/** * 登录页面 — Ant Design Form + Zustand authStore。 */ import React, { useState } from "react"; import { Button, Card, Form, Input, message, Typography, Space } from "antd"; import { LockOutlined, UserOutlined } from "@ant-design/icons"; import { useNavigate } from "react-router-dom"; import { useAuthStore } from "../store/authStore"; const { Title, Text } = Typography; interface LoginFormValues { username: string; password: string; } const Login: React.FC = () => { const navigate = useNavigate(); const login = useAuthStore((s) => s.login); const [loading, setLoading] = useState(false); const onFinish = async (values: LoginFormValues) => { setLoading(true); try { await login(values.username, values.password); message.success("登录成功"); navigate("/dashboard", { replace: true }); } catch (err: unknown) { const detail = (err as { response?: { data?: { detail?: string } } })?.response?.data ?.detail ?? "登录失败,请检查用户名和密码"; message.error(detail); } finally { setLoading(false); } }; return (