import { Modal, Form, Button, Toast } from '@douyinfe/semi-ui'; import { useAuthStore } from '../../stores/useAuthStore'; import { useUIStore } from '../../stores/useUIStore'; import authService from '../../services/auth.service'; export default function PasswordModal() { const { updatePasswordModalVisible, setUpdatePasswordModalVisible } = useUIStore(); const user = useAuthStore((s) => s.user); const handleSubmit = (values: { username: string; oldpassword: string; newpassword: string; }) => { authService .updatePassword(values.username, values.oldpassword, values.newpassword) .then( () => { Toast.success('密码修改成功'); setUpdatePasswordModalVisible(false); }, (error: unknown) => { const msg = error instanceof Error ? error.message : '修改失败,请重试'; Toast.error(msg); }, ); }; return ( setUpdatePasswordModalVisible(false)} closeOnEsc >
handleSubmit( values as { username: string; oldpassword: string; newpassword: string }, ) } style={{ textAlign: 'center', width: 400 }} initValues={{ username: user?.username ?? '' }} >
); }