|
@@ -50,11 +50,9 @@ chrome.runtime.onConnect.addListener(function (port) {
|
|
|
// 当有可用更新时触发
|
|
|
chrome.runtime.onUpdateAvailable.addListener(() => {
|
|
|
try {
|
|
|
- Report.reportLog({
|
|
|
- objectType: Report.objectType.background_function_try,
|
|
|
- funcName: 'onUpdateAvailable'
|
|
|
- });
|
|
|
- chrome.runtime.reload()
|
|
|
+ setChromeStorage({ onUpdateAvailable: '1' }, () => {
|
|
|
+ chrome.runtime.reload()
|
|
|
+ })
|
|
|
} catch (error) {
|
|
|
Report.reportLog({
|
|
|
objectType: Report.objectType.background_function_catch,
|
|
@@ -120,20 +118,38 @@ function thenInstalledMethod() {
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+// 2.reportLog 异常 存储到本地,再上报
|
|
|
+// 3.onInstalledMethod 执行了那个
|
|
|
+
|
|
|
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()
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ // 1.onUpdateAvailable 存储到本地,再上报
|
|
|
+ getChromeStorage('baseInfo', (res) => {
|
|
|
+ if (res && res.onUpdateAvailable) {
|
|
|
+ Report.reportLog({
|
|
|
+ objectType: Report.objectType.background_function_try,
|
|
|
+ funcName: 'onUpdateAvailable',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } catch (error) {
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
function onMessageMethod(req, sender, sendResponse) {
|