This commit is contained in:
parent
97b9ff80c6
commit
dba0371580
|
|
@ -47,6 +47,7 @@ import { usePathname } from "next/navigation" // 导入 usePathname
|
||||||
|
|
||||||
import { useTranslation } from "react-i18next"; // 引入useTranslation用于国际化
|
import { useTranslation } from "react-i18next"; // 引入useTranslation用于国际化
|
||||||
|
|
||||||
|
import i18nConfig from "@/i18nConfig"
|
||||||
|
|
||||||
interface ProfileSettingsProps {}
|
interface ProfileSettingsProps {}
|
||||||
|
|
||||||
|
|
@ -133,9 +134,20 @@ export const ProfileSettings: FC<ProfileSettingsProps> = ({}) => {
|
||||||
const handleSignOut = async () => {
|
const handleSignOut = async () => {
|
||||||
await supabase.auth.signOut()
|
await supabase.auth.signOut()
|
||||||
|
|
||||||
console.log(`...................Redirecting to: /${locale}/login`)
|
const pathSegments = pathname.split("/").filter(Boolean)
|
||||||
|
const locales = i18nConfig.locales
|
||||||
router.push(`/${locale}/login`)
|
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()
|
router.refresh()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue