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
				}
			})
相关推荐
Flynt1 小时前
AI 生成的界面,能放心点吗?我把 Google A2UI 的三层防线拆开测了一遍
前端·google·agent
前端混子2 小时前
我用 AI 做了个「禾月小历」,一套代码跑微信小程序和 H5
前端
IT_陈寒3 小时前
Java实战技巧总结:当你的finally块没有执行时会发生什么?
前端·人工智能·后端
小帅不太帅3 小时前
一年一次黑五,为了买软件真省钱,我做了个开源小站
前端·人工智能·github
JavaGuide5 小时前
刚刚,阿里版 Codex 上线了匿名模型 HungerG,无限 Token!
前端·后端
zhanlang02175 小时前
HTML 零基础入门到企业实战全套教程【第九章 9.3】移动端 HTML 基础适配入门
前端·html
用户69371750013845 小时前
AI 帮我写了大半年的代码,我却越来越不会写代码了
前端·后端·github
skywalk81635 小时前
把「假成功」赶出工具层:lightharness 两天升级复盘(4×5 模式矩阵 + 工具层 5 个缺陷)
开发语言·前端·人工智能·lightharness
彭亚川Allen6 小时前
从零手搓 RAG:用 Elasticsearch 存储与检索向量
前端·后端·面试
jerrywus6 小时前
15 个可以直接安装的 AI Agent Skills:按场景挑
前端·agent·claude