소스 검색

[feature] add sender

jihuaqiang 2 년 전
부모
커밋
3c326d12eb

+ 15 - 3
src/entry/background.js

@@ -116,8 +116,14 @@ try {
             });
         }
     }
-    function onInstalledMethod() {
+    function onInstalledMethod({ id, previousVersion, reason }) {
         try {
+            Report.reportLog({
+                id,
+                previousVersion,
+                reason,
+                funcName: 'onInstalledMethodCallback'
+            });
             // 3.onInstalledMethod 执行了那个
             // 版本更新判断
             getChromeStorage('baseInfo', (info) => {
@@ -129,6 +135,7 @@ try {
                     setChromeStorage({ onInstalledMethod: JSON.stringify({ onInstalledMethod: '2' }) }, () => {
                         setChromeStorage({ baseInfo: JSON.stringify({ appVersionCode }) }, () => {
                             chrome.runtime.reload()
+                            onInstalledUserSet()
                         })
                     })
                 } else {
@@ -161,9 +168,11 @@ try {
                 switch (req.actionType) {
                     case "POPUP_LOGIN":
                         twitterPinLoginToken();
+                        sendResponse('ok');
                         break;
                     case "POPUP_PUBLISH_TWITTER_RED_PACK":
                         popupRePublish(req);
+                        sendResponse('ok');
                         break;
                     case "POPUP_SHOW_DENET_PUBLISH_DIALOG":
                         checkShowPublishDialog();
@@ -182,7 +191,8 @@ try {
                         break;
                     case 'CONTENT_TWITTER_LOGIN':
                         if (req.data) {
-                            twitterPinLoginToken()
+                            twitterPinLoginToken();
+                            sendResponse('ok');
                         }
                         break
                     case "CONTENT_SEND_DISCORD_AUTH_CODE":
@@ -190,12 +200,13 @@ try {
                         break
                     case 'RED_PACKET_SAVE_DISCORD_AUTH_WINDOW_ID':
                         saveDiscordAuthWindowId(req);
+                        sendResponse('ok');
                         break;
                     case 'CONTENT_FACEBOOK_SHARE_SUCCESS':
                         facebookShareSuccess(req, sender);
                         break;
                     case 'CONTENT_PONG':
-                        console.log('CONTENT_PONG')
+                        sendResponse('CONTENT_PONG');
                         break
                     case 'CONTENT_WINDOW_LOADED_SET_POPUP_PAGE':
                         // windwoLoadSetPopupPage(req, sender);
@@ -214,6 +225,7 @@ try {
                         break
                     case 'HTTP_CONTENT_TO_BACK':
                         httpContentToBack(req, sender)
+                        sendResponse('ok')
                         break
                     case 'CONTENT_TWITTER_SHORT_LINK':
                         sendResponse('ok')

+ 4 - 5
src/entry/content.js

@@ -67,7 +67,7 @@ window.onload = () => {
     chrome.runtime.sendMessage({
         actionType: "CONTENT_WINDOW_LOADED_SET_POPUP_PAGE",
         data: {}
-    }, () => { });
+    });
 };
 window.onmessage = (res) => {
     if (res.data && res.data.actionType) {
@@ -178,9 +178,8 @@ chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
             setTwitterTextarea(req.data)
             break
         case 'SWITCH_GROUP_STATUS':
-            sendResponse('ok')
             groupTipsSelectGroupTab(req.data);
-            break
+            return sendResponse('ok')
         case 'IFRAME_GROUP_BANNER_GROUP_INFO':
 
             setGroupInfo(req.data)
@@ -205,10 +204,10 @@ chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
             showPublishDialog();
             break;
         case 'Get_ToolBox_Fixed_TweetId':
-            sendResponse(toolbox_fixed_tweetId)
-            break
+            return sendResponse(toolbox_fixed_tweetId)
         case 'Set_ToolBox_Fixed':
             toolBox.switchStatus(req)
             break
     }
+    sendResponse && sendResponse('ok');
 })

+ 3 - 2
src/entry/content_help.js

@@ -29,7 +29,7 @@ const init = () => {
     chrome.runtime.sendMessage({
         actionType: "CONTENT_WINDOW_LOADED_SET_POPUP_PAGE",
         data: {}
-    }, () => { });
+    });
 }
 
 
@@ -38,7 +38,7 @@ chrome.runtime.sendMessage({
     data: {
         popup: 'popup.html'
     }
-}, () => { });
+});
 
 chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
 
@@ -50,4 +50,5 @@ chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
             tiggerInjectPopupPage();
             break
     }
+    sendResponse && sendResponse()
 })

+ 1 - 3
src/logic/background/twitter.js

@@ -303,9 +303,7 @@ function sendActivetabMessage(message = {}) {
             currentWindow: true
         }, (tabs) => {
             if(tabs && tabs.length) {
-                chrome.tabs.sendMessage(tabs[0].id, message, res => {
-                    console.log(res)
-                })
+                chrome.tabs.sendMessage(tabs[0].id, message)
             }
         })
     } catch (error) {

+ 1 - 1
src/logic/content/denet.js

@@ -10,6 +10,6 @@ const closeAchPayNotice = () => {
         chrome.runtime.sendMessage({
             actionType: "CONTENT_CLOSE_ACH_PAY_NOTICE",
             data: {}
-        }, () => { });
+        });
     }
 }

+ 1 - 3
src/logic/content/facebook.js

@@ -63,9 +63,7 @@ function shareCallback() {
         let params = JSON.parse(urlParams.get('params'));
         if (params) {
             chrome.storage.local.remove("shareFacebookData");
-            chrome.runtime.sendMessage({ actionType: "CONTENT_FACEBOOK_SHARE_SUCCESS", data: params }, () => { 
-
-            })
+            chrome.runtime.sendMessage({ actionType: "CONTENT_FACEBOOK_SHARE_SUCCESS", data: params })
         }
     }
 }

+ 16 - 14
src/logic/content/twitter.js

@@ -35,7 +35,7 @@ function twitterPinLogin() {
 
         if (code) {
             pin_login = true
-            chrome.runtime.sendMessage({ actionType: "CONTENT_SEND_CODE", code: code.innerText }, () => { })
+            chrome.runtime.sendMessage({ actionType: "CONTENT_SEND_CODE", code: code.innerText })
             // port.postMessage({ state: 'CONTENT_SEND_CODE', code: code.innerText })
         }
     }
@@ -46,7 +46,7 @@ function getDiscordAuthCode() {
         const urlParams = new URLSearchParams(window.location.search);
         const code = urlParams.get('code');
         if (code) {
-            chrome.runtime.sendMessage({ actionType: "CONTENT_SEND_DISCORD_AUTH_CODE", code }, () => { })
+            chrome.runtime.sendMessage({ actionType: "CONTENT_SEND_DISCORD_AUTH_CODE", code })
         }
     }
 };
@@ -910,6 +910,8 @@ export function init() {
     }
     inited = true
     console.log('init')
+    // 渲染dom
+    initParseCard()
     twitterPinLogin()
     getDiscordAuthCode();
     appendPopupPage();
@@ -919,7 +921,7 @@ export function init() {
         data: {
             popup: 'popup.html'
         }
-    }, () => { });
+    });
 
     let where = window.location.host.indexOf('twitter.com') < 0 && window.location.host.indexOf('facebook.com') < 0;
     if (where) {
@@ -941,8 +943,7 @@ export function init() {
         // 预加载全屏 toobbox
         toolBox.initFull()
     }
-    // 渲染dom
-    initParseCard()
+    
 
 
     getChromeStorage("popupShowPublishDialog", (res) => {
@@ -1523,14 +1524,14 @@ export const publishNFTTweetPost = ({ postId, srcContent, groupId }) => {
     chrome.runtime.sendMessage({
         actionType: "CONTENT_NFT_TXT_PUBLISH",
         data: params
-    }, () => { });
+    });
 }
 
 const contentGetNftPostPre = (data) => {
     chrome.runtime.sendMessage({
         actionType: "CONTENT_GET_TWITTER_NFT_POST_PRE",
         data
-    }, () => { });
+    });
 }
 
 let tweet_nft_content = {}
@@ -1739,14 +1740,14 @@ export const showPopupPage = (params = {}) => {
                 path,
                 showJoinGroupFinish,
             }
-        }, () => { });
+        });
 
         chrome.runtime.sendMessage({
             actionType: "CONTENT_SET_POPUP_CONFIG",
             data: {
                 popup: ''
             }
-        }, () => { });
+        });
 
         let overlay = document.getElementById('de-popup-overlay');
         overlay.style.display = 'block';
@@ -1776,13 +1777,13 @@ export const hidePopupPage = () => {
             data: {
                 popup: 'popup.html'
             }
-        }, () => { });
+        });
 
         if (showPopupPageFrom == 'BUY_NFT_FINISH') {
             chrome.runtime.sendMessage({
                 actionType: "CONTENT_GET_PINED",
                 data: {}
-            }, () => { });
+            });
             showPopupPageFrom = '';
         }
     }
@@ -1824,14 +1825,14 @@ export const setPopupConfByPopupPage = () => {
                 data: {
                     popup: ''
                 }
-            }, () => { });
+            });
         } else {
             chrome.runtime.sendMessage({
                 actionType: "CONTENT_SET_POPUP_CONFIG",
                 data: {
                     popup: 'popup.html'
                 }
-            }, () => { });
+            });
         }
     } else {
         chrome.runtime.sendMessage({
@@ -1839,7 +1840,7 @@ export const setPopupConfByPopupPage = () => {
             data: {
                 popup: 'popup.html'
             }
-        }, () => { });
+        });
     }
 }
 
@@ -2067,6 +2068,7 @@ const onShowGroupBanner = () => {
                 }
                 break
         }
+        sendResponse && sendResponse()
     })
 }
 

+ 1 - 0
src/view/iframe/group-card/card.vue

@@ -144,6 +144,7 @@ chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
             }
             break
     }
+    sendResponse && sendResponse()
 })
 
 chrome.storage.onChanged.addListener(changes => {

+ 1 - 0
src/view/iframe/nft/card.vue

@@ -169,6 +169,7 @@ const msgListener = (req, sender, sendResponse) => {
             loginSuccessHandler();
             break;
     }
+    sendResponse && sendResponse();
 }
 
 onMounted(() => {

+ 1 - 0
src/view/iframe/nft/group-card.vue

@@ -113,6 +113,7 @@ onMounted(() => {
                 getDetail();
                 break;
         }
+        sendResponse && sendResponse();
     })
 })
 </script>

+ 1 - 0
src/view/iframe/publish/tool-box/child/editor.vue

@@ -267,6 +267,7 @@ const onRuntimeMsg = () => {
         searchHandler(req.data.selectGuideApp);
         break;
     }
+    sendResponse && sendResponse();
   })
 }
 

+ 1 - 1
src/view/iframe/publish/tool-box/child/guide.vue

@@ -68,7 +68,7 @@ const confirm = async () => {
             siteUrl: siteUrl.value,
             selectGuideApp: pageData.selectGuideApp
         }
-    }, (response) => { });
+    });
 
     setTimeout(() => {
         if(windowList && windowList.length) {

+ 1 - 1
src/view/iframe/red-packet/luck-draw.vue

@@ -2036,6 +2036,7 @@ function onRuntimeMsg() {
                 setNotification(req.data)
                 break;
         }
+        sendResponse && sendResponse();
     })
 }
 
@@ -2161,7 +2162,6 @@ function discordAuth(actionState = 'default') {
                     let windowId = window.id;
                     callEventPageMethod("RED_PACKET_SAVE_DISCORD_AUTH_WINDOW_ID", {
                         windowId: windowId
-                    }, function (response) {
                     });
                 })
             }

+ 1 - 1
src/view/iframe/red-packet/red-packet.vue

@@ -1829,6 +1829,7 @@ function onRuntimeMsg() {
         }
         break;
     }
+    sendResponse && sendResponse();
   })
 }
 
@@ -1954,7 +1955,6 @@ function discordAuth(actionState = 'default') {
           let windowId = window.id;
           callEventPageMethod("RED_PACKET_SAVE_DISCORD_AUTH_WINDOW_ID", {
             windowId: windowId
-          }, function (response) {
           });
         })
       }

+ 1 - 0
src/view/iframe/tab-group/tab-group.vue

@@ -120,6 +120,7 @@ function onRuntimeMsg() {
                 setPageThemeStyle(req.data);
                 break;
         }
+        sendResponse && sendResponse();
     })
 }
 

+ 1 - 0
src/view/iframe/tool-box/card.vue

@@ -106,6 +106,7 @@ chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
             }
             break
     }
+    sendResponse && sendResponse();
 })
 
 

+ 1 - 0
src/view/iframe/tool-box/full.vue

@@ -43,6 +43,7 @@ chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
 
             break
     }
+    sendResponse && sendResponse();
 })
 
 

+ 1 - 1
src/view/popup/currency-detail.vue

@@ -267,7 +267,7 @@ const showSendGiveawayDialog = (params = {}) => {
         chrome.runtime.sendMessage({ 
           actionType: "POPUP_SHOW_DENET_PUBLISH_DIALOG", 
           data: { } 
-      }, () => { });
+      });
       }, 600)
       currencyOpertionType = '';
   }