Compare commits

...

1 Commits

Author SHA1 Message Date
scout 086a5fd1fa addhotLpload 1 week ago

@ -1,40 +1,89 @@
<script> <script>
export default { import silenceUpdate from '@/uni_modules/rt-uni-update/js_sdk/silence-update.js' //
methods:{ import config from './config';
networkStatusChange(res){ export default {
if(res.isConnected){ methods: {
uni.redirectTo({ networkStatusChange(res) {
url:'/pages/index/index' if (res.isConnected) {
}) uni.redirectTo({
}else{ url: "/pages/index/index",
uni.redirectTo({ });
url:'/pages/networko/index' } else {
}) uni.redirectTo({
} url: "/pages/networko/index",
});
} }
}, },
onLaunch: function() { //
}, getLocalVersion() {
onShow: function() { return new Promise((resolve, reject) => {
uni.getNetworkType({ plus.runtime.getProperty(plus.runtime.appid, function (widgetInfo) {
success:(res)=> { resolve(widgetInfo);
if(res.networkType==='none') { });
uni.redirectTo({ });
url: '/pages/networko/index' },
}) //
getServerVersion(widgetInfo) {
return new Promise((resolve, reject) => {
uni.request({
url: config.apiBaseUrl + "/version-info",
method:'POST',
data:{
edition_type:widgetInfo.appid,
version_type:uni.getSystemInfoSync().platform,
edition_number:Number(widgetInfo.versionCode)
},
success: (res) => {
console.log("res4", res.data.data);
resolve(res.data.data);
},
});
});
},
//
checkUpdate() {
//
this.getLocalVersion().then((widgetInfo) => {
console.log("本地信息", widgetInfo);
console.log("config", config);
this.getServerVersion(widgetInfo).then((serverVersionData) => {
if (Number(widgetInfo.versionCode) !== serverVersionData.edition_number) {
uni.navigateTo({
url:
"/uni_modules/rt-uni-update/components/rt-uni-update/rt-uni-update?obj=" +
JSON.stringify(serverVersionData),
});
} }
} });
}) });
uni.onNetworkStatusChange(this.networkStatusChange); },
}, },
onHide: function() { onLaunch: function () {},
uni.offNetworkStatusChange(this.networkStatusChange) onShow: function () {
} console.log("App 1onShow");
} this.checkUpdate();
// silenceUpdate('555')
// uni.navigateTo({
// url: "./uni_modules/rt-uni-update/components/rt-uni-update/rt-uni-update",
// });
uni.getNetworkType({
success: (res) => {
if (res.networkType === "none") {
uni.redirectTo({
url: "/pages/networko/index",
});
}
},
});
uni.onNetworkStatusChange(this.networkStatusChange);
},
onHide: function () {
uni.offNetworkStatusChange(this.networkStatusChange);
},
};
</script> </script>
<style> <style>
/*每个页面公共css */ /*每个页面公共css */
</style> </style>

@ -3,6 +3,7 @@ import App from './App'
// #ifndef VUE3 // #ifndef VUE3
import Vue from 'vue' import Vue from 'vue'
import './uni.promisify.adaptor' import './uni.promisify.adaptor'
Vue.config.productionTip = false Vue.config.productionTip = false
App.mpType = 'app' App.mpType = 'app'
const app = new Vue({ const app = new Vue({

@ -2,8 +2,8 @@
"name" : "oa考勤系统", "name" : "oa考勤系统",
"appid" : "__UNI__4796942", "appid" : "__UNI__4796942",
"description" : "", "description" : "",
"versionName" : "2.1.1", "versionName" : "2.1.4",
"versionCode" : 211, "versionCode" : 214,
"transformPx" : false, "transformPx" : false,
/* 5+App */ /* 5+App */
"app-plus" : { "app-plus" : {

@ -1,28 +1,42 @@
{ {
"pages": [ //pageshttps://uniapp.dcloud.io/collocation/pages "pages": [
{ //pageshttps://uniapp.dcloud.io/collocation/pages
"path": "pages/index/index", {
"style": { "path": "pages/index/index",
"navigationBarTitleText": "uni-app", "style": {
"navigationStyle": "custom" "navigationBarTitleText": "uni-app",
} "navigationStyle": "custom"
}, }
{ },
"path" : "pages/networko/index", {
"style" : "path": "pages/networko/index",
{ "style": {
"navigationBarTitleText": "uni-app", "navigationBarTitleText": "uni-app",
"navigationStyle": "custom" "navigationStyle": "custom"
} }
} },
{
], "path": "uni_modules/rt-uni-update/components/rt-uni-update/rt-uni-update",
"globalStyle": { "style": {
"navigationBarTextStyle": "black", "app-plus": {
"navigationBarTitleText": "uni-app", "animationDuration": 200,
"navigationBarBackgroundColor": "#F8F8F8", "animationType": "fade-in",
"backgroundColor": "#F8F8F8" "background": "transparent",
}, "backgroundColorTop": "transparent",
"uniIdRouter": {} "popGesture": "none",
"scrollIndicator": false,
"titleNView": false
},
"disableScroll": true
}
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "uni-app",
"navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8"
},
"uniIdRouter": {}
} }

@ -8,51 +8,51 @@ import {onExit } from "@dcloudio/uni-app";
import { Communication } from '../../utils/communication.js'; import { Communication } from '../../utils/communication.js';
const commun=new Communication() const commun=new Communication()
import { // import {
registerRequestPermissionTipsListener, // registerRequestPermissionTipsListener,
unregisterRequestPermissionTipsListener, // unregisterRequestPermissionTipsListener,
setRequestPermissionTips // setRequestPermissionTips
} from "@/uni_modules/uni-registerRequestPermissionTips" // } from "@/uni_modules/uni-registerRequestPermissionTips"
const PermissionTips = { // const PermissionTips = {
"android.permission.CAMERA": "<h4 style=\"font-size:40px;\">正在读取通讯录权限</h4><font color=#cccccc>通讯录权限不会获取任何信息,请注意</font>", // "android.permission.CAMERA": "<h4 style=\"font-size:40px;\"></h4><font color=#cccccc></font>",
"android.permission.READ_PHONE_STATE": "<h4 style=\"font-size:40px;\">正在读取网络状态权限</h4><font color=#cccccc>通讯录权限不会获取任何信息,请注意通讯录权限不会获取任何信息,请注意通讯录权限不会获取任何信息,请注意</font>" // "android.permission.READ_PHONE_STATE": "<h4 style=\"font-size:40px;\"></h4><font color=#cccccc></font>"
} // }
onExit(()=>{ // onExit(()=>{
unregisterRequestPermissionTipsListener() // unregisterRequestPermissionTipsListener()
}) // })
const brand = uni.getSystemInfoSync().deviceBrand // const brand = uni.getSystemInfoSync().deviceBrand
setRequestPermissionTips(PermissionTips) // setRequestPermissionTips(PermissionTips)
registerRequestPermissionTipsListener({ // registerRequestPermissionTipsListener({
onRequest: (e) => { // onRequest: (e) => {
console.log('onRequest',e) // console.log('onRequest',e)
}, // },
onConfirm: (e) => { // onConfirm: (e) => {
commun.sendToH5('permission-application',{action:'open-permission',data:e}); // commun.sendToH5('permission-application',{action:'open-permission',data:e});
}, // },
onComplete: (e) => { // onComplete: (e) => {
commun.sendToH5('permission-application',{action:'close-permission',data:e}); // commun.sendToH5('permission-application',{action:'close-permission',data:e});
// // //
if (brand.toLowerCase() === "huawei") { // if (brand.toLowerCase() === "huawei") {
const tips = {} // const tips = {}
let hasDeniedPermission = false // let hasDeniedPermission = false
for (let k in PermissionTips) { // for (let k in PermissionTips) {
if (e[k] !== "denied") { // if (e[k] !== "denied") {
tips[k] = PermissionTips[k] // tips[k] = PermissionTips[k]
} else { // } else {
hasDeniedPermission = true // hasDeniedPermission = true
} // }
} // }
setRequestPermissionTips(tips) // // setRequestPermissionTips(tips) //
if (hasDeniedPermission) // if (hasDeniedPermission)
uni.showModal({ // uni.showModal({
content: "权限已经被拒绝,请前往设置中开启" // content: ""
}) // })
} // }
} // }
}) // })
function initializeWebView() { function initializeWebView() {
const currentWebview = getCurrentPages().pop().$getAppWebview() const currentWebview = getCurrentPages().pop().$getAppWebview()
commun.setWebView(currentWebview.children()[0]) commun.setWebView(currentWebview.children()[0])

@ -0,0 +1,97 @@
## 1.5.22023-09-08
优化文档
## 1.5.12023-05-26
优化文档
## 1.5.02023-05-23
优化文档
## 1.4.92023-05-23
文档新增后台版本管理示例图
## 1.4.82023-05-23
优化当前版本显示
## 1.4.72023-05-23
新增当前运行版本名称和新版本名称显示
## 1.4.62023-05-22
新增显示安装包大小
## 1.4.52023-04-27
优化页面不透明
## 1.4.42023-04-25
新增pages_init.json自动注册页面
## 1.4.32023-04-25
修改app下载链接
## 1.4.22023-04-25
优化
## 1.4.12023-04-15
优化bug
## 1.4.02023-04-14
删除无用代码
## 1.3.92023-04-14
优化
## 1.3.82023-04-03
优化文档
## 1.3.72023-03-23
优化文档
## 1.3.62023-03-23
优化文档
## 1.3.52023-03-08
新增常见问题
## 1.3.42023-03-07
解决应用切换到后台再次打开更新弹窗叠加多个的问题
## 1.3.32023-03-02
优化提示文档
## 1.3.22023-02-02
优化部分wgt包无法安装的提示
## 1.3.12023-01-12
修改示例下载文件地址
## 1.3.02022-11-17
兼容低版本安卓手机,用户拒绝安装后,去掉自动重启,优化体验
## 1.2.92022-11-14
优化插件
## 1.2.82022-11-14
优化整包更新用户体验
## 1.2.72022-11-14
修复apk整包更新时点击拒绝安装更新进度还在的bug
## 1.2.62022-10-17
优化问题汇总
## 1.2.52022-10-17
常见问题优化
## 1.2.42022-09-21
文档新增常见问题汇总,方便更快的解决问题
## 1.2.32022-09-21
文档新增常见问题汇总,方便更快的解决问题
## 1.2.22022-09-21
文档新增常见问题汇总,方便更快的解决问题
## 1.2.12022-09-21
文档新增常见问题汇总,方便更快的解决问题
## 1.2.02022-08-03
优化插件wgt升级重启整包升级不重启
## 1.1.92022-08-01
新增弹出一个合并页面路由的pages.json修改界面。插件使用者点击确认按钮即可完成插件页面向项目pages.json的注册。HBuilderX 3.5.0+支持
## 1.1.82022-07-25
1、静默更新后提示用户重启应用以解决样式错乱的问题
2、跳转应用市场下载后解决更新提示弹窗一直叠加的问题
## 1.1.72022-07-22
优化示例代码
## 1.1.62022-07-22
优化文档
## 1.1.52022-07-19
优化文档
## 1.1.42022-07-19
优化文档
## 1.1.32022-07-19
优化文档
## 1.1.22022-07-18
优化wgt更新文档
## 1.1.12022-07-17
新增wgt包静默更新
## 1.1.02022-05-17
优化readme文档
## 1.0.92022-05-14
优化
## 1.0.82022-05-05
修复图片不显示的bug
## 1.0.72022-01-19
1.0.7 优化readme文档
## 1.0.62022-01-19
正式支持uni_modules
## 1.0.52022-01-19
测试支持uni_models

@ -0,0 +1,303 @@
<template>
<view class="update-mask flex-center">
<view class="content botton-radius">
<view class="content-top">
<view class="content-top-text">
<text class="">发现新版本 v{{data.edition_name}}</text>
<text class="version">当前版本{{version}}</text>
</view>
<image class="content-top" style="top: 0;" width="100%" height="100%" src="/uni_modules/rt-uni-update/static/bg_top.png"></image>
</view>
<view class="content-header"></view>
<view class="content-body">
<view class="title"><text>更新内容</text></view>
<view class="body">
<scroll-view class="box-des-scroll" scroll-y="true"><rich-text :nodes="data.describe"></rich-text></scroll-view>
</view>
<view class="footer flex-center">
<view class="progress-box flex-column" v-if="!updateBtn">
<progress class="progress" border-radius="35" :percent="percent" activeColor="#3DA7FF" show-info stroke-width="10" />
<!-- <u-line-progress :striped="true" :percent="percent" :striped-active="true"></u-line-progress> -->
<view><text class="fs24">正在下载请稍后 ({{downloadedSize}}/{{packageFileSize}}M)</text></view>
</view>
<button class="content-button" style="border: none;color: #fff;" plain @click="confirm" v-if="updateBtn"></button>
</view>
</view>
<image v-if="cancleBtn" class="close-img" src="/uni_modules/rt-uni-update/static/app_update_close.png" @click.stop="cancel"></image>
</view>
</view>
</template>
<script>
export default {
data() {
return {
version:'1.0.0',//(manifest)
percent: 0, //
updateBtn: true, //
cancleBtn: false, //
downloadedSize:0,//
packageFileSize:0,//
data: {
describe: '1. 修复已知问题<br>2. 优化用户体验',
edition_url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-6bef1fe3-e3e3-4909-9f0c-6ed9bd11c93b/aae2360a-6628-4c93-b873-ce1600b9a852.apk', //
edition_force: 1, // 0 1
package_type: 0 ,//0 1wgt
edition_name:'1.0.1' //
}
};
},
onHide() { //
// console.log('');
this.data.edition_force = 0;
uni.navigateBack({
delta: 1
})
},
onLoad({obj}) {
this.data = JSON.parse(obj);
if (this.data.edition_force == 0) {
this.cancleBtn = true;
}
plus.runtime.getProperty(plus.runtime.appid,(inf) => {
this.version = inf.version;
})
},
onBackPress() {
//
if (this.data.edition_force == 1) {
return true;
}
},
methods: {
cancel() {
//
uni.navigateBack({
delta: 1
});
},
confirm() {
if (this.data.package_type == 0) {
//apk .apk
if (this.data.edition_url.includes('.apk')) {
this.updateBtn = false;
this.cancleBtn = false;
this.download();
} else {
// h5
this.data.edition_force = 0; //
plus.runtime.openURL(this.data.edition_url);
uni.navigateBack({
delta: 1
});
}
} else {
this.updateBtn = false;
this.cancleBtn = false;
//wgt .wgt
this.download();
}
},
download() {
let package_type = this.data.package_type;
let that = this;
const downloadTask = uni.downloadFile({
url: this.data.edition_url,
success: res => {
if (res.statusCode === 200) {
plus.runtime.install(
res.tempFilePath,
{
force: true //truefalse
},
function() {
// console.log('success', success);
if (package_type == 1) {
plus.runtime.restart();
}
},
function(e) {
//wgt
that.data.edition_force = 0;
uni.showToast({
title:e.message,
icon:'none',
duration:2500
})
setTimeout(()=>{
uni.navigateBack()
},2000)
}
);
if (package_type == 0) {
// app
this.data.edition_force = 0;
uni.navigateBack();
}
}
}
});
//
downloadTask.onProgressUpdate(res => {
this.percent = res.progress;
this.downloadedSize = (res.totalBytesWritten / Math.pow(1024, 2)).toFixed(2);
this.packageFileSize = (res.totalBytesExpectedToWrite / Math.pow(1024, 2)).toFixed(2);
});
}
}
};
</script>
<style>
page {
background: transparent;
}
.flex-center {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
align-items: center;
}
.update-mask {
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.65);
}
.botton-radius {
border-bottom-left-radius: 30rpx;
border-bottom-right-radius: 30rpx;
}
.content {
position: relative;
top: 0;
width: 600rpx;
background-color: #fff;
box-sizing: border-box;
padding: 0 50rpx;
font-family: Source Han Sans CN;
}
.text {
/* #ifndef APP-NVUE */
display: block;
/* #endif */
line-height: 200px;
text-align: center;
color: #ffffff;
}
.content-top {
position: absolute;
top: -195rpx;
left: 0;
width: 600rpx;
height: 270rpx;
}
.content-top-text {
font-size: 40rpx;
font-weight: bold;
color: #f8f8fa;
position: absolute;
top: 120rpx;
left: 50rpx;
z-index: 1;
display: flex;
flex-direction: column;
}
.content-header {
height: 70rpx;
}
.title {
font-size: 33rpx;
font-weight: bold;
color: #3da7ff;
line-height: 38px;
}
.footer {
height: 150rpx;
display: flex;
align-items: center;
justify-content: space-around;
}
.box-des-scroll {
box-sizing: border-box;
padding: 0 40rpx;
text-align: left;
}
.box-des {
font-size: 26rpx;
color: #000000;
line-height: 50rpx;
}
.progress-box {
width: 100%;
}
.progress {
width: 83%;
height: 40rpx;
border-radius: 35px;
}
.close-img {
width: 70rpx;
height: 70rpx;
z-index: 1000;
position: absolute;
bottom: -120rpx;
left: calc(50% - 70rpx / 2);
}
.content-button {
text-align: center;
flex: 1;
font-size: 30rpx;
font-weight: 400;
color: #ffffff;
border-radius: 40rpx;
margin: 0 18rpx;
height: 80rpx;
line-height: 80rpx;
background: linear-gradient(to right, #1785ff, #3da7ff);
}
.flex-column {
display: flex;
flex-direction: column;
align-items: center;
}
.fs24{
font-size: 24rpx;
}
.version{
font-size: 24rpx;
margin-top: 10rpx;
color: #eeeeee;
text-decoration: underline;
}
</style>

@ -0,0 +1,31 @@
export default function silenceUpdate(url) {
uni.downloadFile({
url,
success: res => {
if (res.statusCode === 200) {
plus.runtime.install(
res.tempFilePath, {
force: true //true表示强制安装不进行版本号的校验false则需要版本号校验
},
function() {
uni.showModal({
title: '更新提示',
content: '新版本已经准备好,请重启应用',
showCancel: false,
success: function(res) {
if (res.confirm) {
// console.log('用户点击确定');
plus.runtime.restart()
}
}
});
// console.log('install success...');
},
function(e) {
console.error('install fail...');
}
);
}
}
});
}

@ -0,0 +1,80 @@
{
"id": "rt-uni-update",
"displayName": "app升级整包更新和热更新支持vue3 支持打开安卓、苹果市场wgt静默更新",
"version": "1.5.2",
"description": "app升级、整包更新和热更新组件 支持vue3 支持打开安卓、苹果应用市场支持wgt静默更新无感知支持覆盖原生tabar原生导航栏",
"keywords": [
"整包更新",
"热更新",
"vue3",
"静默更新",
"app更新升级"
],
"repository": "",
"engines": {
},
"dcloudext": {
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "无"
},
"npmurl": "",
"type": "component-vue"
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y"
},
"client": {
"Vue": {
"vue2": "y",
"vue3": "y"
},
"App": {
"app-vue": "y",
"app-nvue": "y"
},
"H5-mobile": {
"Safari": "u",
"Android Browser": "u",
"微信浏览器(Android)": "u",
"QQ浏览器(Android)": "u"
},
"H5-pc": {
"Chrome": "u",
"IE": "u",
"Edge": "u",
"Firefox": "u",
"Safari": "u"
},
"小程序": {
"微信": "u",
"阿里": "u",
"百度": "u",
"字节跳动": "u",
"QQ": "u"
},
"快应用": {
"华为": "u",
"联盟": "u"
}
}
}
}
}

@ -0,0 +1,192 @@
## 整包更新和热更新组件 支持vue3 支持打开安卓、苹果应用市场支持wgt静默更新
- ui图是采用uniapp官方更新组件的ui如不满足需要可自行替换
- 一键式检查更新同时支持整包升级与wgt资源包更新 支持打开安卓自带的应用市场和苹果appstore
- 好看、实用、可自定义的客户端提示框
- 支持强制更新,无法退出
- 支持静默更新,下次启动后更新的内容自动生效
- 支持覆盖原生tabar原生导航栏
## 安装指引
1. 在插件市场打开本插件页面,在右侧点击`使用 HBuilderX 导入插件`选择要导入的项目点击确定建议使用uni_modules版本 非uni_modules版本不在维护有需要自行修改
2. 在`pages.json`中添加页面路径。注意一定不要设置为pages.json中第一项在1.1.9版本新增弹出一个合并页面路由的pages.json修改界面。点击确认按钮即可完成插件页面向项目pages.json的注册。HBuilderX 3.5.0+支持,无需手动添加)
```
"pages": [
// ……其他页面配置
{
"path": "uni_modules/rt-uni-update/components/rt-uni-update/rt-uni-update",
"style": {
"disableScroll": true,
"app-plus": {
"backgroundColorTop": "transparent",
"background": "transparent",
"titleNView": false,
"scrollIndicator": false,
"popGesture": "none",
"animationType": "fade-in",
"animationDuration": 200
}
}
}
]
```
3. 查看显示效果 (注意:这里只是查看显示效果,具体代码需要按照下面的项目使用说明编写)
```
// App.vue的onShow中查看效果 如果无法跳转 请在`pages.json`中添加页面路径,参照第二步
uni.navigateTo({
url: '/uni_modules/rt-uni-update/components/rt-uni-update/rt-uni-update'
});
```
## 前言一般来说后台都需要有一个app的版本管理系统可参考下图
![app的版本管理系统](https://img-cdn-aliyun.dcloud.net.cn/stream/plugin_screens/d7898110-7905-11ec-a3c8-0f6ace22f6cc_3.png?image_process=quality,q_70/format,webp&v=1684809490)
![app的版本管理系统](https://img-cdn-aliyun.dcloud.net.cn/stream/plugin_screens/d7898110-7905-11ec-a3c8-0f6ace22f6cc_4.png?image_process=quality,q_70/format,webp&v=1684809494)
## 项目使用说明 最重要!!!
- 注意!!!后端返回数据要求 字段如下 (如果后端字段不一样,请在跳转更新页时手动赋值,示例见下面代码)
```
data:{
// 版本更新内容 支持<br>自动换行
describe: '1. 修复已知问题<br>
2. 优化用户体验',
edition_url: '', //apk、wgt包下载地址或者应用市场地址 安卓应用市场 market://details?id=xxxx 苹果store itms-apps://itunes.apple.com/cn/app/xxxxxx
edition_force: 0, //是否强制更新 0代表否 1代表是
package_type: 1, //0是整包升级apk或者appstore或者安卓应用市场 1是wgt升级
edition_issue:1, //是否发行 0否 1是 为了控制上架应用市场审核时不能弹出热更新框
edition_number:100, //版本号 最重要的manifest里的版本号 检查更新主要以服务器返回的edition_number版本号是否大于当前app的版本号来实现是否更新
edition_name:'1.0.0',// 版本名称 manifest里的版本名称
edition_silence:0, // 是否静默更新 0代表否 1代表是
}
// 如果后端返回的字段和上面不一致,请在前端手动赋值(示例)
data.edition_url = res.data.editionUrl
data.edition_force = res.data.editionForce
data.package_type = res.data.packageType
data.xxx = res.data.xxx
```
## 后端注意!!!
edition_number传这个参数是为了解决部分用户app长期不使用第一次打开服务器查到的版本是最新的是wgt包但是之前app有过整包更新如果直接更新最新wgt的话会出现以前的整包添加的原生模块或者安卓权限无法使用所以后端查询版本必须返回大于当前edition_number版本的最新的整包apk地址或者是应用市场地址如果没有大于edition_number的整包就返回最新的wgt包地址就行。
- 前端示例代码 或者根据实际业务修改 如果需要自动检测新版本建议写在App.vue的onShow中
```
import silenceUpdate from '@/uni_modules/rt-uni-update/js_sdk/silence-update.js' //引入静默更新
//#ifdef APP-PLUS
// 获取本地应用资源版本号
plus.runtime.getProperty(plus.runtime.appid, (inf) => {
//获取服务器的版本号
uni.request({
url: 'http://127.0.0.1:8088/edition_manage/get_edition', //示例接口
data: {
edition_type: plus.runtime.appid,
version_type: uni.getSystemInfoSync().platform, //android或者ios
edition_number: inf.versionCode // 打包时manifest设置的版本号
},
success: (res) => {
//res.data.xxx根据后台返回的数据决定我这里后端返回的是data所以是res.data.data
//判断后台返回版本号是否大于当前应用版本号 && 是否发行 (上架应用市场时一定不能弹出更新提示)
if (Number(res.data.data.edition_number) > Number(inf.versionCode) && res
.data.data.edition_issue == 1) {
//如果是wgt升级并且是静默更新 (注意!!! 如果是手动检查新版本,就不用判断静默更新,请直接跳转更新页,不然点击检查新版本后会没反应)
if (res.data.data.package_type == 1 && res.data.data.edition_silence == 1) {
//调用静默更新方法 传入下载地址
silenceUpdate(res.data.data.edition_url)
} else {
//跳转更新页面 注意如果pages.json第一页的代码里有一打开就跳转其他页面的操作下面这行代码最好写在setTimeout里面设置延时3到5秒再执行
uni.navigateTo({
url: '/uni_modules/rt-uni-update/components/rt-uni-update/rt-uni-update?obj=' +
JSON.stringify(res.data.data)
});
}
} else {
// 如果是手动检查新版本 需开启以下注释
/* uni.showModal({
title: '提示',
content: '已是最新版本',
showCancel: false
}) */
}
}
})
});
//#endif
```
# 常见问题汇总!!!
# 热更新制作wgt包的方法1、修改manifest.json版本名称和版本号必须大于当前版本。2、点击菜单的发行——原生App-制作应用wgt包
# app上传地址个人建议开通unicloud的阿里云按量付费方便、便宜apk或者wgt包直接上传到云存储就行。
## 1、调试请打包自定义基座测试否则uni.getSystemInfoSync().platform获取到的可能不是android或者ios会导致无法跳转更新页
## 2、进度条不显示但可以正常安装原因99%的情况是因为下载链接为内网链接,内网链接无法监听下载进度,请更换为外网链接
## 3、进度条显示下载apk完成后安卓不会自动弹出安装页面原因可能是离线打包未添加安卓安装权限请添加以下权限或者使用云打包
```
<uses-permission android:name="android.permission.INSTALL_PACKAGES" />
```
```
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
```
## 4、在app.vue中无法跳转到更新页原因第一、在pages.json中忘记注册页面第二、如果已经注册过页面一般在app.vue或者首页中会有默认跳转所以影响到了跳转更新页解决办法修改跳转逻辑或者在跳转更新页时加setTimeout延时几秒在跳转
## 5、app内下载apk时会跳转外部下载原因安卓apk下载链接必须为.apk结尾如果不是.apk结尾就会跳转外部下载比如应用市场链接
## 6、热更新时wgt包可以下载但是无法安装控制台提示wgt/wgtu文件格式错误。解决方法下载地址必须为http://xxxxxx.wgt的格式就是链接必须以.wgt结尾。2、如果地址是http://xxxxxx.wgt格式请在浏览器打开这个下载地址如果无法自动下载一般可能都是后端下载权限的问题导致的
## 7、整包更新/热更新成功后还是一直弹更新弹窗原因是打wgt包时未修改manifest.json的版本号请修改版本号后上传服务器后重试。
## 8、苹果支持appstore链接和wgt更新不支持整包ipa更新。
## 9、wgt更新进度条100%苹果无法安装原因1、wgt包名不要设置为中文2、增加原生模块必须上传appstore不能热更新
## 10、不能热更新的有1、如果原项目没有nvue页面新增nvue后也必须整包更新2、增加推送、第三方登录、地图、视频播放、支付等模块或者其他安卓权限。3、修改启动图或者app图标
## 11、更新弹窗后面的页面一半儿白屏[官方的bug](https://ask.dcloud.net.cn/question/164141)
## 12、跳转更新页后无法获取参数可能是使用了uni-simple-router等第三方路由插件解决办法通过eventChannel.$emit等方式传参在插件里接收赋值
有鼓励,更有动力,如果您认为这个插件帮到了您的开发工作,麻烦给个五星好评鼓励一下,有能力的也可以小小赞赏一下,感谢支持。
<img src="https://mp-bed742be-5cd0-413d-b7a5-c1bdcda83cd2.cdn.bspapp.com/rookie-ui/34afc1f2862e7579c3cbdd33d23d0de.jpg" width="220" >
<img style="margin-left: 100px;" src="https://mp-bed742be-5cd0-413d-b7a5-c1bdcda83cd2.cdn.bspapp.com/rookie-ui/e14de964c6d89008035f651be6fa2c8.jpg" width="220" >
## 如有问题请加qq 965969604

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Loading…
Cancel
Save