From c75337b8cbc8bdbcc134240063af9581564bb998 Mon Sep 17 00:00:00 2001
From: linyuchen <lin.yu.chen@foxmail.com>
Date: Wed, 13 Mar 2024 01:40:44 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BC=80=E5=90=AF=E7=8B=AC=E7=AB=8B?=
 =?UTF-8?q?=E7=AA=97=E5=8F=A3=E5=90=8E=E9=87=8D=E5=A4=8D=E4=B8=8A=E6=8A=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/main/main.ts | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/main/main.ts b/src/main/main.ts
index 1102a17..27442c6 100644
--- a/src/main/main.ts
+++ b/src/main/main.ts
@@ -151,9 +151,19 @@ function onLoad() {
         log(arg);
     })
 
+    let postedMsgIds: Record<string, any> = {}
     async function postReceiveMsg(msgList: RawMessage[]) {
         const {debug, reportSelfMessage} = getConfigUtil().getConfig();
         for (let message of msgList) {
+            if (postedMsgIds[message.msgId]) { // 如果QQ开启了独立窗口,会导致消息重复上报,这里加个记录避免重复上报
+                continue
+            }
+            postedMsgIds[message.msgId] = true
+            // 超过容量清空
+            if (Object.keys(postedMsgIds).length > 10000) {
+                postedMsgIds = {}
+            }
+
             // log("收到新消息", message.msgId, message.msgSeq)
             // if (message.senderUin !== selfInfo.uin){
                 message.msgShortId = await dbUtil.addMsg(message);