From d5f0094025bebd5bcba89e3d7eae4d6e7a31ed18 Mon Sep 17 00:00:00 2001 From: xuncha <1658671838@qq.com> Date: Thu, 19 Feb 2026 16:47:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=BD=AC=E8=B4=A6=E7=B1=BB?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electron/services/exportService.ts | 55 +++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/electron/services/exportService.ts b/electron/services/exportService.ts index ab0eb67..3db210d 100644 --- a/electron/services/exportService.ts +++ b/electron/services/exportService.ts @@ -534,11 +534,14 @@ class ExportService { groupNicknamesMap: Map, getContactName: (username: string) => Promise ): Promise { - const xmlType = this.extractXmlValue(content, 'type') - if (xmlType !== '2000') return null + const normalizedContent = this.normalizeAppMessageContent(content || '') + if (!normalizedContent) return null - const payerUsername = this.extractXmlValue(content, 'payer_username') - const receiverUsername = this.extractXmlValue(content, 'receiver_username') + const xmlType = this.extractXmlValue(normalizedContent, 'type') + if (xmlType && xmlType !== '2000') return null + + const payerUsername = this.extractXmlValue(normalizedContent, 'payer_username') + const receiverUsername = this.extractXmlValue(normalizedContent, 'receiver_username') if (!payerUsername || !receiverUsername) return null const cleanedMyWxid = myWxid ? this.cleanAccountDirName(myWxid) : '' @@ -3955,6 +3958,15 @@ class ExportService { const isGroup = sessionId.includes('@chatroom') const sessionInfo = await this.getContactInfo(sessionId) const myInfo = await this.getContactInfo(cleanedMyWxid) + const contactCache = new Map() + const getContactCached = async (username: string) => { + if (contactCache.has(username)) { + return contactCache.get(username)! + } + const result = await wcdbService.getContact(username) + contactCache.set(username, result) + return result + } onProgress?.({ current: 0, @@ -3974,6 +3986,24 @@ class ExportService { return { success: false, error: '该会话在指定时间范围内没有消息' } } + const senderUsernames = new Set() + for (const msg of collected.rows) { + if (msg.senderUsername) senderUsernames.add(msg.senderUsername) + } + senderUsernames.add(sessionId) + await this.preloadContacts(senderUsernames, contactCache) + + const groupNicknameCandidates = isGroup + ? this.buildGroupNicknameIdCandidates([ + ...Array.from(senderUsernames.values()), + ...collected.rows.map(msg => msg.senderUsername), + cleanedMyWxid + ]) + : [] + const groupNicknamesMap = isGroup + ? await this.getGroupNicknamesForRoom(sessionId, groupNicknameCandidates) + : new Map() + if (isGroup) { await this.mergeGroupMembers(sessionId, collected.memberSet, options.exportAvatars === true) } @@ -4186,6 +4216,23 @@ class ExportService { if (mediaItem && (msg.localType === 3 || msg.localType === 47)) { textContent = '' } + if (textContent.startsWith('[转账]') && msg.content) { + const transferDesc = await this.resolveTransferDesc( + msg.content, + cleanedMyWxid, + groupNicknamesMap, + async (username) => { + const c = await getContactCached(username) + if (c.success && c.contact) { + return c.contact.remark || c.contact.nickName || c.contact.alias || username + } + return username + } + ) + if (transferDesc) { + textContent = textContent.replace('[转账]', `[转账] (${transferDesc})`) + } + } let mediaHtml = '' if (mediaItem?.kind === 'image') {