当前位置:网站首页>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)
})
})
},边栏推荐
- The Windows C disk is full
- redisson使用全解——redisson官方文檔+注釋(上篇)
- Caesar
- 2022危险化学品经营单位主要负责人试题及模拟考试
- Office365 - how to use stream app to watch offline files at any time
- Source code analysis of open source API gateway APIs IX
- Introduction to kubernetes resource objects and common commands (II)
- 【无标题】
- 论文学习——水文时间序列相似性查询的分析与研究
- 如何使用layui将数据库中的数据以表格的形式展现出来
猜你喜欢

Android screen adaptation (using constraintlayout), kotlin array sorting

SharePoint - modify web application authentication using PowerShell

How to check ad user information?

Latex formula code

Aardio - Shadow Gradient Text

关系数据库如何工作

kubernetes资源对象介绍及常用命令(二)

STM32 uses esp01s to go to the cloud, mqtt FX debugging

2022制冷与空调设备运行操作国家题库模拟考试平台操作
![[MySQL learning notes 25] SQL statement optimization](/img/01/cf0556961670bb43512caab8d5f4e5.png)
[MySQL learning notes 25] SQL statement optimization
随机推荐
[batch DOS CMD summary] extension variables - delay variables CMD /v:on, CMD /v:off, SETLOCAL enabledelayedexpansion, disabledelayedexpansion
Saving db4i depth camera pictures with MATLAB
2022年流动式起重机司机考试练习题及在线模拟考试
Redisson utilise la solution complète - redisson Documents officiels + commentaires (Partie 1)
Download xshell and xftp
She is the "HR of others" | ones character
[software] phantomjs screenshot
Scala语言学习-07-构造器
The Windows C disk is full
【mysql学习笔记26】视图
Php laraver Wechat payment
良心安利万向轮 SolidWorks模型素材网站
Missing API interface actual development series (14): ID card real name authentication verification
Custom events of components ①
I bet on performance and won the CTO of the company. I want to build Devops platform!
Day5: scanner object, next() and nextline(), sequential structure, selection structure, circular structure
Redisson uses the complete solution - redisson official documents + Notes (Part 1)
Todolist classic case ①
Li Kou daily question - day 31 -202 Happy number
The triode is a great invention