This commit is contained in:
parent
e3b7c93300
commit
e816303958
|
|
@ -7,6 +7,8 @@ import { useEffect, useState } from "react"
|
||||||
|
|
||||||
import { usePathname } from "next/navigation" // 导入 usePathname
|
import { usePathname } from "next/navigation" // 导入 usePathname
|
||||||
|
|
||||||
|
import i18nConfig from "@/i18nConfig"
|
||||||
|
|
||||||
export default function ChangePasswordPage() {
|
export default function ChangePasswordPage() {
|
||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
|
|
||||||
|
|
@ -18,9 +20,27 @@ export default function ChangePasswordPage() {
|
||||||
const session = (await supabase.auth.getSession()).data.session
|
const session = (await supabase.auth.getSession()).data.session
|
||||||
|
|
||||||
if (!session) {
|
if (!session) {
|
||||||
// 提取当前路径中的 locale 部分
|
// // 提取当前路径中的 locale 部分
|
||||||
const locale = pathname.split("/")[1] || "en" // 获取路径中的 locale 部分,如果没有则默认为 "en"
|
// const locale = pathname.split("/")[1] || "en" // 获取路径中的 locale 部分,如果没有则默认为 "en"
|
||||||
router.push(`${locale}/login`)
|
|
||||||
|
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}/login`)
|
||||||
|
// router.push(`${locale}/login`)
|
||||||
} else {
|
} else {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,9 @@ import { FC, useContext, useRef, useState } from "react"
|
||||||
import { Input } from "../ui/input"
|
import { Input } from "../ui/input"
|
||||||
import { useRouter } from "next/navigation"
|
import { useRouter } from "next/navigation"
|
||||||
|
|
||||||
|
import { usePathname } from "next/navigation"
|
||||||
|
import i18nConfig from "@/i18nConfig"
|
||||||
|
|
||||||
interface DeleteWorkspaceProps {
|
interface DeleteWorkspaceProps {
|
||||||
workspace: Tables<"workspaces">
|
workspace: Tables<"workspaces">
|
||||||
onDelete: () => void
|
onDelete: () => void
|
||||||
|
|
@ -46,7 +49,25 @@ export const DeleteWorkspace: FC<DeleteWorkspaceProps> = ({
|
||||||
const defaultWorkspace = filteredWorkspaces[0]
|
const defaultWorkspace = filteredWorkspaces[0]
|
||||||
|
|
||||||
setSelectedWorkspace(defaultWorkspace)
|
setSelectedWorkspace(defaultWorkspace)
|
||||||
router.push(`/${defaultWorkspace.id}/chat`)
|
|
||||||
|
|
||||||
|
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}/${defaultWorkspace.id}/chat`)
|
||||||
|
// router.push(`/${defaultWorkspace.id}/chat`)
|
||||||
|
|
||||||
return filteredWorkspaces
|
return filteredWorkspaces
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue