当前位置: 移动技术网 > IT编程>脚本编程>vue.js > uni-app的app打包过程

uni-app的app打包过程

2020年07月17日  | 移动技术网IT编程  | 我要评论

首先hbuilderX的版本与第一次android版本一致,否则更新失败
1.uni-app项目基础设置应用版本名称应用版本号一致,如果在app.vue中注释了app版本更新的方法在打包之前应该放开
在这里插入图片描述

checkAppVersion() {
	// #ifdef APP-PLUS
	var os_type = plus.os.name.toLowerCase();
	var app_version = plus.runtime.version;
	let _this = this;
	plus.runtime.getProperty(plus.runtime.appid, function(info) {
		uni.setStorageSync('VERSION',info.version);
		console.log(JSON.stringify(info));
		var res_version = info.version;
		var requestData = {
			os_type: os_type,
			app_version: app_version,
			res_version: res_version
		}
		_this.Util.postRequest('appVersion/getAppVersion', requestData).then(res => {
			var data = res.data;
			var app_version_db = data.appVersion;
			var res_version_db = data.resVersion;
			var app_url = data.appUrl;
			var res_url = data.resUrl;
			var app_version_desc = data.versionDesc;
			//大版本更新(涉及安卓壳子或ios壳子改动)
			console.log(JSON.stringify(data));
			console.log(app_version_db,'app_version_db')
			console.log(app_version,'app_version')
			if (app_version_db !== app_version) {
				uni.showModal({ //提醒用户更新  
					title: "更新提示",
					content: app_version_desc,
					showCancel:false,
					success: (res) => {
						if (res.confirm) {
							plus.runtime.openURL(app_url);
						}
					}
				})
			} else {
				//小版本更新(uniapp中的改动)
				console.log(res_version_db,'res_version_db')
				console.log(res_version,'res_version')
				if (res_version_db !== res_version) {
					uni.showLoading({
						title: '更新中...',
					});
					uni.downloadFile({
						url: res_url,
						success: (downloadResult) => {
							console.log(downloadResult,'downloadResult')
							if (downloadResult.statusCode === 200) {
								plus.runtime.install(downloadResult.tempFilePath, {
									force: true
								}, function() {
									console.log('install success...');
									uni.hideLoading();
									plus.runtime.restart();
								}, function(e) {
									uni.hideLoading();
									console.error(e,'install fail...');
								});
							}else{
								uni.hideLoading();
							}
						}
					});
				}
			}
		})
	});
	// #endif
},

2.使用hbuilderx发行原生App制作应用wgt包(成功后会在控制台将路径导出)
在这里插入图片描述
3.使用xftp替换服务器上的文件(删除服务器右边的文件,复制左边文件到右边)
在这里插入图片描述
4.在管理系统pc更改APP版本管理的资源包版本号(安卓与IOS)
之后就上线成功了。
注意:appID不能随便改动,如果修改了得换android的东西,还有项目配置

本文地址:https://blog.csdn.net/weixin_45423865/article/details/107383461

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网