6.13提交

This commit is contained in:
zoujiandong
2023-06-13 16:04:55 +08:00
parent fa1ecdafbc
commit 0f0240bc45
15 changed files with 119 additions and 73 deletions
+8 -8
View File
@@ -3,7 +3,6 @@ import Layout from '../layout/index.vue';
import { useUserStore } from '../store/userInfo';
import { usePermissionStore } from '../store/permission';
import Watermark from '@/utils/watermark.js';
const routes = [
{
path: '/',
@@ -67,22 +66,23 @@ router.beforeEach(async (to, from, next) => {
// 获取系统配置信息
await store.getSysConfig();
console.log(permissionStore.addRouters.length)
// 判断用户Token是否获取
if (to.name !== 'login' && !store.token) {
next({ name: 'login' });
next({ name: 'login' });
} else {
// 判断判断权限有无获取
if (store.token && store.roles.length === 0) {
store.getUserInfo();
console.log(store.token,permissionStore.addRouters.length)
if (store.token && permissionStore.addRouters.length==0) {
//store.getUserInfo();
await permissionStore.getMenuRole();
permissionStore.addRouters.forEach((route) => {
permissionStore.addRouters.forEach((route) => {
router.addRoute('/', route);
});
// next(to.fullPath);
// 如果 addRoute 并未完成,路由守卫会一层一层的执行执行,直到 addRoute 完成,找到对应的路由
next({ ...to, replace: true })
next({ ...to, replace: true });
} else {
next();
}