wenliming 2 rokov pred
rodič
commit
40819fb6f1
2 zmenil súbory, kde vykonal 14 pridanie a 12 odobranie
  1. 5 12
      src/entry/background.js
  2. 9 0
      src/logic/background/twitter.js

+ 5 - 12
src/entry/background.js

@@ -11,10 +11,9 @@ import {
     setBadgeInfo,
     hideBadge,
     setMessageCount,
-    getMessageInfo,
-    readTaskAllMsg,
     discordLoginCode,
-    saveDiscordAuthWindowId
+    saveDiscordAuthWindowId,
+    onDisconnectHandler
 } from "@/logic/background/twitter";
 
 //加载bg.js 执行
@@ -22,15 +21,9 @@ setMessageCount();
 
 // 消息通讯
 chrome.runtime.onConnect.addListener(function (port) {
-    
-    if (port.name === "popup" || port.name === "popup_transactions") {
-        let msgType = port.name === "popup" ? 1 : 2;
-        port.onDisconnect.addListener(function() {
-            readTaskAllMsg({msgType},() => {
-                getMessageInfo();
-            })
-        });
-    }
+    port.onDisconnect.addListener(function() {
+        onDisconnectHandler(port);
+    });
 });
 
 chrome.runtime.onInstalled.addListener(onInstalledMethod);

+ 9 - 0
src/logic/background/twitter.js

@@ -308,3 +308,12 @@ export function readTaskAllMsg({msgType}, cb) {
         }
     });
 }
+
+export const onDisconnectHandler = (port) => {
+    if (port.name === "popup" || port.name === "popup_transactions") {
+        let msgType = port.name === "popup" ? 1 : 2;
+        readTaskAllMsg({msgType},() => {
+            getMessageInfo();
+        })
+    }
+}