第3项:旧界面与 React 共用对账、回收及基础业务规则

This commit is contained in:
黄健铭 committed 2026-12-05 07:43:18 -08:00
1 parent 54c05879d5
commit 389952f31c
65 files changed
+2265 -3800

No files matched your search

+2 -3
View File
@@ -1,6 +1,6 @@
import { useEffect, useState } from 'react';
import type { LedgerClient } from '../../lib/api';
import { Model, type LedgerState } from '../../shared';
import { Model, Values, type LedgerState } from '../../shared';
export interface Props {
client: LedgerClient;
@@ -161,8 +161,7 @@ export function time(value: string) {
}
export const snapshotLabel = (s: Snapshot) =>
s.source === 'automatic' ? '系统自动保存' : !s.source || s.source === 'manual' ? '店主复核' : '已保存';
export const dateValid = (s: string) =>
/^\d{4}-\d{2}-\d{2}$/.test(s) && !Number.isNaN(+new Date(s)) && new Date(s).toISOString().slice(0, 10) === s;
export const dateValid = Values.validDate;
export function useRead<T>(client: LedgerClient, url: string | null, version: number, validate?: (value: T) => void) {
const [response, setResponse] = useState<{ url: string; version: number; value?: T; error?: string }>();
useEffect(() => {