This commit is contained in:
zk
2024-06-27 11:26:55 +08:00
parent 778e350959
commit 752405b9a4
4 changed files with 72 additions and 10 deletions
+14
View File
@@ -1,5 +1,7 @@
import { createRouter, createWebHistory, Router, RouteRecordRaw } from 'vue-router';
import { setCurrentPath } from '/@/enum/pageEnum.ts';
import { store } from '/@/store';
import { useUserStoreWithOut } from '/@/store/modules/user.ts';
const routes: Array<RouteRecordRaw> = [
{
@@ -61,7 +63,19 @@ const router: Router = createRouter({
history: createWebHistory('/'),
routes: [...routes],
});
const xian = ['/login', '/home', '/secondScreen', '/transfer'];
const yinchuan = ['/screenLogin', '/secondScreen', '/transfer'];
router.beforeEach((to, from, next) => {
console.log('store', store);
let flag1 = store.getters.getFlag1();
let flag2 = store.getters.getFlag2();
if (flag1 && !flag2 && !yinchuan.includes(to.path)) {
return next('/screenLogin');
}
if (flag2 && !flag1 && !xian.includes(to.path)) {
return next('/login');
}
if (to.path !== '/login' && to.path !== '/screenLogin') {
setCurrentPath(to.path);
}