37 lines
803 B
Vue
37 lines
803 B
Vue
<script setup>
|
|
import { onLaunch } from "@dcloudio/uni-app"
|
|
onLaunch(() => {
|
|
const updateManager = wx.getUpdateManager()
|
|
updateManager.onCheckForUpdate(function (res) {
|
|
// 请求完新版本信息的回调
|
|
console.log(res.hasUpdate)
|
|
})
|
|
|
|
updateManager.onUpdateReady(function () {
|
|
uni.showModal({
|
|
title: '更新提示',
|
|
content: '新版本已经准备好,是否重启应用?',
|
|
success(res) {
|
|
if (res.confirm) {
|
|
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
|
updateManager.applyUpdate()
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
updateManager.onUpdateFailed(function () {
|
|
// 新版本下载失败
|
|
uni.showToast({
|
|
title: '更新失败,请手动清理缓存重试',
|
|
icon: 'none'
|
|
});
|
|
})
|
|
|
|
})
|
|
</script>
|
|
|
|
<style>
|
|
/*每个页面公共css */
|
|
</style>
|