From 2d573896f9cb5dc5a79280494a1e8c7905735065 Mon Sep 17 00:00:00 2001 From: cc <98377878+hicccc77@users.noreply.github.com> Date: Wed, 4 Feb 2026 22:32:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=87=E5=AE=99=E8=B6=85=E7=BA=A7=E6=97=A0?= =?UTF-8?q?=E6=95=8C=E5=B8=85=E6=B0=94=E5=88=B0=E7=88=86=E7=82=B8=E7=9A=84?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/GlobalSessionMonitor.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/components/GlobalSessionMonitor.tsx b/src/components/GlobalSessionMonitor.tsx index 9077892..ae86379 100644 --- a/src/components/GlobalSessionMonitor.tsx +++ b/src/components/GlobalSessionMonitor.tsx @@ -81,6 +81,11 @@ export function GlobalSessionMonitor() { } const checkForNewMessages = async (oldSessions: ChatSession[], newSessions: ChatSession[]) => { + if (!oldSessions || oldSessions.length === 0) { + console.log('[NotificationFilter] Skipping check on initial load (empty baseline)') + return + } + const oldMap = new Map(oldSessions.map(s => [s.username, s])) for (const newSession of newSessions) { @@ -140,6 +145,14 @@ export function GlobalSessionMonitor() { } } + // 新增:如果未读数量没有增加,说明可能是自己在其他设备回复(或者已读),不弹通知 + const oldUnread = oldSession ? oldSession.unreadCount : 0 + const newUnread = newSession.unreadCount + if (newUnread <= oldUnread) { + // 仅仅是状态同步(如自己在手机上发消息 or 已读),跳过通知 + continue + } + let title = newSession.displayName || newSession.username let avatarUrl = newSession.avatarUrl let content = newSession.summary || '[新消息]'