From 21d785dd3cf99bd781666de08b30c40841c330ec Mon Sep 17 00:00:00 2001 From: xuncha <1658671838@qq.com> Date: Wed, 21 Jan 2026 19:08:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E4=BA=86=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E6=97=B6=E5=9B=A0=E4=B8=BA=E5=A4=B4=E5=83=8F=E5=9C=A8?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E5=8A=A0=E8=BD=BD=E5=AF=BC=E8=87=B4=E7=9A=84?= =?UTF-8?q?=E4=B8=8D=E5=AF=BC=E5=87=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electron/main.ts | 11 ++++++++--- electron/preload.ts | 6 +++++- src/pages/ExportPage.tsx | 13 +++++++++++++ src/types/electron.d.ts | 8 ++++++++ 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/electron/main.ts b/electron/main.ts index a04dc4c..9747a28 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -13,7 +13,7 @@ import { imagePreloadService } from './services/imagePreloadService' import { analyticsService } from './services/analyticsService' import { groupAnalyticsService } from './services/groupAnalyticsService' import { annualReportService } from './services/annualReportService' -import { exportService, ExportOptions } from './services/exportService' +import { exportService, ExportOptions, ExportProgress } from './services/exportService' import { KeyService } from './services/keyService' import { voiceTranscribeService } from './services/voiceTranscribeService' import { videoService } from './services/videoService' @@ -646,8 +646,13 @@ function registerIpcHandlers() { }) // 导出相关 - ipcMain.handle('export:exportSessions', async (_, sessionIds: string[], outputDir: string, options: ExportOptions) => { - return exportService.exportSessions(sessionIds, outputDir, options) + ipcMain.handle('export:exportSessions', async (event, sessionIds: string[], outputDir: string, options: ExportOptions) => { + const onProgress = (progress: ExportProgress) => { + if (!event.sender.isDestroyed()) { + event.sender.send('export:progress', progress) + } + } + return exportService.exportSessions(sessionIds, outputDir, options, onProgress) }) ipcMain.handle('export:exportSession', async (_, sessionId: string, outputPath: string, options: ExportOptions) => { diff --git a/electron/preload.ts b/electron/preload.ts index f04e6f4..e70b70b 100644 --- a/electron/preload.ts +++ b/electron/preload.ts @@ -191,7 +191,11 @@ contextBridge.exposeInMainWorld('electronAPI', { exportSessions: (sessionIds: string[], outputDir: string, options: any) => ipcRenderer.invoke('export:exportSessions', sessionIds, outputDir, options), exportSession: (sessionId: string, outputPath: string, options: any) => - ipcRenderer.invoke('export:exportSession', sessionId, outputPath, options) + ipcRenderer.invoke('export:exportSession', sessionId, outputPath, options), + onProgress: (callback: (payload: { current: number; total: number; currentSession: string; phase: string }) => void) => { + ipcRenderer.on('export:progress', (_, payload) => callback(payload)) + return () => ipcRenderer.removeAllListeners('export:progress') + } }, whisper: { diff --git a/src/pages/ExportPage.tsx b/src/pages/ExportPage.tsx index 19d8605..ef0e68e 100644 --- a/src/pages/ExportPage.tsx +++ b/src/pages/ExportPage.tsx @@ -154,6 +154,19 @@ function ExportPage() { loadExportDefaults() }, [loadSessions, loadExportPath, loadExportDefaults]) + useEffect(() => { + const removeListener = window.electronAPI.export.onProgress?.((payload) => { + setExportProgress({ + current: payload.current, + total: payload.total, + currentName: payload.currentSession + }) + }) + return () => { + removeListener?.() + } + }, []) + useEffect(() => { if (!searchKeyword.trim()) { setFilteredSessions(sessions) diff --git a/src/types/electron.d.ts b/src/types/electron.d.ts index bacefb3..45d134d 100644 --- a/src/types/electron.d.ts +++ b/src/types/electron.d.ts @@ -314,6 +314,7 @@ export interface ElectronAPI { success: boolean error?: string }> + onProgress: (callback: (payload: ExportProgress) => void) => () => void } whisper: { downloadModel: () => Promise<{ success: boolean; modelPath?: string; tokensPath?: string; error?: string }> @@ -334,6 +335,13 @@ export interface ExportOptions { excelCompactColumns?: boolean } +export interface ExportProgress { + current: number + total: number + currentSession: string + phase: 'preparing' | 'exporting' | 'writing' | 'complete' +} + export interface WxidInfo { wxid: string modifiedTime: number