From 38a0453cbbf00a0a7cdcef66eb7ce623f2246d19 Mon Sep 17 00:00:00 2001 From: aits2026 Date: Fri, 6 Mar 2026 12:01:21 +0800 Subject: [PATCH] fix(export): restore loading states for session metrics --- src/pages/ExportPage.tsx | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/pages/ExportPage.tsx b/src/pages/ExportPage.tsx index b26f4af..0cc85ec 100644 --- a/src/pages/ExportPage.tsx +++ b/src/pages/ExportPage.tsx @@ -5236,6 +5236,7 @@ function ExportPage() { const renderContactRow = useCallback((_: number, contact: ContactInfo) => { const matchedSession = sessionRowByUsername.get(contact.username) const canExport = Boolean(matchedSession?.hasSession) + const isSessionBindingPending = !matchedSession && (isLoading || isSessionEnriching) const checked = canExport && selectedSessions.has(contact.username) const isRunning = canExport && runningSessionIds.has(contact.username) const isQueued = canExport && queuedSessionIds.has(contact.username) @@ -5246,14 +5247,17 @@ function ExportPage() { const hintedMessages = normalizeMessageCount(matchedSession?.messageCountHint) const displayedMessageCount = countedMessages ?? hintedMessages const mediaMetric = sessionContentMetrics[contact.username] - const messageCountLabel = !canExport - ? '--' - : typeof displayedMessageCount === 'number' - ? displayedMessageCount.toLocaleString('zh-CN') - : '获取中' + const messageCountState: { state: 'value'; text: string } | { state: 'loading' } | { state: 'na'; text: '--' } = + !canExport + ? (isSessionBindingPending ? { state: 'loading' } : { state: 'na', text: '--' }) + : typeof displayedMessageCount === 'number' + ? { state: 'value', text: displayedMessageCount.toLocaleString('zh-CN') } + : { state: 'loading' } const metricToDisplay = (value: unknown): { state: 'value'; text: string } | { state: 'loading' } | { state: 'na'; text: '--' } => { const normalized = normalizeMessageCount(value) - if (!canExport) return { state: 'na', text: '--' } + if (!canExport) { + return isSessionBindingPending ? { state: 'loading' } : { state: 'na', text: '--' } + } if (typeof normalized === 'number') { return { state: 'value', text: normalized.toLocaleString('zh-CN') } } @@ -5310,8 +5314,10 @@ function ExportPage() {
- - {messageCountLabel} + + {messageCountState.state === 'loading' + ? + : messageCountState.text}
{canExport && ( @@ -5424,6 +5430,8 @@ function ExportPage() { sessionLoadTraceMap, sessionMessageCounts, sessionRowByUsername, + isLoading, + isSessionEnriching, showSessionDetailPanel, shouldShowSnsColumn, snsUserPostCounts,