feat(client): track digital sync retry history

This commit is contained in:
baiyanyun
2026-06-07 01:42:39 +08:00
parent 646901b5fa
commit cef3fe4a43
10 changed files with 375 additions and 133 deletions

View File

@@ -64,6 +64,15 @@ interface ManagementSyncStatus {
recentFailures?: ManagementSyncFailure[];
}
interface ManagementSyncAttempt {
attemptNo: number;
status: string;
error: string | null;
endpoint?: string | null;
startedAt: string;
finishedAt: string;
}
interface ManagementSyncFailure {
id: string;
entityType: string;
@@ -74,6 +83,7 @@ interface ManagementSyncFailure {
nextRetryAt?: string | null;
dueForRetry?: boolean;
managementRecordUrl?: string | null;
attemptHistory?: ManagementSyncAttempt[];
error: string | null;
createdAt: string;
updatedAt: string;
@@ -495,6 +505,18 @@ function syncFailureRetryTime(failure: ManagementSyncFailure): string {
return formatBeijingDateTime(failure.nextRetryAt) || '待计算';
}
function syncAttemptStatusLabel(status: string): string {
if (status === 'synced') return '已同步';
if (status === 'failed') return '失败';
return status || '未知';
}
function syncAttemptTone(status: string): 'success' | 'danger' | 'info' {
if (status === 'synced') return 'success';
if (status === 'failed') return 'danger';
return 'info';
}
async function readManagementSyncStatus(): Promise<ManagementSyncStatus | null> {
const bridge = window.QimingClawBridge?.digital;
if (!bridge?.getSyncStatus) return null;
@@ -1837,6 +1859,31 @@ export default function CommandDeck({ onNavigate }: { onNavigate: (target: Digit
<span></span>
<p>{selectedSyncFailure.error || '暂无错误详情。'}</p>
</div>
{(selectedSyncFailure.attemptHistory?.length ?? 0) > 0 && (
<div className="de-sync-attempt-history">
<span></span>
<div className="de-sync-attempt-list">
{selectedSyncFailure.attemptHistory?.map((attempt) => (
<div
key={`${attempt.attemptNo}-${attempt.finishedAt}`}
className={`de-sync-attempt-row de-sync-attempt-row--${syncAttemptTone(
attempt.status,
)}`}
>
<div>
<strong> {attempt.attemptNo} </strong>
<em>{syncAttemptStatusLabel(attempt.status)}</em>
<span>
{formatBeijingDateTime(attempt.finishedAt) ||
attempt.finishedAt}
</span>
</div>
{attempt.error && <small>{attempt.error}</small>}
</div>
))}
</div>
</div>
)}
<div className="de-event-modal-actions">
<button
type="button"