|
@@ -1,3 +1,6 @@
|
|
|
+import { getChromeStorage, setChromeStorage } from '@/uilts/chromeExtension'
|
|
|
+import { appVersionCode } from '@/http/configAPI.js'
|
|
|
+
|
|
|
// 此文件不要写具体逻辑,只调用函数
|
|
|
import {
|
|
|
twitterShortUrl,
|
|
@@ -86,7 +89,7 @@ chrome.action.onClicked.addListener(function (tab) {
|
|
|
chrome.tabs.onActivated.addListener(function (activeInfo) {
|
|
|
setPopupConfig(activeInfo);
|
|
|
})
|
|
|
-function onInstalledMethod() {
|
|
|
+function thenInstalledMethod() {
|
|
|
try {
|
|
|
onInstalledCreateTab()
|
|
|
onInstalledMid()
|
|
@@ -119,6 +122,23 @@ function onInstalledMethod() {
|
|
|
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()
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
function onMessageMethod(req, sender, sendResponse) {
|