共计 869 个字符,预计需要花费 3 分钟才能阅读完成。
热更新会自动安装
整包更新会自动打开指定地址
// #ifdef APP-PLUS
// 锁定屏幕方向
plus.screen.lockOrientation('portrait-primary'); //锁定
// 检测升级
uni.request({
url: _self.gConfig.baseUrl + 'update',
method: 'POST',
data: {
version: _self.$currentVersion,
uniVersion: plus.runtime.uniVersion, // uni-app的基座版本号
os: plus.os.name,
appid: plus.runtime.appid,
uuid:plus.device.uuid
},
success: (result) => {
var data = result.data;
if (data.update && data.wgtUrl) {
uni.downloadFile({
url: data.wgtUrl,
success: (downloadResult) => {
if (downloadResult.statusCode === 200) {
plus.runtime.install(downloadResult.tempFilePath, {
force: true
}, function() {
plus.nativeUI.toast('更新成功');
plus.runtime.restart();
}, function(e) {
plus.nativeUI.toast('更新失败');
});
}
}
});
}
if (data.update && data.pkgUrl) {
uni.showModal({
title: '更新提示',
showCancel: !data.force,
content: data.note ? data.note : '是否选择更新',
success: (showResult) => {
if (showResult.confirm) {
plus.runtime.openURL(data.pkgUrl);
}
}
})
}
}
});
// #endif
正文完