diff --git a/web/src/app/(main)/layout.tsx b/web/src/app/(main)/layout.tsx index fef8c20..1022dfc 100644 --- a/web/src/app/(main)/layout.tsx +++ b/web/src/app/(main)/layout.tsx @@ -37,6 +37,10 @@ export default function Layout({ children }: Readonly<{ children: ReactNode }>) if (auth.getToken()) { setAuthed(true); } else { + // 客户端守卫认为未登录时,必须同时清掉 cookie:否则 proxy.ts 仅凭 + // “cookie 存在”就把我们从 /login 又重定向回主界面,与本守卫来回弹跳 + // 形成无限重定向 → 白屏(cookie 与 localStorage 不一致时触发)。 + auth.clearToken(); window.location.href = "/login"; } }, []);