import { useState } from 'react'; import { Card, Form, Input, Button, Typography, Space, Alert } from 'antd'; import { UserOutlined, LockOutlined, GithubOutlined, SendOutlined, WechatOutlined, CloudSyncOutlined, SearchOutlined, ShareAltOutlined, ApartmentOutlined } from '@ant-design/icons'; import { useAuth } from '../contexts/AuthContext'; import { useSystemStatus } from '../contexts/SystemContext'; import { useNavigate } from 'react-router'; const { Title, Text } = Typography; export default function LoginPage() { const status = useSystemStatus(); const { login } = useAuth(); const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); const [err, setErr] = useState(''); const [loading, setLoading] = useState(false); const navigate = useNavigate(); const handleSubmit = async () => { const u = username.trim(); const p = password; if (!u || !p) { setErr('请输入用户名与密码'); return; } console.debug('[LoginPage] submit ->', { username: u, passwordLength: p.length }); setErr(''); setLoading(true); try { await login(u, p); navigate('/'); } catch (e: any) { console.error('[LoginPage] login failed:', e); setErr(e.message || '登录失败'); } finally { setLoading(false); } }; return (