zhangwei 2 роки тому
батько
коміт
d6d2e5c355
2 змінених файлів з 39 додано та 24 видалено
  1. 23 16
      src/entry/background.js
  2. 16 8
      src/logic/background/twitter.js

+ 23 - 16
src/entry/background.js

@@ -115,30 +115,37 @@ function thenInstalledMethod() {
     } catch (error) {
         Report.reportLog({
             objectType: Report.objectType.background_function_catch,
-            funcName: 'onInstalledMethod',
+            funcName: 'thenInstalledMethod',
             errMsg: error.message
-        });
+        })
     }
 }
 function onInstalledMethod() {
-    // 版本更新判断
-    getChromeStorage('baseInfo', (info) => {
-        if (!info || !info.appVersionCode) {
-            setChromeStorage({ baseInfo: JSON.stringify({ appVersionCode }) })
-            thenInstalledMethod()
-        } else if (appVersionCode != info.appVersionCode) {
-            setChromeStorage({ baseInfo: JSON.stringify({ appVersionCode }) }, () => {
-                chrome.runtime.reload()
-            })
-        } else {
-            thenInstalledMethod()
-        }
-    })
+    try {
+        // 版本更新判断
+        getChromeStorage('baseInfo', (info) => {
+            if (!info || !info.appVersionCode) {
+                setChromeStorage({ baseInfo: JSON.stringify({ appVersionCode }) })
+                thenInstalledMethod()
+            } else if (appVersionCode != info.appVersionCode) {
+                setChromeStorage({ baseInfo: JSON.stringify({ appVersionCode }) }, () => {
+                    chrome.runtime.reload()
+                })
+            } else {
+                thenInstalledMethod()
+            }
+        })
+    } catch (error) {
+        Report.reportLog({
+            objectType: Report.objectType.background_function_catch,
+            funcName: 'onInstalledMethod',
+            errMsg: error.message
+        })
+    }
 }
 
 function onMessageMethod(req, sender, sendResponse) {
     try {
-
         if (req) {
             switch (req.actionType) {
                 case "POPUP_LOGIN":

+ 16 - 8
src/logic/background/twitter.js

@@ -287,7 +287,7 @@ export function checkPined() {
 }
 
 function sendActivetabMessage(message = {}) {
-    try{
+    try {
         chrome.tabs.query({
             active: true,
             currentWindow: true
@@ -512,7 +512,7 @@ export const injectExtensionPopup = (tab) => {
 }
 
 export const setPopupConfig = (activeInfo) => {
-    try{
+    try {
         chrome.tabs.query({
             active: true,
             currentWindow: true
@@ -536,17 +536,25 @@ export const setPopupConfig = (activeInfo) => {
             objectType: Report.objectType.background_function_catch,
             funcName: 'setPopupConfig',
             errMsg: error.message
-        });
+        })
     }
 }
 
 export const getSysMessage = () => {
-    // 请求通知接口
-    fetchGetAllUnReadNotices({})
-        .then((res) => {
-            // 向选中的content发送消息
-            setContentMessage({ actionType: 'BACK_UNREAD_MESSAGE', data: res })
+    try {
+        // 请求通知接口
+        fetchGetAllUnReadNotices({})
+            .then((res) => {
+                // 向选中的content发送消息
+                setContentMessage({ actionType: 'BACK_UNREAD_MESSAGE', data: res })
+            })
+    } catch (error) {
+        Report.reportLog({
+            objectType: Report.objectType.background_function_catch,
+            funcName: 'getSysMessage',
+            errMsg: error.message
         })
+    }
 }
 
 export const windwoLoadSetPopupPage = (data, sender) => {