This commit is contained in:
zk
2023-12-22 16:57:16 +08:00
parent dd5a47e7fb
commit b9f2b3b521
15 changed files with 240 additions and 182 deletions
+2 -24
View File
@@ -1,6 +1,4 @@
import {createRouter, createWebHistory, Router, RouteRecordRaw} from 'vue-router';
import {getAuthCache} from '/@/utils/auth.ts';
import {TOKEN_KEY} from '/@/enum/cacheEnum.ts';
import { createRouter, createWebHistory, Router, RouteRecordRaw } from 'vue-router';
const routes: Array<RouteRecordRaw> = [
{
@@ -36,27 +34,7 @@ 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;