ycm 2 лет назад
Родитель
Сommit
9a12213633
2 измененных файлов с 115 добавлено и 86 удалено
  1. 31 2
      app.js
  2. 84 84
      project.config.json

+ 31 - 2
app.js

@@ -12,7 +12,7 @@ App({
     // wx.cloud.init({
     //   traceUser: true,
     // })
-
+    this.updateApp()
 
     wx.setStorageSync('islocation', false)
     var that = this;
@@ -56,7 +56,36 @@ App({
       })
     })
   },
-
+  updateApp:function(){
+    const updateManager = wx.getUpdateManager()
+    updateManager.onCheckForUpdate(function (res) {
+      // 请求完新版本信息的回调
+      if (res.hasUpdate) {
+        wx.showLoading({
+          title:'更新下载中...',
+        })
+      }
+    })
+    updateManager.onUpdateReady(function () {
+      wx.hideLoading();
+      wx.showModal({
+        title:'更新提示',
+        content:'新版本已经准备好,是否重启应用?',
+        success:function (res) {
+          if (res.confirm) {
+            // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
+            updateManager.applyUpdate()
+          }
+        }
+      })
+ 
+    })
+    updateManager.onUpdateFailed(function () {
+      // 新的版本下载失败
+      wx.hideLoading();
+      wx.showToast({ title:'下载失败...', icon:"none" });
+    })
+  },
 })
 
 

+ 84 - 84
project.config.json

@@ -1,94 +1,94 @@
 {
-  "description": "项目配置文件",
-  "packOptions": {
-    "ignore": [
-      {
-        "type": "file",
-        "value": ".eslintrc.js"
-      }
-    ]
-  },
-  "setting": {
-    "urlCheck": false,
-    "es6": true,
-    "enhance": true,
-    "postcss": true,
-    "preloadBackgroundData": false,
-    "minified": true,
-    "newFeature": false,
-    "coverView": true,
-    "nodeModules": true,
-    "autoAudits": false,
-    "showShadowRootInWxmlPanel": true,
-    "scopeDataCheck": false,
-    "uglifyFileName": false,
-    "checkInvalidKey": true,
-    "checkSiteMap": true,
-    "uploadWithSourceMap": true,
-    "compileHotReLoad": false,
-    "lazyloadPlaceholderEnable": false,
-    "useMultiFrameRuntime": true,
-    "useApiHook": true,
-    "useApiHostProcess": true,
-    "babelSetting": {
-      "ignore": [],
-      "disablePlugins": [],
-      "outputPath": ""
+    "description": "项目配置文件",
+    "packOptions": {
+        "ignore": [
+            {
+                "type": "file",
+                "value": ".eslintrc.js"
+            }
+        ]
     },
-    "useIsolateContext": false,
-    "userConfirmedBundleSwitch": false,
-    "packNpmManually": false,
-    "packNpmRelationList": [
-      {
-        "packageJsonPath": "./package.json",
-        "miniprogramNpmDistDir": "./"
-      }
-    ],
-    "minifyWXSS": true,
-    "disableUseStrict": false,
-    "minifyWXML": true,
-    "showES6CompileOption": false,
-    "useCompilerPlugins": false,
-    "ignoreUploadUnusedFiles": true
-  },
-  "compileType": "miniprogram",
-  "libVersion": "2.22.0",
-  "appid": "wx96efd334b6da6e38",
-  "projectname": "%E6%B5%B7%E6%98%9F%E5%88%86%E6%8B%A3%E7%AB%AF",
-  "debugOptions": {
-    "hidedInDevtools": []
-  },
-  "scripts": {},
-  "staticServerOptions": {
-    "baseURL": "",
-    "servePath": ""
-  },
-  "isGameTourist": false,
-  "condition": {
-    "search": {
-      "list": []
+    "setting": {
+        "urlCheck": false,
+        "es6": true,
+        "enhance": true,
+        "postcss": true,
+        "preloadBackgroundData": false,
+        "minified": true,
+        "newFeature": false,
+        "coverView": true,
+        "nodeModules": true,
+        "autoAudits": false,
+        "showShadowRootInWxmlPanel": true,
+        "scopeDataCheck": false,
+        "uglifyFileName": false,
+        "checkInvalidKey": true,
+        "checkSiteMap": true,
+        "uploadWithSourceMap": true,
+        "compileHotReLoad": false,
+        "lazyloadPlaceholderEnable": false,
+        "useMultiFrameRuntime": true,
+        "useApiHook": true,
+        "useApiHostProcess": true,
+        "babelSetting": {
+            "ignore": [],
+            "disablePlugins": [],
+            "outputPath": ""
+        },
+        "useIsolateContext": false,
+        "userConfirmedBundleSwitch": false,
+        "packNpmManually": false,
+        "packNpmRelationList": [
+            {
+                "packageJsonPath": "./package.json",
+                "miniprogramNpmDistDir": "./"
+            }
+        ],
+        "minifyWXSS": true,
+        "disableUseStrict": false,
+        "minifyWXML": true,
+        "showES6CompileOption": false,
+        "useCompilerPlugins": false,
+        "ignoreUploadUnusedFiles": true
     },
     "compileType": "miniprogram",
     "libVersion": "2.22.0",
     "appid": "wx96efd334b6da6e38",
     "projectname": "%E6%B5%B7%E6%98%9F%E5%88%86%E6%8B%A3%E7%AB%AF",
     "debugOptions": {
-      "hidedInDevtools": [],
-      "conversation": {
-        "list": []
-      },
-      "game": {
-        "list": []
-      },
-      "plugin": {
-        "list": []
-      },
-      "gamePlugin": {
-        "list": []
-      },
-      "miniprogram": {
-        "list": []
-      }
+        "hidedInDevtools": []
+    },
+    "scripts": {},
+    "staticServerOptions": {
+        "baseURL": "",
+        "servePath": ""
+    },
+    "isGameTourist": false,
+    "condition": {
+        "search": {
+            "list": []
+        },
+        "compileType": "miniprogram",
+        "libVersion": "2.22.0",
+        "appid": "wx96efd334b6da6e38",
+        "projectname": "%E6%B5%B7%E6%98%9F%E5%88%86%E6%8B%A3%E7%AB%AF",
+        "debugOptions": {
+            "hidedInDevtools": [],
+            "conversation": {
+                "list": []
+            },
+            "game": {
+                "list": []
+            },
+            "plugin": {
+                "list": []
+            },
+            "gamePlugin": {
+                "list": []
+            },
+            "miniprogram": {
+                "list": []
+            }
+        }
     }
-  }
 }