You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.3 KiB
35 lines
1.3 KiB
10 months ago
|
export default function checkVersion() {
|
||
|
return new Promise((resolve, reject) => {
|
||
|
if (uni.canIUse('getUpdateManager')) {
|
||
|
const updateManager = uni.getUpdateManager();
|
||
|
updateManager.onCheckForUpdate((res) => {
|
||
|
if (res.hasUpdate) {
|
||
|
updateManager.onUpdateReady(() => {
|
||
|
uni.showModal({
|
||
|
title: '更新提示',
|
||
|
content: '新版本已经准备好, 是否重启应用',
|
||
|
success(successRes) {
|
||
|
if (successRes.confirm) {
|
||
|
updateManager.applyUpdate();
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
resolve(true);
|
||
|
});
|
||
|
updateManager.onUpdateFailed(() => {
|
||
|
uni.showModal({
|
||
|
title: '更新提示',
|
||
|
content: '新版本已经上线了,请您删除当前小程序,重新搜索打开~'
|
||
|
});
|
||
|
reject(false);
|
||
|
});
|
||
|
} else {
|
||
|
resolve(true);
|
||
|
}
|
||
|
});
|
||
|
} else {
|
||
|
reject(false);
|
||
|
}
|
||
|
});
|
||
|
}
|