This commit is contained in:
zk
2023-12-19 18:10:46 +08:00
parent 3e53c75a6f
commit 8dccce0208
16 changed files with 128 additions and 35 deletions
+24 -1
View File
@@ -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;