feat(client): track digital sync retry history
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user