fix: 优化登录相关权限问题 添加按键权限判断
This commit is contained in:
@@ -39,6 +39,11 @@ router.beforeEach(async (to, _from, next) => {
|
||||
await Promise.all([loadMenu(), loadPermissions()]);
|
||||
}
|
||||
|
||||
if (!auth.isLoggedIn()) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
|
||||
const redirectPath = getRedirectPath(to.query.redirect);
|
||||
const targetPath =
|
||||
redirectPath && isRoutePathAvailable(redirectPath)
|
||||
@@ -63,6 +68,12 @@ router.beforeEach(async (to, _from, next) => {
|
||||
const { loadPermissions } = usePermissionStore();
|
||||
await Promise.all([loadMenu(), loadPermissions()]);
|
||||
|
||||
// 权限获取失败时会清空会话,此时回登录页而不是继续进入业务页
|
||||
if (!auth.isLoggedIn()) {
|
||||
next({ path: '/login', replace: true });
|
||||
return;
|
||||
}
|
||||
|
||||
// 动态路由刚注册,需要用新路由表重新匹配当前路径
|
||||
next({ path: to.fullPath, replace: true });
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user