From a7ec5ba7b0c1df7e1f649c8d2b257660f2f722ea Mon Sep 17 00:00:00 2001 From: kkfluous Date: Thu, 2 Apr 2026 15:59:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=98=B2=E6=AD=A2=20StrictMode=20?= =?UTF-8?q?=E5=8F=8C=E9=87=8D=E8=B0=83=E7=94=A8=E5=AF=BC=E8=87=B4=20jumpTo?= =?UTF-8?q?ken=20=E9=87=8D=E5=A4=8D=E6=B6=88=E8=B4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 (1M context) --- src/auth/AuthProvider.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/auth/AuthProvider.tsx b/src/auth/AuthProvider.tsx index 3198832..70a8a30 100644 --- a/src/auth/AuthProvider.tsx +++ b/src/auth/AuthProvider.tsx @@ -12,11 +12,16 @@ export default function AuthProvider({ children }: { children: ReactNode }) { error: null, }); const tokenRef = useRef(null); + const authStarted = useRef(false); useEffect(() => { // 设置全局 token getter setTokenGetter(() => tokenRef.current); + // 防止 StrictMode 双重调用(jumpToken 一次性使用) + if (authStarted.current) return; + authStarted.current = true; + // 监听 401 事件 const onUnauthorized = () => { tokenRef.current = null;