diff --git a/src/pages/ExportPage.tsx b/src/pages/ExportPage.tsx index b420505..2211143 100644 --- a/src/pages/ExportPage.tsx +++ b/src/pages/ExportPage.tsx @@ -66,6 +66,7 @@ function ExportPage() { const [elapsedSeconds, setElapsedSeconds] = useState(0) const displayNameDropdownRef = useRef(null) const preselectAppliedRef = useRef(false) + const statsRequestIdRef = useRef(0) const preselectSessionIds = useMemo(() => { const state = location.state as { preselectSessionIds?: unknown; preselectSessionId?: unknown } | null @@ -382,7 +383,9 @@ function ExportPage() { if (selectedSessions.size === 0 || !exportFolder) return // 先获取预估统计 + const requestId = ++statsRequestIdRef.current setIsLoadingStats(true) + setPreExportStats(null) setShowPreExportDialog(true) try { const sessionList = Array.from(selectedSessions) @@ -400,16 +403,21 @@ function ExportPage() { } : null } const stats = await window.electronAPI.export.getExportStats(sessionList, exportOptions) + if (statsRequestIdRef.current !== requestId) return setPreExportStats(stats) } catch (e) { console.error('获取导出统计失败:', e) + if (statsRequestIdRef.current !== requestId) return setPreExportStats(null) } finally { + if (statsRequestIdRef.current !== requestId) return setIsLoadingStats(false) } } const confirmExport = () => { + statsRequestIdRef.current++ + setIsLoadingStats(false) setShowPreExportDialog(false) setPreExportStats(null) @@ -911,7 +919,7 @@ function ExportPage() { {isLoadingStats ? (
- 正在统计消息... + 正在统计消息,可直接点击“直接导出”跳过等待
) : preExportStats ? (
@@ -957,11 +965,11 @@ function ExportPage() {

统计信息获取失败,仍可继续导出

)}
- -