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;