From 1f676254a92d8855c3b91994cd4d701513644fe7 Mon Sep 17 00:00:00 2001 From: cc <98377878+hicccc77@users.noreply.github.com> Date: Sun, 15 Mar 2026 23:32:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E4=B8=AA=E7=95=A5=E6=9C=89=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E7=9A=84=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/ChatPage.tsx | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/src/pages/ChatPage.tsx b/src/pages/ChatPage.tsx index 12215e8..eaad286 100644 --- a/src/pages/ChatPage.tsx +++ b/src/pages/ChatPage.tsx @@ -2831,28 +2831,22 @@ function ChatPage(props: ChatPageProps) { if (gen !== inSessionSearchGenRef.current) return const messages = res?.messages || [] - // 查询完整消息信息 + // 补充联系人信息 const enriched = await Promise.all( messages.map(async (msg: any) => { - try { - const full = await window.electronAPI.chat.getMessages(sid, 0, 3, msg.createTime, msg.createTime, false) - const found: any = full?.messages?.find((m: any) => m.localId === msg.localId) - if (found && found.senderUsername) { - try { - const contact = await window.electronAPI.chat.getContact(found.senderUsername) - if (contact) { - found.senderDisplayName = contact.remark || contact.nickName || found.senderUsername - } - const avatarData = await window.electronAPI.chat.getContactAvatar(found.senderUsername) - if (avatarData?.avatarUrl) { - found.senderAvatarUrl = avatarData.avatarUrl - } - } catch {} - } - return found || msg - } catch { - return msg + if (msg.senderUsername) { + try { + const contact = await window.electronAPI.chat.getContact(msg.senderUsername) + if (contact) { + msg.senderDisplayName = contact.remark || contact.nickName || msg.senderUsername + } + const avatarData = await window.electronAPI.chat.getContactAvatar(msg.senderUsername) + if (avatarData?.avatarUrl) { + msg.senderAvatarUrl = avatarData.avatarUrl + } + } catch {} } + return msg }) )