/** * 登录页面 — 3 个测试角色账号。 */ import { useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { colorVar, FONT_FAMILY, RADIUS, SHADOW, space, typographyStyle, } from '../design-system/components/styles.js'; import { useAuthStore, TEST_ACCOUNTS } from '../stores/authStore.js'; export function Login(): JSX.Element { const navigate = useNavigate(); const { login, error, clearError } = useAuthStore(); const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); const handleSubmit = async (e: React.FormEvent): Promise => { e.preventDefault(); clearError(); const ok = await login(username, password); if (ok) { navigate('/'); } }; const pageStyle: React.CSSProperties = { minHeight: '100vh', display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: `${space(5)}px`, padding: `${space(6)}px ${space(4)}px`, backgroundColor: colorVar('color.bg.canvas'), fontFamily: FONT_FAMILY, }; const cardStyle: React.CSSProperties = { fontFamily: FONT_FAMILY, width: '100%', maxWidth: 400, padding: `${space(7)}px ${space(6)}px`, backgroundColor: colorVar('color.bg.elevated'), borderRadius: `${RADIUS.lg}px`, border: `1px solid ${colorVar('color.border.default')}`, boxShadow: SHADOW.md, }; const inputStyle: React.CSSProperties = { width: '100%', padding: `${space(2)}px ${space(3)}px`, border: `1px solid ${colorVar('color.border.default')}`, borderRadius: `${RADIUS.md}px`, fontFamily: FONT_FAMILY, ...typographyStyle('body'), backgroundColor: colorVar('color.bg.canvas'), color: colorVar('color.text.primary'), boxSizing: 'border-box', }; const buttonStyle: React.CSSProperties = { width: '100%', padding: `${space(3)}px`, backgroundColor: colorVar('color.brand.primary'), color: colorVar('color.text.onAccent'), border: 'none', borderRadius: `${RADIUS.md}px`, cursor: 'pointer', ...typographyStyle('body'), fontWeight: 600, letterSpacing: '-0.01em', }; return (

外包项目风险评估

智能风险评估平台
{ void handleSubmit(e); }} style={{ display: 'flex', flexDirection: 'column', gap: `${space(3)}px` }}>
setUsername(e.target.value)} placeholder="请输入用户名" style={inputStyle} />
setPassword(e.target.value)} placeholder="请输入密码" style={inputStyle} />
{error !== null && (
{error}
)}

点击角色快速登录

{TEST_ACCOUNTS.map((a) => ( ))}
); }