新版界面(React + TypeScript + Vite + Ant Design):登录页与开单页
共用计算经构建插件直接导入 public/ 下的 UMD 源文件;请求客户端沿用旧界面的重试、 同一操作号自动确认、恢复原操作与账号切换约定;附 vitest 单元与组件测试。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bdffbcab85
commit
ec5889075f
39 files changed
+8772
No files matched your search
@@ -0,0 +1,23 @@
|
||||
import { LedgerClient } from '../src/lib/api';
|
||||
|
||||
export function fakeClient(routes: Record<string, (body: unknown) => unknown>) {
|
||||
const calls: { url: string; method: string; body: unknown; headers: Record<string, string> }[] = [];
|
||||
const client = new LedgerClient({
|
||||
fetch: async (url, init) => {
|
||||
const body = init.body ? JSON.parse(String(init.body)) : undefined;
|
||||
calls.push({ url, method: String(init.method), body, headers: init.headers as Record<string, string> });
|
||||
const handler = routes[url.split('?')[0]];
|
||||
if (!handler) return new Response(JSON.stringify({ error: '地址不存在' }), { status: 404 });
|
||||
try {
|
||||
return new Response(JSON.stringify(handler(body)), { status: 200 });
|
||||
} catch (err) {
|
||||
return new Response(JSON.stringify({ error: (err as Error).message }), { status: 401 });
|
||||
}
|
||||
},
|
||||
storage: window.localStorage,
|
||||
setTimeout: (fn, ms) => (ms === 25000 ? 0 : setTimeout(fn, 0)),
|
||||
clearTimeout: () => {},
|
||||
randomUUID: () => 'test-operation-key-0001',
|
||||
});
|
||||
return { client, calls };
|
||||
}
|
||||
Reference in new issue
Block a user