uni-update-check
Version:
跨端(微信小程序 & App)的一体化版本更新检查工具,用于uni-app项目。支持wgt热更新、APK整包更新、iOS商店跳转以及小程序原生更新。
40 lines (34 loc) • 795 B
JavaScript
;
/**
* 小程序端检查更新
*/
function checkUpdateWeapp() {
try {
if (typeof wx === 'undefined' || !wx.getUpdateManager) {
return;
}
const updateManager = wx.getUpdateManager();
updateManager.onCheckForUpdate((res) => {
// res.hasUpdate
});
updateManager.onUpdateReady(() => {
wx.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success: (res) => {
if (res.confirm) {
updateManager.applyUpdate();
}
}
});
});
updateManager.onUpdateFailed(() => {
wx.showToast({ title: '新版本下载失败', icon: 'none' });
});
} catch (e) {
// ignore
}
}
module.exports = {
checkUpdateWeapp
};