浏览代码

[bug] msg read

wenliming 2 年之前
父节点
当前提交
d1f0067b53
共有 3 个文件被更改,包括 7 次插入4 次删除
  1. 4 2
      src/entry/background.js
  2. 2 2
      src/logic/background/twitter.js
  3. 1 0
      src/view/components/popup-transactions.vue

+ 4 - 2
src/entry/background.js

@@ -22,9 +22,11 @@ setMessageCount();
 
 // 消息通讯
 chrome.runtime.onConnect.addListener(function (port) {
-    if (port.name === "popup") {
+    
+    if (port.name === "popup" || port.name === "popup_transactions") {
+        let msgType = port.name === "popup" ? 1 : 2;
         port.onDisconnect.addListener(function() {
-            readTaskAllMsg(() => {
+            readTaskAllMsg({msgType},() => {
                 getMessageInfo();
             })
         });

+ 2 - 2
src/logic/background/twitter.js

@@ -299,9 +299,9 @@ export  function getMessageInfo () {
     })
 }
 
-export function readTaskAllMsg(cb) {
+export function readTaskAllMsg({msgType}, cb) {
     fetchReadTaskAllMsg({
-        msgType: 1 // 1:任务红包 2:钱包明细
+        msgType // 1:任务红包 2:钱包明细
     }).then(res => {
         if(res.code == 0) {
             cb && cb();

+ 1 - 0
src/view/components/popup-transactions.vue

@@ -190,6 +190,7 @@ const getTransactionsList = () => {
 };
 
 onMounted(() => {
+    chrome.runtime.connect({ name: "popup_transactions" });
     readAllMsgByType({
         params: {
             msgType: 1