From e3164f34ec35bc6e9925de9e256d555158f56dea Mon Sep 17 00:00:00 2001 From: chengkml Date: Sat, 2 May 2026 11:37:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=80=80=E5=87=BA=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E9=97=AA=E7=83=81=E5=B9=B6=E7=9B=B4=E8=BE=BE=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: multica-agent --- memory/2026-05-02.md | 20 ++++++++++++++++++++ web/src/components/auth-provider.tsx | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/memory/2026-05-02.md b/memory/2026-05-02.md index 75ad70d..16e6ef7 100644 --- a/memory/2026-05-02.md +++ b/memory/2026-05-02.md @@ -121,3 +121,23 @@ - 风险与影响: - 影响面仅前端浏览器标签图标资源。 - 可能受浏览器 favicon 缓存影响,首次需强刷后看到新图标。 + +## Work Log - 修复退出登录闪烁(2026-05-02) + +- 背景: + - 当前退出登录会先把前端登录态置空,再触发页面跳转。 + - 在后台页会先短暂渲染“请先登录”占位,再跳回登录页,造成肉眼可见闪烁。 + +- 本次改动(最小闭环): + - 文件:`web/src/components/auth-provider.tsx` + - 调整 `logout` 的 `finally` 收尾顺序: + - 浏览器环境下优先执行 `window.location.replace("/")` 并直接返回; + - 非浏览器环境才执行 `clearAuth()`。 + - 效果:避免在跳转前先渲染未登录中间态页面。 + +- 风险与影响: + - 影响面仅前端退出流程。 + - 行为变化为“直接跳登录页”,不会改变后端登出接口调用逻辑。 + +- 验证建议: + - 已登录状态下从任意后台页面点击“退出登录”,预期直接到登录页,不再出现“请先登录”闪屏。 diff --git a/web/src/components/auth-provider.tsx b/web/src/components/auth-provider.tsx index ed65128..7fc1daa 100644 --- a/web/src/components/auth-provider.tsx +++ b/web/src/components/auth-provider.tsx @@ -179,10 +179,11 @@ export function AuthProvider({ children }: { children: React.ReactNode }) { credentials: "include", }); } finally { - clearAuth(); if (typeof window !== "undefined") { window.location.replace("/"); + return; } + clearAuth(); } }, [clearAuth]);