From 7772de1acf4f0d17c0b4df8538bc9b1183870deb Mon Sep 17 00:00:00 2001 From: hzm <934585316@qq.com> Date: Sun, 8 Feb 2026 07:14:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=8C=E5=96=84=E4=BC=9A=E8=AF=9D?= =?UTF-8?q?=E8=BF=87=E6=9C=9F=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/page.jsx | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/app/page.jsx b/app/page.jsx index 7fe508a..80c3bcd 100644 --- a/app/page.jsx +++ b/app/page.jsx @@ -2438,8 +2438,25 @@ export default function HomePage() { if (session.expires_at && session.expires_at * 1000 <= Date.now()) { isLoggingOutRef.current = true; await supabase.auth.signOut({ scope: 'local' }); + try { + const storageKeys = Object.keys(localStorage); + storageKeys.forEach((key) => { + if (key === 'supabase.auth.token' || (key.startsWith('sb-') && key.endsWith('-auth-token'))) { + localStorage.removeItem(key); + } + }); + } catch { } + try { + const sessionKeys = Object.keys(sessionStorage); + sessionKeys.forEach((key) => { + if (key === 'supabase.auth.token' || (key.startsWith('sb-') && key.endsWith('-auth-token'))) { + sessionStorage.removeItem(key); + } + }); + } catch { } clearAuthState(); setLoginError('会话已过期,请重新登录'); + showToast('会话已过期,请重新登录', 'error'); setLoginModalOpen(true); return; } @@ -2564,17 +2581,39 @@ export default function HomePage() { try { const { data: { session } } = await supabase.auth.getSession(); if (session) { - const { error } = await supabase.auth.signOut(); + const { error } = await supabase.auth.signOut({ scope: 'local' }); if (error && error.code !== 'session_not_found') { throw error; } } } catch (err) { + showToast(err.message, 'error') console.error('登出失败', err); } finally { try { await supabase.auth.signOut({ scope: 'local' }); } catch { } + try { + const storageKeys = Object.keys(localStorage); + storageKeys.forEach((key) => { + if (key === 'supabase.auth.token' || (key.startsWith('sb-') && key.endsWith('-auth-token'))) { + localStorage.removeItem(key); + } + }); + } catch { } + try { + const sessionKeys = Object.keys(sessionStorage); + sessionKeys.forEach((key) => { + if (key === 'supabase.auth.token' || (key.startsWith('sb-') && key.endsWith('-auth-token'))) { + sessionStorage.removeItem(key); + } + }); + } catch { } + setLoginModalOpen(false); + setLoginError(''); + setLoginSuccess(''); + setLoginEmail(''); + setLoginOtp(''); setUserMenuOpen(false); setUser(null); }