当前位置:网站首页>uni 热更新
uni 热更新
2022-07-01 07:56:00 【diangedan】
// 检查是否更新版本
updateVersion() {
// 热更新不会更新app的版本号
// 这里用一个常量定义(每次修改版本号将设置里面的版本号手动更新)
let realVersion = '1';
//plus.runtime.getProperty(),获取本机安装的版本,具体使用请参照如下链接
// https: //www.html5plus.org/doc/zh_cn/runtime.html#plus.runtime.WidgetInfo
plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) {
let currentVersion = widgetInfo.version.replace(/\./g, ""); //获取当前版本号
sendVersion().then(res => {
const code = res.data.code;
if (code === 100) {
let newVersion = res.data.data.id;
let downloadUrl = res.data.data.downloadUrl;
if (realVersion < newVersion) {
uni.showModal({
title: '已发现新版本',
content: '确认更新?',
success: function(res) {
if (res.confirm) {
uni.downloadFile({
url: downloadUrl,
success: (downloadResult) => {
plus.runtime.install(
downloadResult
.tempFilePath, {
force: true
},
function() {
// 应用热重启,重新启动进入首页。
plus.runtime.restart();
uni.showModal({
title: '安装成功!',
content: '已重新进入应用',
success: function(res) {
if (res.confirm) {
console.log('用户点击确定');
} else if(res.cancel) {
console.log('用户点击取消');
}
}
});
// uni.hideToast();
},
function(e) {
uni.showToast({
title: '安装失败',
icon: 'none'
})
})
},
fail: (err) => {
console.log(err)
uni.showToast({
title: '下载失败',
icon: 'none'
})
}
})
} else if (res.cancel) {
uni.showToast({
title: '已取消',
icon: 'none'
})
}
}
})
}
} else {
uni.showToast({
title: res.data.msg,
icon: 'none'
})
}
}).catch(err => {
console.log(err)
})
})
},边栏推荐
- Gui Gui programming (XV) - use scale to control font size changes
- Latex table
- Gdip - hatchBrush图案表
- [MySQL learning notes 28] storage function
- Day5: scanner object, next() and nextline(), sequential structure, selection structure, circular structure
- PHP laravel wechat payment
- Significance and measures of source code encryption
- How to get a SharePoint online site created using the office365 group template
- What information does the supplier need to know about Audi EDI project?
- Apple account password auto fill
猜你喜欢

Aardio - Shadow Gradient Text

How to use layui to display the data in the database in the form of tables

关系数据库如何工作

【mysql学习笔记25】sql语句优化

2022 test question bank and simulation test of tea master (primary) operation certificate

Vhost kick & call principle

2022 mobile crane driver test exercises and online simulation test

base64

Gui Gui programming (XV) - use scale to control font size changes

038 network security JS
随机推荐
【R语言】年龄性别频数匹配 挑选样本 病例对照研究,对年龄性别进行频数匹配
[MySQL learning notes 28] storage function
Thesis learning -- Analysis and Research on similarity query of hydrological time series
redisson使用全解——redisson官方文档+注释(上篇)
Significance and measures of source code encryption
【批处理DOS-CMD命令-汇总和小结】-Cmd窗口中常用操作符(<、<<、&<、>、>>、&>、&、&&、||、|、()、;、@)
Discussion on several research hotspots of cvpr2022
LSTM of RNN
关系数据库如何工作
Contenttype comparison of all types
力扣——求一组字符中的第一个回文字符
Implementation and encapsulation of go universal dynamic retry mechanism
Kickback -- find the first palindrome character in a group of characters
The Windows C disk is full
【批处理DOS-CMD-汇总】扩展变量-延迟变量cmd /v:on、cmd /v:off、setlocal enabledelayedexpansion、DisableDelayedExpansion
Apple account password auto fill
STM32 uses esp01s to go to the cloud, mqtt FX debugging
组件的自定义事件②
2022危险化学品经营单位主要负责人试题及模拟考试
PHP laravel wechat payment