当前位置:网站首页>Uni hot update
Uni hot update
2022-07-01 07:59:00 【diangedan】
// Check whether the version is updated
updateVersion() {
// Hot update will not update app Version number of
// Here we use a constant to define ( Each time you modify the version number, you will manually update the version number in the settings )
let realVersion = '1';
//plus.runtime.getProperty(), Get the locally installed version , Please refer to the following links for specific use
// 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, ""); // Get the current version number
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: ' A new version has been found ',
content: ' Confirm update ?',
success: function(res) {
if (res.confirm) {
uni.downloadFile({
url: downloadUrl,
success: (downloadResult) => {
plus.runtime.install(
downloadResult
.tempFilePath, {
force: true
},
function() {
// Application hot restart , Restart to enter the home page .
plus.runtime.restart();
uni.showModal({
title: ' Installation successful !',
content: ' Re entered the app ',
success: function(res) {
if (res.confirm) {
console.log(' The user clicks ok ');
} else if(res.cancel) {
console.log(' The user clicks cancel ');
}
}
});
// uni.hideToast();
},
function(e) {
uni.showToast({
title: ' Installation failed ',
icon: 'none'
})
})
},
fail: (err) => {
console.log(err)
uni.showToast({
title: ' Download failed ',
icon: 'none'
})
}
})
} else if (res.cancel) {
uni.showToast({
title: ' Cancelled ',
icon: 'none'
})
}
}
})
}
} else {
uni.showToast({
title: res.data.msg,
icon: 'none'
})
}
}).catch(err => {
console.log(err)
})
})
},边栏推荐
- Li Kou daily question - day 31 -202 Happy number
- kubernetes资源对象介绍及常用命令(二)
- EDA开源仿真工具verilator入门6:调试实例
- 2022 test question bank and simulation test of tea master (primary) operation certificate
- 奥迪AUDI EDI 项目中供应商需要了解哪些信息?
- I bet on performance and won the CTO of the company. I want to build Devops platform!
- 【mysql学习笔记28】存储函数
- 2022危险化学品经营单位主要负责人试题及模拟考试
- Teach you how to apply for domestic trademark online step by step
- Gui Gui programming (XV) - use scale to control font size changes
猜你喜欢

Eigen矩阵运算库快速上手

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

web254

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

Aardio - 阴影渐变文字

Microsoft stream - how to modify video subtitles
![[website architecture] solve 90% of distributed transactions in one move, and introduce the working principles and application scenarios of database transactions and distributed transactions](/img/2c/07d729d49b1d74553decac4588074e.png)
[website architecture] solve 90% of distributed transactions in one move, and introduce the working principles and application scenarios of database transactions and distributed transactions

How to check ad user information?

The triode is a great invention

Why some people earn nearly 10billion a year, while others earn 3000 a month: the details you ignore actually make the most money
随机推荐
Latex table
【R语言】两个/N个数据合并merge函数
[website architecture] solve 90% of distributed transactions in one move, and introduce the working principles and application scenarios of database transactions and distributed transactions
uni 热更新
MATLAB之基础知识
Tupu software has passed CMMI5 certification| High authority and high-level certification in the international software field
getInputStream() has already been called for this request
Inftnews | from "avalanche" to Baidu "xirang", 16 major events of the meta universe in 30 years
web254
How outlook puts together messages with the same discussion
Access报表实现小计功能
Todolist classic case ①
她就是那个「别人家的HR」|ONES 人物
[R language] age sex frequency matching select samples for case-control study, and perform frequency matching on age and sex
How to use layui to display the data in the database in the form of tables
Li Kou daily question - day 31 -202 Happy number
AArdio - 【问题】bass库回调时内存增长的问题
软键盘高度报错
Apple account password auto fill
[batch DOS CMD summary] extension variables - delay variables CMD /v:on, CMD /v:off, SETLOCAL enabledelayedexpansion, disabledelayedexpansion