import { useEffect, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { Form, Input, Button, message, Divider } from 'antd'; import { UserOutlined, LockOutlined, SafetyCertificateOutlined } from '@ant-design/icons'; import { useAuthStore } from '../stores/auth'; import ThemeSwitcher from '../components/ThemeSwitcher'; import { getPublicBrand, type BrandConfig } from '../api/themes'; export default function Login() { const navigate = useNavigate(); const login = useAuthStore((s) => s.login); const loading = useAuthStore((s) => s.loading); const [messageApi, contextHolder] = message.useMessage(); const [brand, setBrand] = useState(null); useEffect(() => { getPublicBrand().then(setBrand); }, []); const onFinish = async (values: { username: string; password: string }) => { try { await login(values.username, values.password); messageApi.success('登录成功'); navigate('/'); } catch (err: unknown) { const errorMsg = (err as { response?: { data?: { message?: string } } })?.response?.data?.message || '登录失败,请检查用户名和密码'; messageApi.error(errorMsg); } }; return (
{contextHolder} {/* 左侧品牌展示区 */}

{brand?.brand_name || 'HMS 健康管理平台'}

{brand?.brand_slogan || '新一代健康管理平台'}

{brand?.brand_features || '患者管理 · 健康监测 · 随访管理 · AI 智能分析'}

{[ { label: '多租户架构', value: 'SaaS' }, { label: '模块化设计', value: '可插拔' }, { label: '事件驱动', value: '可扩展' }, ].map((item) => (
{item.value}
{item.label}
))}
{/* 右侧登录表单区 */}

欢迎回来

请登录您的账户以继续

} placeholder="用户名" style={{ height: 44, borderRadius: 'var(--erp-radius-md)' }} /> } placeholder="密码" style={{ height: 44, borderRadius: 'var(--erp-radius-md)' }} />
{brand?.brand_copyright || 'HMS 健康管理平台 · ©汕头市智界科技有限公司'}
); }