This commit is contained in:
parent
385ceeeb38
commit
b771297b97
|
|
@ -5,10 +5,13 @@ import { supabase } from "@/lib/supabase/browser-client"
|
||||||
import { useRouter } from "next/navigation"
|
import { useRouter } from "next/navigation"
|
||||||
import { useEffect, useState } from "react"
|
import { useEffect, useState } from "react"
|
||||||
|
|
||||||
|
import { usePathname } from "next/navigation" // 导入 usePathname
|
||||||
|
|
||||||
export default function ChangePasswordPage() {
|
export default function ChangePasswordPage() {
|
||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const pathname = usePathname() // 获取当前路径
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
;(async () => {
|
;(async () => {
|
||||||
|
|
@ -16,7 +19,6 @@ export default function ChangePasswordPage() {
|
||||||
|
|
||||||
if (!session) {
|
if (!session) {
|
||||||
// 提取当前路径中的 locale 部分
|
// 提取当前路径中的 locale 部分
|
||||||
const pathname = router.pathname
|
|
||||||
const locale = pathname.split("/")[1] || "en" // 获取路径中的 locale 部分,如果没有则默认为 "en"
|
const locale = pathname.split("/")[1] || "en" // 获取路径中的 locale 部分,如果没有则默认为 "en"
|
||||||
router.push(`${locale}/login`)
|
router.push(`${locale}/login`)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { supabase } from "@/lib/supabase/browser-client"
|
import { supabase } from "@/lib/supabase/browser-client"
|
||||||
|
import { usePathname } from "next/navigation" // 导入 usePathname
|
||||||
import { useRouter } from "next/navigation"
|
import { useRouter } from "next/navigation"
|
||||||
import { FC, useState } from "react"
|
import { FC, useState } from "react"
|
||||||
import { Button } from "../ui/button"
|
import { Button } from "../ui/button"
|
||||||
|
|
@ -18,6 +19,9 @@ interface ChangePasswordProps {}
|
||||||
|
|
||||||
export const ChangePassword: FC<ChangePasswordProps> = () => {
|
export const ChangePassword: FC<ChangePasswordProps> = () => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const pathname = usePathname() // 获取当前路径
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const [newPassword, setNewPassword] = useState("")
|
const [newPassword, setNewPassword] = useState("")
|
||||||
const [confirmPassword, setConfirmPassword] = useState("")
|
const [confirmPassword, setConfirmPassword] = useState("")
|
||||||
|
|
@ -30,7 +34,6 @@ export const ChangePassword: FC<ChangePasswordProps> = () => {
|
||||||
toast.success("Password changed successfully.")
|
toast.success("Password changed successfully.")
|
||||||
|
|
||||||
// 提取当前路径中的 locale 部分
|
// 提取当前路径中的 locale 部分
|
||||||
const pathname = router.pathname
|
|
||||||
const locale = pathname.split("/")[1] || "en" // 获取路径中的 locale 部分,如果没有则默认为 "en"
|
const locale = pathname.split("/")[1] || "en" // 获取路径中的 locale 部分,如果没有则默认为 "en"
|
||||||
|
|
||||||
// 将 locale 添加到跳转 URL 中
|
// 将 locale 添加到跳转 URL 中
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue