mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-03-24 23:06:51 +00:00
@@ -66,6 +66,7 @@ function ExportPage() {
|
|||||||
const [elapsedSeconds, setElapsedSeconds] = useState(0)
|
const [elapsedSeconds, setElapsedSeconds] = useState(0)
|
||||||
const displayNameDropdownRef = useRef<HTMLDivElement>(null)
|
const displayNameDropdownRef = useRef<HTMLDivElement>(null)
|
||||||
const preselectAppliedRef = useRef(false)
|
const preselectAppliedRef = useRef(false)
|
||||||
|
const statsRequestIdRef = useRef(0)
|
||||||
|
|
||||||
const preselectSessionIds = useMemo(() => {
|
const preselectSessionIds = useMemo(() => {
|
||||||
const state = location.state as { preselectSessionIds?: unknown; preselectSessionId?: unknown } | null
|
const state = location.state as { preselectSessionIds?: unknown; preselectSessionId?: unknown } | null
|
||||||
@@ -382,7 +383,9 @@ function ExportPage() {
|
|||||||
if (selectedSessions.size === 0 || !exportFolder) return
|
if (selectedSessions.size === 0 || !exportFolder) return
|
||||||
|
|
||||||
// 先获取预估统计
|
// 先获取预估统计
|
||||||
|
const requestId = ++statsRequestIdRef.current
|
||||||
setIsLoadingStats(true)
|
setIsLoadingStats(true)
|
||||||
|
setPreExportStats(null)
|
||||||
setShowPreExportDialog(true)
|
setShowPreExportDialog(true)
|
||||||
try {
|
try {
|
||||||
const sessionList = Array.from(selectedSessions)
|
const sessionList = Array.from(selectedSessions)
|
||||||
@@ -400,16 +403,21 @@ function ExportPage() {
|
|||||||
} : null
|
} : null
|
||||||
}
|
}
|
||||||
const stats = await window.electronAPI.export.getExportStats(sessionList, exportOptions)
|
const stats = await window.electronAPI.export.getExportStats(sessionList, exportOptions)
|
||||||
|
if (statsRequestIdRef.current !== requestId) return
|
||||||
setPreExportStats(stats)
|
setPreExportStats(stats)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('获取导出统计失败:', e)
|
console.error('获取导出统计失败:', e)
|
||||||
|
if (statsRequestIdRef.current !== requestId) return
|
||||||
setPreExportStats(null)
|
setPreExportStats(null)
|
||||||
} finally {
|
} finally {
|
||||||
|
if (statsRequestIdRef.current !== requestId) return
|
||||||
setIsLoadingStats(false)
|
setIsLoadingStats(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const confirmExport = () => {
|
const confirmExport = () => {
|
||||||
|
statsRequestIdRef.current++
|
||||||
|
setIsLoadingStats(false)
|
||||||
setShowPreExportDialog(false)
|
setShowPreExportDialog(false)
|
||||||
setPreExportStats(null)
|
setPreExportStats(null)
|
||||||
|
|
||||||
@@ -911,7 +919,7 @@ function ExportPage() {
|
|||||||
{isLoadingStats ? (
|
{isLoadingStats ? (
|
||||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8, padding: '24px 0', justifyContent: 'center' }}>
|
<div style={{ display: 'flex', alignItems: 'center', gap: 8, padding: '24px 0', justifyContent: 'center' }}>
|
||||||
<Loader2 size={20} className="spin" />
|
<Loader2 size={20} className="spin" />
|
||||||
<span style={{ fontSize: 14, color: 'var(--text-secondary)' }}>正在统计消息...</span>
|
<span style={{ fontSize: 14, color: 'var(--text-secondary)' }}>正在统计消息,可直接点击“直接导出”跳过等待</span>
|
||||||
</div>
|
</div>
|
||||||
) : preExportStats ? (
|
) : preExportStats ? (
|
||||||
<div style={{ padding: '12px 0' }}>
|
<div style={{ padding: '12px 0' }}>
|
||||||
@@ -957,11 +965,11 @@ function ExportPage() {
|
|||||||
<p style={{ fontSize: 14, color: 'var(--text-secondary)', padding: '16px 0' }}>统计信息获取失败,仍可继续导出</p>
|
<p style={{ fontSize: 14, color: 'var(--text-secondary)', padding: '16px 0' }}>统计信息获取失败,仍可继续导出</p>
|
||||||
)}
|
)}
|
||||||
<div className="layout-actions" style={{ display: 'flex', gap: 8, justifyContent: 'flex-end', marginTop: 8 }}>
|
<div className="layout-actions" style={{ display: 'flex', gap: 8, justifyContent: 'flex-end', marginTop: 8 }}>
|
||||||
<button className="layout-cancel-btn" onClick={() => { setShowPreExportDialog(false); setPreExportStats(null) }}>
|
<button className="layout-cancel-btn" onClick={() => { statsRequestIdRef.current++; setIsLoadingStats(false); setShowPreExportDialog(false); setPreExportStats(null) }}>
|
||||||
取消
|
取消
|
||||||
</button>
|
</button>
|
||||||
<button className="layout-option-btn primary" onClick={confirmExport} disabled={isLoadingStats}>
|
<button className="layout-option-btn primary" onClick={confirmExport}>
|
||||||
<span className="layout-title">开始导出</span>
|
<span className="layout-title">{isLoadingStats ? '直接导出' : '开始导出'}</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user