From e7b28dfb300767f3d74f1e3f08a3d687e2d9ea21 Mon Sep 17 00:00:00 2001 From: hzm <934585316@qq.com> Date: Sun, 8 Feb 2026 05:32:53 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9Atoken=20=E8=BF=87=E6=9C=9F?= =?UTF-8?q?=E9=87=8D=E6=96=B0=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/page.jsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/page.jsx b/app/page.jsx index 68a6972..5cfe077 100644 --- a/app/page.jsx +++ b/app/page.jsx @@ -1768,6 +1768,7 @@ export default function HomePage() { const [error, setError] = useState(''); const timerRef = useRef(null); const refreshingRef = useRef(false); + const isLoggingOutRef = useRef(false); // 刷新频率状态 const [refreshMs, setRefreshMs] = useState(30000); @@ -2414,12 +2415,20 @@ export default function HomePage() { const handleSession = async (session, event) => { if (!session?.user) { + if (event === 'SIGNED_OUT' && !isLoggingOutRef.current) { + setLoginError('会话已过期,请重新登录'); + setLoginModalOpen(true); + } + isLoggingOutRef.current = false; clearAuthState(); return; } if (session.expires_at && session.expires_at * 1000 <= Date.now()) { + isLoggingOutRef.current = true; await supabase.auth.signOut({ scope: 'local' }); clearAuthState(); + setLoginError('会话已过期,请重新登录'); + setLoginModalOpen(true); return; } setUser(session.user); @@ -2539,6 +2548,7 @@ export default function HomePage() { // 登出 const handleLogout = async () => { + isLoggingOutRef.current = true; try { const { data: { session } } = await supabase.auth.getSession(); if (!session) {