From ef97202867972d3468907a3d377fe5888b54dfd3 Mon Sep 17 00:00:00 2001
From: cc <98377878+hicccc77@users.noreply.github.com>
Date: Sun, 15 Mar 2026 20:28:46 +0800
Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E4=BA=9B=E6=9B=B4=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/pages/ChatPage.scss | 7 ++--
src/pages/ChatPage.tsx | 74 ++++++++++++++++++++++-------------------
src/types/electron.d.ts | 1 +
3 files changed, 44 insertions(+), 38 deletions(-)
diff --git a/src/pages/ChatPage.scss b/src/pages/ChatPage.scss
index 1025d7c..e810bd5 100644
--- a/src/pages/ChatPage.scss
+++ b/src/pages/ChatPage.scss
@@ -3045,13 +3045,15 @@
}
.member-flag {
- width: 18px;
height: 18px;
+ padding: 0 6px;
border-radius: 9999px;
display: inline-flex;
align-items: center;
justify-content: center;
border: 1px solid var(--border-color);
+ font-size: 11px;
+ white-space: nowrap;
&.owner {
color: #f59e0b;
@@ -4702,10 +4704,9 @@
// 全局消息搜索结果面板
.global-msg-search-results {
- max-height: 320px;
+ flex: 1;
overflow-y: auto;
background: var(--bg-primary);
- border-top: 1px solid var(--border-color);
.global-msg-searching,
.global-msg-empty {
diff --git a/src/pages/ChatPage.tsx b/src/pages/ChatPage.tsx
index 4306e7c..6b8697f 100644
--- a/src/pages/ChatPage.tsx
+++ b/src/pages/ChatPage.tsx
@@ -2691,6 +2691,7 @@ function ChatPage(props: ChatPageProps) {
setGlobalMsgResults([])
} finally {
if (gen === globalMsgSearchGenRef.current) setGlobalMsgSearching(false)
+ setGlobalMsgSearching(false)
}
}, 500)
}, [])
@@ -2702,6 +2703,7 @@ function ChatPage(props: ChatPageProps) {
setGlobalMsgQuery('')
setGlobalMsgResults([])
setGlobalMsgSearching(false)
+ if (globalMsgSearchTimerRef.current) clearTimeout(globalMsgSearchTimerRef.current)
}, [])
// 滚动加载更多 + 显示/隐藏回到底部按钮(优化:节流,避免频繁执行)
@@ -4003,44 +4005,11 @@ function ChatPage(props: ChatPageProps) {
)}
- {globalMsgSearching && }
- {/* 全局消息搜索结果面板 */}
- {showGlobalMsgSearch && (
-
- {globalMsgSearching && (
-
搜索中...
- )}
- {!globalMsgSearching && globalMsgQuery && globalMsgResults.length === 0 && (
-
没有找到相关消息
- )}
- {globalMsgResults.map((msg, i) => {
- const sid = msg._session_id || msg.username || ''
- const sessionObj = sessions.find(s => s.username === sid)
- const sessionName = sessionObj?.displayName || sid || '未知会话'
- const content = (msg.content || msg.strContent || msg.message_content || '').slice(0, 60)
- const ts = msg.createTime || msg.create_time
- const timeStr = ts ? new Date(ts * 1000).toLocaleString('zh-CN', { month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' }) : ''
- return (
-
{
- if (sessionObj) {
- handleSelectSession(sessionObj)
- handleCloseGlobalMsgSearch()
- setSearchKeyword('')
- }
- }}>
-
{sessionName}
-
{content}
-
{timeStr}
-
- )
- })}
-
- )}
{/* 折叠群 header */}
@@ -4079,6 +4048,39 @@ function ChatPage(props: ChatPageProps) {
) : (
+ {/* 全局消息搜索结果 */}
+ {showGlobalMsgSearch ? (
+
+ {globalMsgSearching && (
+
搜索中...
+ )}
+ {!globalMsgSearching && globalMsgQuery && globalMsgResults.length === 0 && (
+
没有找到相关消息
+ )}
+ {!globalMsgSearching && globalMsgResults.map((msg, i) => {
+ const sid = msg._session_id || msg.username || ''
+ const sessionObj = sessions.find(s => s.username === sid)
+ const sessionName = sessionObj?.displayName || sid || '未知会话'
+ const content = (msg.content || msg.strContent || msg.message_content || '').slice(0, 60)
+ const ts = msg.createTime || msg.create_time
+ const timeStr = ts ? new Date(ts * 1000).toLocaleString('zh-CN', { month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' }) : ''
+ return (
+
{
+ if (sessionObj) {
+ handleSelectSession(sessionObj)
+ handleCloseGlobalMsgSearch()
+ setSearchKeyword('')
+ }
+ }}>
+
{sessionName}
+
{content}
+
{timeStr}
+
+ )
+ })}
+
+ ) : (
+ <>
{/* 普通会话列表 */}
{Array.isArray(filteredSessions) && filteredSessions.length > 0 ? (
@@ -4136,6 +4138,8 @@ function ChatPage(props: ChatPageProps) {
)}
+ >
+ )}
)}
@@ -4515,12 +4519,12 @@ function ChatPage(props: ChatPageProps) {
{member.isOwner && (
-
+ 群主
)}
{member.isFriend && (
-
+ 好友
)}
diff --git a/src/types/electron.d.ts b/src/types/electron.d.ts
index 4875413..7bfd316 100644
--- a/src/types/electron.d.ts
+++ b/src/types/electron.d.ts
@@ -221,6 +221,7 @@ export interface ElectronAPI {
}>
getMyAvatarUrl: () => Promise<{ success: boolean; avatarUrl?: string; error?: string }>
downloadEmoji: (cdnUrl: string, md5?: string) => Promise<{ success: boolean; localPath?: string; error?: string }>
+ searchMessages: (keyword: string, sessionId?: string, limit?: number, offset?: number, beginTimestamp?: number, endTimestamp?: number) => Promise<{ success: boolean; messages?: Message[]; error?: string }>
close: () => Promise
getSessionDetail: (sessionId: string) => Promise<{
success: boolean