import { useState } from 'react' import { useNavigate } from 'react-router-dom' import { Card, Form, Input, Button, Typography, message, Space } from 'antd' import { UserOutlined, LockOutlined } from '@ant-design/icons' import { useAuth } from '../store/auth' export default function Login() { const { login } = useAuth() const navigate = useNavigate() const [loading, setLoading] = useState(false) const onFinish = async (values: { username: string; password: string }) => { setLoading(true) try { await login(values.username, values.password) message.success('登录成功') navigate('/') } catch (e) { message.error(e instanceof Error ? e.message : '登录失败') } finally { setLoading(false) } } return (