添加小程序更新代码
This commit is contained in:
parent
1c85a641e4
commit
6ed45b630f
41
App.vue
41
App.vue
@ -1,17 +1,36 @@
|
|||||||
<script>
|
<script setup>
|
||||||
export default {
|
import { onLaunch } from "@dcloudio/uni-app"
|
||||||
onLaunch: function() {
|
onLaunch(() => {
|
||||||
console.log('App Launch')
|
const updateManager = wx.getUpdateManager()
|
||||||
},
|
updateManager.onCheckForUpdate(function (res) {
|
||||||
onShow: function() {
|
// 请求完新版本信息的回调
|
||||||
console.log('App Show')
|
console.log(res.hasUpdate)
|
||||||
},
|
})
|
||||||
onHide: function() {
|
|
||||||
console.log('App Hide')
|
updateManager.onUpdateReady(function () {
|
||||||
|
uni.showModal({
|
||||||
|
title: '更新提示',
|
||||||
|
content: '新版本已经准备好,是否重启应用?',
|
||||||
|
success(res) {
|
||||||
|
if (res.confirm) {
|
||||||
|
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
||||||
|
updateManager.applyUpdate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
updateManager.onUpdateFailed(function () {
|
||||||
|
// 新版本下载失败
|
||||||
|
uni.showToast({
|
||||||
|
title: '更新失败,请手动清理缓存重试',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
/*每个页面公共css */
|
/*每个页面公共css */
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user