This commit is contained in:
hailin 2025-04-18 17:23:02 +08:00
parent 385ceeeb38
commit b771297b97
2 changed files with 7 additions and 2 deletions

View File

@ -5,10 +5,13 @@ import { supabase } from "@/lib/supabase/browser-client"
import { useRouter } from "next/navigation"
import { useEffect, useState } from "react"
import { usePathname } from "next/navigation" // 导入 usePathname
export default function ChangePasswordPage() {
const [loading, setLoading] = useState(true)
const router = useRouter()
const pathname = usePathname() // 获取当前路径
useEffect(() => {
;(async () => {
@ -16,7 +19,6 @@ export default function ChangePasswordPage() {
if (!session) {
// 提取当前路径中的 locale 部分
const pathname = router.pathname
const locale = pathname.split("/")[1] || "en" // 获取路径中的 locale 部分,如果没有则默认为 "en"
router.push(`${locale}/login`)
} else {

View File

@ -1,6 +1,7 @@
"use client"
import { supabase } from "@/lib/supabase/browser-client"
import { usePathname } from "next/navigation" // 导入 usePathname
import { useRouter } from "next/navigation"
import { FC, useState } from "react"
import { Button } from "../ui/button"
@ -18,6 +19,9 @@ interface ChangePasswordProps {}
export const ChangePassword: FC<ChangePasswordProps> = () => {
const router = useRouter()
const pathname = usePathname() // 获取当前路径
const [newPassword, setNewPassword] = useState("")
const [confirmPassword, setConfirmPassword] = useState("")
@ -30,7 +34,6 @@ export const ChangePassword: FC<ChangePasswordProps> = () => {
toast.success("Password changed successfully.")
// 提取当前路径中的 locale 部分
const pathname = router.pathname
const locale = pathname.split("/")[1] || "en" // 获取路径中的 locale 部分,如果没有则默认为 "en"
// 将 locale 添加到跳转 URL 中