当前位置:网站首页>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)
})
})
},边栏推荐
- Custom events of components ①
- 【力扣10天SQL入门】Day10 控制流
- Microsoft stream - how to modify video subtitles
- AUTOSAR learning record (1) – ECUM_ Init
- Eigen矩阵运算库快速上手
- Missing API interface actual development series (14): ID card real name authentication verification
- Sorting out tcp/udp communication problems
- She is the "HR of others" | ones character
- 2022危险化学品经营单位主要负责人试题及模拟考试
- window c盘满了
猜你喜欢

奥迪AUDI EDI 项目中供应商需要了解哪些信息?

Latex formula code

软键盘高度报错

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

Eigen矩阵运算库快速上手

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

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

下载Xshell和Xftp

三极管是一项伟大的发明
![[recommendation system] breakthrough and imagination of deep location interactive network dpin for meituan takeout recommendation scenario](/img/10/ed857892d2e0ea72e100a4008e6d69.png)
[recommendation system] breakthrough and imagination of deep location interactive network dpin for meituan takeout recommendation scenario
随机推荐
5大组合拳,解决校园6大难题,护航教育信息化建设
【批处理DOS-CMD-汇总】扩展变量-延迟变量cmd /v:on、cmd /v:off、setlocal enabledelayedexpansion、DisableDelayedExpansion
她就是那个「别人家的HR」|ONES 人物
Custom events of components ①
【力扣10天SQL入门】Day10 控制流
Access报表实现小计功能
Kickback -- find the first palindrome character in a group of characters
Sorting out tcp/udp communication problems
【网站架构】一招搞定90%的分布式事务,实打实介绍数据库事务、分布式事务的工作原理应用场景
Aardio - Method of self constructed geticonhandle
Redisson uses the complete solution - redisson official documents + Notes (Part 1)
PHP laravel wechat payment
Minecraft 1.16.5模组开发(五十一) 方块实体 (Tile Entity)
AUTOSAR learning record (1) – ECUM_ Init
IMDB practice of emotion classification (simplernn, LSTM, Gru)
Vhost kick & call principle
Contenttype comparison of all types
web254
EDA开源仿真工具verilator入门6:调试实例
Office365 - how to use stream app to watch offline files at any time