uniapp APP版本更新

复制代码
var dtask = plus.downloader.createDownload(userl.value, {}, function(d, status) {
		 
							if (status == 200) { // 下载完成-进行安装
								console.log('下载status', d, status)
								// console.log("Download success: " + d.filename);
								this.show_update = false
								plus.runtime.install(d.filename, {
									force: true
								}, function() {
									plus.runtime.restart();
								}, function(e) {
									console.log(e)
									uni.hideLoading()
									plus.nativeUI.toast("安装失败");
								});
							} else {
								console.log("Download failed: " + status);
							}
						});
					 
						dtask.start();

进度
onProgress(task) { //  获取下载进度
				console.log('下载中onProgress');
				this.show_update = true
				task.addEventListener('statechanged', e => {
					console.log('下载中', e)
					if (e && e.downloadedSize > 0) {
						const progress = ((e.downloadedSize / e.totalSize) * 100).toFixed(0)
						console.log('下载中111', progress)
						this.progress = progress
					}

p判断版本号是否小于当前线上版本

复制代码
plus.runtime.getProperty(plus.runtime.appid, function (inf) {
				console.log('当前应用版本号:',  parseInt(inf.versionCode), parseInt(res.data.apkVersion),parseInt(inf.versionCode) < parseInt(res.data.apkVersion))
				if (parseInt(inf.versionCode) < parseInt(res.data.apkVersion)) {
					uModal.value.open()
					console.log(res,"参数--")
					userl.value=res.data.path
				}
			})
相关推荐
卸任9 分钟前
Vibe coding工具使用心得
前端·ai编程
wuxianda103043 分钟前
2026 苹果审核 4.3 (a) 被拒全解析|Guideline 4.3a spam 马甲包拒审原因 + 避坑方案
flutter·uni-app·苹果上架
brien91 小时前
为什么模型标称 1M,Google Antigravity 聊到 256K 却突然失忆?我们给它做了个原生行内监控圆环
前端
修炼的dance1 小时前
录屏关键帧间隔多少合适?六档实测,2秒到10秒小了75.6%
前端
Lank_M1 小时前
关键帧从1秒拉到10秒,录屏小87.3%,摄像头小10.8%
前端
补码缩写1 小时前
用 ffprobe 拆录屏,八成字节在 29 个关键帧上
前端
百思不得小李1 小时前
一个复杂的动态表单是如何实现的
前端·设计模式
陈随易2 小时前
Cmder 停更 17 个月,2.0 支持 Windows Terminal
前端·后端·程序员
清晨Coding2 小时前
删了 Cookie 还能自动登录?Google系网站登录态自动恢复的原理分析
javascript
风骏时光牛马2 小时前
前沿视界
前端