This commit is contained in:
parent
ba2c8b985f
commit
c929269e8e
|
|
@ -85,9 +85,9 @@ export default async function RootLayout({
|
||||||
// const session = (await supabase.auth.getSession()).data.session
|
// const session = (await supabase.auth.getSession()).data.session
|
||||||
const { data, error } = await supabase.auth.getSession();
|
const { data, error } = await supabase.auth.getSession();
|
||||||
if (error) {
|
if (error) {
|
||||||
console.log("[layout.tsx]Session Error: ", error);
|
console.log("............[layout.tsx]Session Error: ", error);
|
||||||
} else {
|
} else {
|
||||||
console.log("[layout.tsx]Session Data: ", data.session);
|
console.log("............[layout.tsx]Session Data: ", data.session);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { t, resources } = await initTranslations(locale, i18nNamespaces)
|
const { t, resources } = await initTranslations(locale, i18nNamespaces)
|
||||||
|
|
|
||||||
|
|
@ -131,16 +131,60 @@ export const ProfileSettings: FC<ProfileSettingsProps> = ({}) => {
|
||||||
profile?.openrouter_api_key || ""
|
profile?.openrouter_api_key || ""
|
||||||
)
|
)
|
||||||
|
|
||||||
const handleSignOut = async () => {
|
// const handleSignOut = async () => {
|
||||||
await supabase.auth.signOut()
|
// 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
|
||||||
|
|
||||||
|
// let locale: (typeof locales)[number] = defaultLocale
|
||||||
|
|
||||||
|
// const segment = pathSegments[0] as (typeof locales)[number]
|
||||||
|
|
||||||
|
// if (locales.includes(segment)) {
|
||||||
|
// locale = segment
|
||||||
|
// }
|
||||||
|
|
||||||
|
// const homePath = locale === defaultLocale ? "/" : `/${locale}`
|
||||||
|
|
||||||
|
// router.push(homePath)
|
||||||
|
// router.refresh()
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const handleSignOut = async () => {
|
||||||
|
try {
|
||||||
|
// 调用 Supabase 注销
|
||||||
|
await supabase.auth.signOut();
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Sign-out error:", error);
|
||||||
|
// 在错误发生时显示反馈或进行其他处理
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// ✅ 清除 localStorage 中的语言偏好
|
// ✅ 清除 localStorage 中的语言偏好
|
||||||
if (typeof window !== "undefined") {
|
if (typeof window !== "undefined") {
|
||||||
localStorage.removeItem("preferred-language")
|
localStorage.removeItem("preferred-language");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ✅ 清除 Cookie 中的语言偏好(设置 max-age=0 立即过期)
|
// ✅ 清除 Cookie 中的语言偏好(设置 max-age=0 立即过期)
|
||||||
document.cookie = "preferred-language=; path=/; max-age=0"
|
document.cookie = "preferred-language=; path=/; max-age=0";
|
||||||
|
|
||||||
|
// 清除相关 cookies,例如 access_token 和 refresh_token
|
||||||
|
document.cookie = "access_token=; path=/; max-age=0";
|
||||||
|
document.cookie = "refresh_token=; path=/; max-age=0";
|
||||||
|
|
||||||
const pathSegments = pathname.split("/").filter(Boolean)
|
const pathSegments = pathname.split("/").filter(Boolean)
|
||||||
const locales = i18nConfig.locales
|
const locales = i18nConfig.locales
|
||||||
|
|
@ -153,13 +197,11 @@ export const ProfileSettings: FC<ProfileSettingsProps> = ({}) => {
|
||||||
if (locales.includes(segment)) {
|
if (locales.includes(segment)) {
|
||||||
locale = segment
|
locale = segment
|
||||||
}
|
}
|
||||||
|
|
||||||
const homePath = locale === defaultLocale ? "/" : `/${locale}`
|
const homePath = locale === defaultLocale ? "/" : `/${locale}`
|
||||||
|
|
||||||
router.push(homePath)
|
router.push(homePath)
|
||||||
router.refresh()
|
router.refresh()
|
||||||
return
|
return
|
||||||
}
|
};
|
||||||
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
if (!profile) return
|
if (!profile) return
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue