This commit is contained in:
hailin 2025-04-21 01:22:08 +08:00
parent 97b9ff80c6
commit dba0371580
1 changed files with 15 additions and 3 deletions

View File

@ -47,6 +47,7 @@ import { usePathname } from "next/navigation" // 导入 usePathname
import { useTranslation } from "react-i18next"; // 引入useTranslation用于国际化
import i18nConfig from "@/i18nConfig"
interface ProfileSettingsProps {}
@ -133,9 +134,20 @@ export const ProfileSettings: FC<ProfileSettingsProps> = ({}) => {
const handleSignOut = async () => {
await supabase.auth.signOut()
console.log(`...................Redirecting to: /${locale}/login`)
router.push(`/${locale}/login`)
const pathSegments = pathname.split("/").filter(Boolean)
const locales = i18nConfig.locales
const defaultLocale = i18nConfig.defaultLocale
let locale = defaultLocale
// 动态判断首段是否是合法语言代码
if (locales.includes(pathSegments[0])) {
locale = pathSegments[0]
}
const loginPath = locale === defaultLocale ? "/login" : `/${locale}/login`
router.push(loginPath)
router.refresh()
return
}