Merge pull request #281 from hicccc77/dev

Dev
This commit is contained in:
xuncha
2026-02-19 18:44:39 +08:00
committed by GitHub

View File

@@ -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>