This commit is contained in:
parent
e3529b1b02
commit
8929ecc5de
|
|
@ -1,5 +1,7 @@
|
|||
"use client"
|
||||
|
||||
import { usePathname } from "next/navigation"
|
||||
|
||||
import { Dashboard } from "@/components/ui/dashboard"
|
||||
import { ChatbotUIContext } from "@/context/context"
|
||||
import { getAssistantWorkspacesByWorkspaceId } from "@/db/assistants"
|
||||
|
|
@ -27,6 +29,9 @@ interface WorkspaceLayoutProps {
|
|||
export default function WorkspaceLayout({ children }: WorkspaceLayoutProps) {
|
||||
const router = useRouter()
|
||||
|
||||
// 提取当前路径中的 locale 部分
|
||||
const locale = pathname.split("/")[1] || "en"
|
||||
|
||||
const params = useParams()
|
||||
const searchParams = useSearchParams()
|
||||
const workspaceId = params.workspaceid as string
|
||||
|
|
@ -64,7 +69,8 @@ export default function WorkspaceLayout({ children }: WorkspaceLayoutProps) {
|
|||
const session = (await supabase.auth.getSession()).data.session
|
||||
|
||||
if (!session) {
|
||||
return router.push("/login")
|
||||
// 跳转到带有 locale 的登录页面
|
||||
return router.push(`/${locale}/login`)
|
||||
} else {
|
||||
await fetchWorkspaceData(workspaceId)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ export default async function Login({
|
|||
const supabase = createClient(cookieStore)
|
||||
|
||||
const { error } = await supabase.auth.resetPasswordForEmail(email, {
|
||||
redirectTo: `${origin}/auth/callback?next=/login/password`
|
||||
redirectTo: `${origin}/auth/callback?next=${localeString}/login/password`
|
||||
})
|
||||
|
||||
if (error) {
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@ import { TextareaAutosize } from "../ui/textarea-autosize"
|
|||
import { WithTooltip } from "../ui/with-tooltip"
|
||||
import { ThemeSwitcher } from "./theme-switcher"
|
||||
|
||||
import { usePathname } from "next/navigation" // 导入 usePathname
|
||||
|
||||
interface ProfileSettingsProps {}
|
||||
|
||||
export const ProfileSettings: FC<ProfileSettingsProps> = ({}) => {
|
||||
|
|
@ -56,6 +58,10 @@ export const ProfileSettings: FC<ProfileSettingsProps> = ({}) => {
|
|||
} = useContext(ChatbotUIContext)
|
||||
|
||||
const router = useRouter()
|
||||
const pathname = usePathname() // 获取当前路径
|
||||
|
||||
// 提取当前路径中的 locale 部分
|
||||
const locale = pathname.split("/")[1] || "en"
|
||||
|
||||
const buttonRef = useRef<HTMLButtonElement>(null)
|
||||
|
||||
|
|
@ -120,7 +126,8 @@ export const ProfileSettings: FC<ProfileSettingsProps> = ({}) => {
|
|||
|
||||
const handleSignOut = async () => {
|
||||
await supabase.auth.signOut()
|
||||
router.push("/login")
|
||||
|
||||
router.push(`${locale}/login`)
|
||||
router.refresh()
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue