新版界面(React + TypeScript + Vite + Ant Design):登录页与开单页

共用计算经构建插件直接导入 public/ 下的 UMD 源文件;请求客户端沿用旧界面的重试、
同一操作号自动确认、恢复原操作与账号切换约定;附 vitest 单元与组件测试。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
黄健铭andClaude Opus 5.5 committed 2026-12-04 18:58:31 -08:00
1 parent bdffbcab85
commit ec5889075f
39 files changed
+8772

No files matched your search

@@ -0,0 +1,10 @@
import { Alert } from 'antd';
import type { LedgerClient } from '../lib/api';
import { useClientSnapshot } from '../lib/useClient';
// 与旧界面 #request-status 相同:显示“正在保存”“正在自动确认(1/2)”等进度。
export function RequestStatus({ client }: { client: LedgerClient }) {
useClientSnapshot(client);
if (!client.progressText) return null;
return <Alert className="request-status" type="info" showIcon role="status" message={client.progressText} />;
}
@@ -0,0 +1,64 @@
import { useState } from 'react';
import { App as AntApp, Button, Tag } from 'antd';
import type { LedgerClient } from '../lib/api';
import { logout, shopName } from '../lib/session';
import { modeLabel } from '../lib/format';
import { useClientSnapshot } from '../lib/useClient';
import type { LedgerState, SessionInfo } from '../shared';
export function TopBar({
client,
state,
session,
onLoggedOut,
}: {
client: LedgerClient;
state: LedgerState;
session: SessionInfo;
onLoggedOut: () => void;
}) {
const { message } = AntApp.useApp();
const [leaving, setLeaving] = useState(false);
useClientSnapshot(client);
const name = shopName(state, session);
return (
<header className="topbar">
<div className="topbar-brand">
<span className="brand-mark" aria-hidden="true">
{Array.from(name)[0] || '店'}
</span>
<div>
<strong data-testid="store-name">{name}</strong>
<small>新版界面 · 开单</small>
</div>
</div>
<div className="topbar-right">
<Tag className="mode-tag">{modeLabel(state.mode)}</Tag>
<span className="identity" data-testid="identity">
{state.user.label || state.user.name}
</span>
<a className="old-ui-link" href="/">
返回旧版界面
</a>
<Button
size="small"
loading={leaving}
disabled={client.busy}
onClick={async () => {
setLeaving(true);
try {
await logout(client);
onLoggedOut();
} catch (err) {
message.error((err as Error).message);
} finally {
setLeaving(false);
}
}}
>
退出
</Button>
</div>
</header>
);
}