fix: 优化登录相关权限问题 添加按键权限判断

This commit is contained in:
ZhuRui
2026-08-05 15:30:09 +08:00
parent 503ee266b0
commit 73d4d8fd34
18 changed files with 283 additions and 95 deletions
+11
View File
@@ -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;