From 85d82bfd09ad0dce221c589fb8343b23f74bf0bd Mon Sep 17 00:00:00 2001 From: xuncha <1658671838@qq.com> Date: Tue, 27 Jan 2026 17:46:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E5=BD=93=E5=A4=A9?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E4=BC=9A=E8=AF=9D=E4=B9=9F=E4=BE=9D=E6=97=A7?= =?UTF-8?q?=E4=BC=9A=E4=BA=A7=E7=94=9F=E5=AF=BC=E5=87=BA=E6=96=87=E4=BB=B6?= =?UTF-8?q?=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/services/exportService.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/electron/services/exportService.ts b/electron/services/exportService.ts index 6f6eefe..f5e750b 100644 --- a/electron/services/exportService.ts +++ b/electron/services/exportService.ts @@ -1665,6 +1665,12 @@ class ExportService { const collected = await this.collectMessages(sessionId, cleanedMyWxid, options.dateRange) const allMessages = collected.rows + + // 如果没有消息,不创建文件 + if (allMessages.length === 0) { + return { success: false, error: '该会话在指定时间范围内没有消息' } + } + if (isGroup) { await this.mergeGroupMembers(sessionId, collected.memberSet, options.exportAvatars === true) } @@ -1858,6 +1864,12 @@ class ExportService { }) const collected = await this.collectMessages(sessionId, cleanedMyWxid, options.dateRange) + + // 如果没有消息,不创建文件 + if (collected.rows.length === 0) { + return { success: false, error: '该会话在指定时间范围内没有消息' } + } + const { exportMediaEnabled, mediaRootDir, mediaRelativePrefix } = this.getMediaLayout(outputPath, options) // ========== 阶段1:并行导出媒体文件 ========== @@ -2100,6 +2112,10 @@ class ExportService { const collected = await this.collectMessages(sessionId, cleanedMyWxid, options.dateRange) + // 如果没有消息,不创建文件 + if (collected.rows.length === 0) { + return { success: false, error: '该会话在指定时间范围内没有消息' } + } onProgress?.({ current: 30, @@ -2453,6 +2469,12 @@ class ExportService { }) const collected = await this.collectMessages(sessionId, cleanedMyWxid, options.dateRange) + + // 如果没有消息,不创建文件 + if (collected.rows.length === 0) { + return { success: false, error: '该会话在指定时间范围内没有消息' } + } + const sortedMessages = collected.rows.sort((a, b) => a.createTime - b.createTime) const { exportMediaEnabled, mediaRootDir, mediaRelativePrefix } = this.getMediaLayout(outputPath, options) @@ -2624,6 +2646,12 @@ class ExportService { }) const collected = await this.collectMessages(sessionId, cleanedMyWxid, options.dateRange) + + // 如果没有消息,不创建文件 + if (collected.rows.length === 0) { + return { success: false, error: '该会话在指定时间范围内没有消息' } + } + if (isGroup) { await this.mergeGroupMembers(sessionId, collected.memberSet, options.exportAvatars === true) }