添加版本更新提示

This commit is contained in:
xuwenbo
2020-09-14 14:50:54 +08:00
parent 3d519fa840
commit f449f9cf58

39
App.vue
View File

@ -1,8 +1,35 @@
<script>
import Vue from 'vue'
export default {
onLaunch: function () {
console.log("App Launch");
onLaunch: function() {
// debugger
const updateManager = uni.getUpdateManager()
updateManager.onCheckForUpdate(function (res) {
// 请求完新版本信息的回调
console.log(res.hasUpdate)
})
// 下载新版本
updateManager.onUpdateReady(function () {
uni.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success(res) {
if (res.confirm) {
// 重启应用
updateManager.applyUpdate()
}
}
})
})
// 新版本下载失败
updateManager.onUpdateFailed(function (res) {
// 新的版本下载失败
uni.showModal({
title: '已经有新版本了哟~',
content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~',
})
})
},
onShow: function () {
console.log("App Show");
@ -43,17 +70,17 @@ export default {
});
});
},
// 自动登录
async autoLogin(data) {
},
},
};
</script>
<style lang="less">
/*每个页面公共css */
@import "animate.css";