import { useState } from 'react' import { Card, Form, Input, Button, Typography, message, Result } from 'antd' import { LockOutlined } from '@ant-design/icons' import { useNavigate } from 'react-router-dom' import { useAppStore } from '../store' import api from '../api/client' const { Title, Text } = Typography export default function ForceChangePassword() { const [loading, setLoading] = useState(false) const [done, setDone] = useState(false) const navigate = useNavigate() const { user, setAuth, token } = useAppStore() const handleSubmit = async (values: { old_password: string; new_password: string; confirm: string }) => { if (values.new_password !== values.confirm) { message.error('两次密码不一致') return } setLoading(true) try { await api.put('/auth/password', { old_password: values.old_password, new_password: values.new_password, }) // Update user in store to clear must_change_password if (user && token) { setAuth(token, { ...user, must_change_password: false }) } setDone(true) } catch (err: any) { message.error(err?.response?.data?.message || err?.data?.message || '修改失败') } finally { setLoading(false) } } if (done) { return (