pay-employee/src/common/libraries/updateManager.ts

26 lines
664 B
TypeScript
Raw Normal View History

2025-07-08 16:49:39 +08:00
export function CheckUpdate() {
2025-07-09 00:34:00 +08:00
const updateManager = uni.getUpdateManager()
2025-07-08 16:49:39 +08:00
updateManager.onCheckForUpdate(function (res) {
// 请求完新版本信息的回调
2025-07-09 00:34:00 +08:00
console.log(res.hasUpdate)
})
2025-07-08 16:49:39 +08:00
updateManager.onUpdateReady(function () {
uni.showModal({
2025-07-09 00:34:00 +08:00
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
2025-07-08 16:49:39 +08:00
success: function (res) {
if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
2025-07-09 00:34:00 +08:00
updateManager.applyUpdate()
2025-07-08 16:49:39 +08:00
}
2025-07-09 00:34:00 +08:00
}
})
})
2025-07-08 16:49:39 +08:00
updateManager.onUpdateFailed(function () {
// 新版本下载失败
2025-07-09 00:34:00 +08:00
})
2025-07-08 16:49:39 +08:00
}