Browse Source

优化小程序热更新

kaileyhao 1 year ago
parent
commit
9673114c14
2 changed files with 57 additions and 2 deletions
  1. 21 1
      app.js
  2. 36 1
      project.config.json

+ 21 - 1
app.js

@@ -6,7 +6,27 @@ App({
   },
   onLaunch: function () {
     
+    // const updateManager = wx.getUpdateManager()
+    // console.log(updateManager)
+    // updateManager.onCheckForUpdate(function (res) {
+    //   // 请求完新版本信息的回调
+    //   console.log(res.hasUpdate)
+    // })
+    // updateManager.onUpdateReady(function () {
+    //   wx.showModal({
+    //     title: '更新提示',
+    //     content: '新版本已经准备好,是否重启应用吗?',
+    //     success(res) {
+    //       if (res.confirm) {
+    //         // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
+    //         updateManager.applyUpdate()
+    //       }
+    //     }
+    //   })
+    // })
+
     if (wx.canIUse('getUpdateManager')) {
+      console.log(wx.canIUse('getUpdateManager'))
       const updateManager = wx.getUpdateManager()
       updateManager.onCheckForUpdate(function (res) {
         console.log('onCheckForUpdate====', res)
@@ -130,7 +150,7 @@ App({
     title: '缘分糖化漂流',
     desc: '全国糖友都在参与!你也来测糖化识糖友吧~',
     path: "pages/mapIndex/mapIndex",
-    imageUrl: "https://test.ttq.so/wechatProgram/images/shareImg.png",
+    imageUrl: "https://test.ttq.so/wechatProgram/images/shareImg.png?1",
     userToken:'',
 
     couponShow :true,

+ 36 - 1
project.config.json

@@ -48,7 +48,7 @@
 			"list": []
 		},
 		"miniprogram": {
-			"current": 0,
+			"current": 5,
 			"list": [
 				{
 					"id": 0,
@@ -56,6 +56,41 @@
 					"pathName": "pages/mapIndex/mapIndex",
 					"query": "",
 					"scene": null
+				},
+				{
+					"id": -1,
+					"name": "pages/auth/index",
+					"pathName": "pages/auth/index",
+					"query": "",
+					"scene": null
+				},
+				{
+					"id": -1,
+					"name": "pages/auth/index",
+					"pathName": "pages/auth/index",
+					"query": "",
+					"scene": null
+				},
+				{
+					"id": -1,
+					"name": "pages/auth/index",
+					"pathName": "pages/auth/index",
+					"query": "",
+					"scene": null
+				},
+				{
+					"id": -1,
+					"name": "pages/auth/index",
+					"pathName": "pages/auth/index",
+					"query": "",
+					"scene": null
+				},
+				{
+					"id": -1,
+					"name": "pages/auth/index",
+					"pathName": "pages/auth/index",
+					"query": "",
+					"scene": null
 				}
 			]
 		}