/** * 忘记密码页面 - V21 完全对标 */ import React, { useState } from 'react'; import { Form, Input, Button, Result, message } from 'antd'; import { MailOutlined } from '@ant-design/icons'; import { Link } from 'react-router-dom'; import { useMutation } from '@tanstack/react-query'; import { requestPasswordReset } from '@/api/auth'; import './ForgotPassword.css'; const ForgotPassword: React.FC = () => { const [form] = Form.useForm(); const [emailSent, setEmailSent] = useState(false); const resetMutation = useMutation({ mutationFn: (email: string) => requestPasswordReset(email), onSuccess: () => { setEmailSent(true); message.success('重置邮件已发送!'); }, onError: (error: unknown) => { if (!(error as { __msgShown?: boolean })?.__msgShown) message.error('发送失败,请重试'); }, }); const onFinish = (values: { email: string }) => { resetMutation.mutate(values.email); }; if (emailSent) { return (
, ]} />
); } return (
🦐

小虾自动剪辑

重置密码

请输入您的邮箱地址,我们将发送重置密码的链接到您的邮箱。

} placeholder="name@example.com" size="large" />
返回登录
); }; export default ForgotPassword;