From 43b441fd12ce056a6785c97656aac007dac32a62 Mon Sep 17 00:00:00 2001 From: hailin Date: Mon, 21 Apr 2025 11:23:24 +0800 Subject: [PATCH] . --- components/utility/profile-settings.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/components/utility/profile-settings.tsx b/components/utility/profile-settings.tsx index 373be95..0e7d217 100644 --- a/components/utility/profile-settings.tsx +++ b/components/utility/profile-settings.tsx @@ -134,6 +134,14 @@ export const ProfileSettings: FC = ({}) => { const handleSignOut = async () => { await supabase.auth.signOut() + // ✅ 清除 localStorage 中的语言偏好 + if (typeof window !== "undefined") { + localStorage.removeItem("preferred-language") + } + + // ✅ 清除 Cookie 中的语言偏好(设置 max-age=0 立即过期) + document.cookie = "preferred-language=; path=/; max-age=0" + const pathSegments = pathname.split("/").filter(Boolean) const locales = i18nConfig.locales const defaultLocale = i18nConfig.defaultLocale @@ -146,7 +154,6 @@ export const ProfileSettings: FC = ({}) => { locale = segment } - // const loginPath = locale === defaultLocale ? "/login" : `/${locale}/login` const homePath = locale === defaultLocale ? "/" : `/${locale}` router.push(homePath)