批量更新
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { createRouter, createWebHashHistory } from "vue-router";
|
||||
import { convertMenusToRoutes } from "./dynamicRoutes";
|
||||
import { isSSOEnabled, redirectToAuthorize } from "@/utils/authClient";
|
||||
import { isSSOEnabled, redirectToAuthorize, ensureUserInfo } from "@/utils/authClient";
|
||||
|
||||
// 静态子路由:需要在 Main 框架内显示的页面
|
||||
const staticMainChildren = [
|
||||
@@ -335,6 +335,17 @@ router.beforeEach(async (to, from, next) => {
|
||||
next({ path: "/login", query: { redirect: to.path } });
|
||||
return;
|
||||
}
|
||||
|
||||
// 统一认证模式:补全用户信息(旧会话可能只有 token 没有 userInfo,
|
||||
// 或迁移后 userInfo 缺失 id,会导致菜单等接口报「用户ID不存在」)。
|
||||
// 令牌失效时 ensureUserInfo 会清空登录态并返回 null,此时重新登录。
|
||||
if (isSSOEnabled()) {
|
||||
const info = await ensureUserInfo();
|
||||
if (!info) {
|
||||
await redirectToAuthorize();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!dynamicRoutesAdded) {
|
||||
await loadAndAddDynamicRoutes();
|
||||
|
||||
Reference in New Issue
Block a user