mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-10-07 02:01:37 +00:00
fix(router): 修复存储失效时登出逻辑的循环依赖
将存储失效登出逻辑从 storage 模块移至路由守卫,通过标志位解耦, 消除动态 import 及其引发的循环依赖问题。
This commit is contained in:
@@ -19,6 +19,7 @@ import { UserAPI } from "@/api/module_system/user";
|
||||
import { ApiStatus, isHttpError } from "@utils/http";
|
||||
import { RouteRegistry } from "./dynamicRoutes";
|
||||
import { MenuProcessor } from "./MenuProcessor";
|
||||
import { checkStorageInvalidated } from "@utils/storage";
|
||||
|
||||
// --- 模块级单例与守卫状态 ---
|
||||
|
||||
@@ -119,6 +120,14 @@ async function handleRouteGuard(
|
||||
NProgress.start();
|
||||
}
|
||||
|
||||
// 检查存储是否已失效(storage/index.ts 检测到异常时标记)
|
||||
if (checkStorageInvalidated()) {
|
||||
console.info("[RouteGuard] 检测到存储已失效,执行登出");
|
||||
await userStore.logout();
|
||||
next({ name: "Login", replace: true });
|
||||
return;
|
||||
}
|
||||
|
||||
if (!handleLoginStatus(to, userStore, next)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user