@@ -121,3 +121,23 @@
|
||||
- 风险与影响:
|
||||
- 影响面仅前端浏览器标签图标资源。
|
||||
- 可能受浏览器 favicon 缓存影响,首次需强刷后看到新图标。
|
||||
|
||||
## Work Log - 修复退出登录闪烁(2026-05-02)
|
||||
|
||||
- 背景:
|
||||
- 当前退出登录会先把前端登录态置空,再触发页面跳转。
|
||||
- 在后台页会先短暂渲染“请先登录”占位,再跳回登录页,造成肉眼可见闪烁。
|
||||
|
||||
- 本次改动(最小闭环):
|
||||
- 文件:`web/src/components/auth-provider.tsx`
|
||||
- 调整 `logout` 的 `finally` 收尾顺序:
|
||||
- 浏览器环境下优先执行 `window.location.replace("/")` 并直接返回;
|
||||
- 非浏览器环境才执行 `clearAuth()`。
|
||||
- 效果:避免在跳转前先渲染未登录中间态页面。
|
||||
|
||||
- 风险与影响:
|
||||
- 影响面仅前端退出流程。
|
||||
- 行为变化为“直接跳登录页”,不会改变后端登出接口调用逻辑。
|
||||
|
||||
- 验证建议:
|
||||
- 已登录状态下从任意后台页面点击“退出登录”,预期直接到登录页,不再出现“请先登录”闪屏。
|
||||
|
||||
@@ -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]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user