import React, { useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { Form, Input, Button, message, Typography } from 'antd'; import { UserOutlined, LockOutlined } from '@ant-design/icons'; import { login } from '../../api/auth'; import { useAuthStore } from '../../store/useAuthStore'; const { Title, Text } = Typography; const LoginPage: React.FC = () => { const [loading, setLoading] = useState(false); const navigate = useNavigate(); const { setAuth } = useAuthStore(); const onFinish = async (values: { username: string; password: string }) => { setLoading(true); try { const res = await login(values); setAuth(res.data.token.access, res.data.token.refresh, res.data.admin); message.success('登录成功'); navigate('/dashboard'); } catch (error) { message.error(error instanceof Error ? error.message : '登录失败'); } finally { setLoading(false); } }; return (