// app.ts App({ globalData: {}, onLaunch() { const updateManager = wx.getUpdateManager() updateManager.onCheckForUpdate(function (res) { // 请求完新版本信息的回调 console.log('是否有新版本', res.hasUpdate) }) updateManager.onUpdateReady(function () { // 新版本下载完毕,强制重启应用 wx.showModal({ title: '更新提示', content: '新版本已就绪,即将重启应用', showCancel: false, success: function (res) { if (res.confirm) { // 强制重启,应用新版本 updateManager.applyUpdate() } } }) }) updateManager.onUpdateFailed(function () { // 新版本下载失败 wx.showModal({ title: '更新提示', content: '新版本下载失败,请检查网络后重试', showCancel: false }) }) const envVersion = wx.getAccountInfoSync().miniProgram.envVersion if (envVersion !== 'release') { wx.reLaunch({ url: '/pages/tools/index' }) } }, })