import { useRef, useState } from 'react'; import { Alert, Button, Card, Form, Input, Select, Typography, type InputRef } from 'antd'; import { ArrowRightOutlined, LockOutlined, UserOutlined } from '@ant-design/icons'; import { BrandMark } from '../../components/BrandMark'; import type { LedgerClient } from '../../lib/api'; import { demoLogin, login, modeLabel, setup, shopName, type SetupInput } from '../../lib/session'; import type { SessionInfo } from '../../shared'; // 登录页:与旧界面相同的三种入口——演示模式一键进入、试用空库初始化、员工下拉加密码登录。 export function LoginPage({ client, session, onLoggedIn, }: { client: LedgerClient; session: SessionInfo; onLoggedIn: () => void | Promise; }) { const [error, setError] = useState(''); const [working, setWorking] = useState(''); const name = shopName(null, session); const options = session.loginOptions || []; const intro = session.mode === 'demo' ? '用虚构订单练习完整流程,演示数据与新账隔离。' : '先设置账号。当前是本机试用,正式云端开账另行配置。'; async function run(key: string, action: () => Promise) { setError(''); setWorking(key); try { await action(); await onLoggedIn(); } catch (err) { setError((err as Error).message); } finally { setWorking(''); } } return (
{name} · 新账系统 {session.setup || session.mode === 'demo' ? intro : '录入、收款与复核,从同一张订单开始。'} {modeLabel(session.mode)}
{error && } {session.mode === 'demo' ? (
{options.map(row => ( ))}
) : session.setup ? ( run('setup', () => setup(client, input))} /> ) : ( run('login', () => login(client, member, password))} /> )}
新版界面(对照试用) 返回旧版界面

云端数据库和飞书同步的真实状态,会在系统内显示。

); } function LoginForm({ options, working, onSubmit, }: { options: { member: string; label: string }[]; working: boolean; onSubmit: (member: string, password: string) => void; }) { const [member, setMember] = useState(''); const [password, setPassword] = useState(''); const passwordRef = useRef(null); return (
{ event.preventDefault(); onSubmit(member, password); }} > 进入系统后,在设置 → 员工管理中添加员工。
); }