"use client"; import { useState } from "react"; import Link from "next/link"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "@/components/ui/card"; import { api } from "@/lib/api"; export default function ForgotPasswordPage() { const [email, setEmail] = useState(""); const [error, setError] = useState(""); const [loading, setLoading] = useState(false); const [success, setSuccess] = useState(false); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setLoading(true); setError(""); try { await api.auth.forgotPassword(email); setSuccess(true); } catch (err: unknown) { const message = err instanceof Error ? err.message : "请求失败"; setError(message); } finally { setLoading(false); } }; if (success) { return ( 重置链接已发送 重置链接已发送到您的邮箱,请查收 如果您没有收到邮件,请检查垃圾邮件文件夹或稍后再试。 返回登录 ); } return ( 忘记密码 输入您的邮箱地址,我们将发送重置链接 {error && ( {error} )} 邮箱 setEmail(e.target.value)} required /> {loading ? "发送中..." : "发送重置链接"} 返回登录 ); }
如果您没有收到邮件,请检查垃圾邮件文件夹或稍后再试。
{error}