update
This commit is contained in:
+24
-1
@@ -1,4 +1,6 @@
|
||||
import { createRouter, createWebHistory, Router, RouteRecordRaw } from 'vue-router';
|
||||
import {createRouter, createWebHistory, Router, RouteRecordRaw} from 'vue-router';
|
||||
import {getAuthCache} from '/@/utils/auth.ts';
|
||||
import {TOKEN_KEY} from '/@/enum/cacheEnum.ts';
|
||||
|
||||
const routes: Array<RouteRecordRaw> = [
|
||||
{
|
||||
@@ -34,6 +36,27 @@ const routes: Array<RouteRecordRaw> = [
|
||||
|
||||
const router: Router = createRouter({
|
||||
history: createWebHistory('/'),
|
||||
// mode: 'hash',
|
||||
routes: [...routes],
|
||||
});
|
||||
let token = getAuthCache(TOKEN_KEY);
|
||||
// router.beforeEach((to, from, next) => {
|
||||
// console.log('to', to);
|
||||
// console.log('token', token);
|
||||
// // token = null;
|
||||
// if (token) {
|
||||
// // 如果已经登录的话
|
||||
// next();
|
||||
// } else {
|
||||
// if (to.path === '/login') {
|
||||
// // 如果是登录页面的话,直接next()
|
||||
// next();
|
||||
// } else {
|
||||
// // 否则 跳转到登录页面
|
||||
// next({
|
||||
// path: '/login',
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
export default router;
|
||||
|
||||
Reference in New Issue
Block a user