当前位置:网站首页>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)
})
})
},
边栏推荐
- [MySQL learning notes 28] storage function
- Minecraft 1.16.5模组开发(五十一) 方块实体 (Tile Entity)
- How to make the two financial transactions faster
- 【技能】创建.bat快速打开网页
- How to troubleshoot SharePoint online map network drive failure?
- [软件] phantomjs屏幕截图
- 力扣每日一题-第31天-1790.仅执行一次字符串交换能否使两个字符串相等
- SharePoint - how to quickly check whether SharePoint is standard or enterprise edition?
- Insufficient executors to build thread pool
- 【R语言】两个/N个数据合并merge函数
猜你喜欢
Software testing methods and techniques - overview of basic knowledge
Aardio - 阴影渐变文字
How to check ad user information?
Apple account password auto fill
Redisson uses the full solution - redisson official document + comments (Part 2)
Minecraft 1.16.5模组开发(五十一) 方块实体 (Tile Entity)
【mysql学习笔记25】sql语句优化
奥迪AUDI EDI 项目中供应商需要了解哪些信息?
【批处理DOS-CMD-汇总】扩展变量-延迟变量cmd /v:on、cmd /v:off、setlocal enabledelayedexpansion、DisableDelayedExpansion
Caesar
随机推荐
Aardio - 自己构造的getIconHandle的方法
PWN攻防世界int_overflow
【mysql学习笔记28】存储函数
ContentType所有类型对比
Android screen adaptation (using constraintlayout), kotlin array sorting
[MySQL learning notes27] stored procedure
奥迪AUDI EDI 项目中供应商需要了解哪些信息?
[recommendation system] breakthrough and imagination of deep location interactive network dpin for meituan takeout recommendation scenario
window c盘满了
[软件] phantomjs屏幕截图
Basic number theory -- combinatorial number
How to check ad user information?
【mysql学习笔记27】存储过程
php laravel微信支付
[software] phantomjs screenshot
Redisson watchdog mechanism, redisson watchdog performance problems, redisson source code analysis
Introduction to kubernetes resource objects and common commands (II)
She is the "HR of others" | ones character
LSTM of RNN
[skill] create Bat quick open web page