addhotLpload
This commit is contained in:
parent
3290739625
commit
086a5fd1fa
115
App.vue
115
App.vue
@ -1,40 +1,89 @@
|
||||
<script>
|
||||
export default {
|
||||
methods:{
|
||||
networkStatusChange(res){
|
||||
if(res.isConnected){
|
||||
uni.redirectTo({
|
||||
url:'/pages/index/index'
|
||||
})
|
||||
}else{
|
||||
uni.redirectTo({
|
||||
url:'/pages/networko/index'
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
onLaunch: function() {
|
||||
},
|
||||
onShow: function() {
|
||||
uni.getNetworkType({
|
||||
success:(res)=> {
|
||||
if(res.networkType==='none') {
|
||||
uni.redirectTo({
|
||||
url: '/pages/networko/index'
|
||||
})
|
||||
import silenceUpdate from '@/uni_modules/rt-uni-update/js_sdk/silence-update.js' //引入静默更新
|
||||
import config from './config';
|
||||
export default {
|
||||
methods: {
|
||||
networkStatusChange(res) {
|
||||
if (res.isConnected) {
|
||||
uni.redirectTo({
|
||||
url: "/pages/index/index",
|
||||
});
|
||||
} else {
|
||||
uni.redirectTo({
|
||||
url: "/pages/networko/index",
|
||||
});
|
||||
}
|
||||
},
|
||||
// 获取本地应用资源版本号
|
||||
getLocalVersion() {
|
||||
return new Promise((resolve, reject) => {
|
||||
plus.runtime.getProperty(plus.runtime.appid, function (widgetInfo) {
|
||||
resolve(widgetInfo);
|
||||
});
|
||||
});
|
||||
},
|
||||
// 获取服务端应用资源版本号
|
||||
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() {
|
||||
uni.offNetworkStatusChange(this.networkStatusChange)
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
onLaunch: function () {},
|
||||
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>
|
||||
|
||||
<style>
|
||||
/*每个页面公共css */
|
||||
/*每个页面公共css */
|
||||
</style>
|
||||
|
1
main.js
1
main.js
@ -3,6 +3,7 @@ import App from './App'
|
||||
// #ifndef VUE3
|
||||
import Vue from 'vue'
|
||||
import './uni.promisify.adaptor'
|
||||
|
||||
Vue.config.productionTip = false
|
||||
App.mpType = 'app'
|
||||
const app = new Vue({
|
||||
|
@ -2,8 +2,8 @@
|
||||
"name" : "oa考勤系统",
|
||||
"appid" : "__UNI__4796942",
|
||||
"description" : "",
|
||||
"versionName" : "2.1.1",
|
||||
"versionCode" : 211,
|
||||
"versionName" : "2.1.4",
|
||||
"versionCode" : 214,
|
||||
"transformPx" : false,
|
||||
/* 5+App特有相关 */
|
||||
"app-plus" : {
|
||||
|
1
package.json
Normal file
1
package.json
Normal file
@ -0,0 +1 @@
|
||||
{}
|
64
pages.json
64
pages.json
@ -1,28 +1,42 @@
|
||||
{
|
||||
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
|
||||
{
|
||||
"path": "pages/index/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "uni-app",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "pages/networko/index",
|
||||
"style" :
|
||||
{
|
||||
"navigationBarTitleText": "uni-app",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
}
|
||||
"pages": [
|
||||
//pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
|
||||
{
|
||||
"path": "pages/index/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "uni-app",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/networko/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "uni-app",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
],
|
||||
"globalStyle": {
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "uni-app",
|
||||
"navigationBarBackgroundColor": "#F8F8F8",
|
||||
"backgroundColor": "#F8F8F8"
|
||||
},
|
||||
"uniIdRouter": {}
|
||||
{
|
||||
"path": "uni_modules/rt-uni-update/components/rt-uni-update/rt-uni-update",
|
||||
"style": {
|
||||
"app-plus": {
|
||||
"animationDuration": 200,
|
||||
"animationType": "fade-in",
|
||||
"background": "transparent",
|
||||
"backgroundColorTop": "transparent",
|
||||
"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';
|
||||
const commun=new Communication()
|
||||
|
||||
import {
|
||||
registerRequestPermissionTipsListener,
|
||||
unregisterRequestPermissionTipsListener,
|
||||
setRequestPermissionTips
|
||||
} from "@/uni_modules/uni-registerRequestPermissionTips"
|
||||
// import {
|
||||
// registerRequestPermissionTipsListener,
|
||||
// unregisterRequestPermissionTipsListener,
|
||||
// setRequestPermissionTips
|
||||
// } from "@/uni_modules/uni-registerRequestPermissionTips"
|
||||
|
||||
const PermissionTips = {
|
||||
"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>"
|
||||
}
|
||||
onExit(()=>{
|
||||
unregisterRequestPermissionTipsListener()
|
||||
})
|
||||
// const PermissionTips = {
|
||||
// "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>"
|
||||
// }
|
||||
// onExit(()=>{
|
||||
// unregisterRequestPermissionTipsListener()
|
||||
// })
|
||||
|
||||
const brand = uni.getSystemInfoSync().deviceBrand
|
||||
setRequestPermissionTips(PermissionTips)
|
||||
registerRequestPermissionTipsListener({
|
||||
onRequest: (e) => {
|
||||
console.log('onRequest',e)
|
||||
},
|
||||
onConfirm: (e) => {
|
||||
commun.sendToH5('permission-application',{action:'open-permission',data:e});
|
||||
},
|
||||
onComplete: (e) => {
|
||||
commun.sendToH5('permission-application',{action:'close-permission',data:e});
|
||||
// const brand = uni.getSystemInfoSync().deviceBrand
|
||||
// setRequestPermissionTips(PermissionTips)
|
||||
// registerRequestPermissionTipsListener({
|
||||
// onRequest: (e) => {
|
||||
// console.log('onRequest',e)
|
||||
// },
|
||||
// onConfirm: (e) => {
|
||||
// commun.sendToH5('permission-application',{action:'open-permission',data:e});
|
||||
// },
|
||||
// onComplete: (e) => {
|
||||
// commun.sendToH5('permission-application',{action:'close-permission',data:e});
|
||||
|
||||
// 华为手机在权限禁止之后,再次申请权限不会出现权限申请框。此时应该引导用户去系统设置开启此权限,不应该频繁申请。
|
||||
if (brand.toLowerCase() === "huawei") {
|
||||
const tips = {}
|
||||
let hasDeniedPermission = false
|
||||
for (let k in PermissionTips) {
|
||||
if (e[k] !== "denied") {
|
||||
tips[k] = PermissionTips[k]
|
||||
} else {
|
||||
hasDeniedPermission = true
|
||||
}
|
||||
}
|
||||
setRequestPermissionTips(tips) // 更新弹框提醒,防止华为手机不出现权限申请框时权限提醒框闪烁的情况
|
||||
if (hasDeniedPermission)
|
||||
uni.showModal({
|
||||
content: "权限已经被拒绝,请前往设置中开启"
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
// // 华为手机在权限禁止之后,再次申请权限不会出现权限申请框。此时应该引导用户去系统设置开启此权限,不应该频繁申请。
|
||||
// if (brand.toLowerCase() === "huawei") {
|
||||
// const tips = {}
|
||||
// let hasDeniedPermission = false
|
||||
// for (let k in PermissionTips) {
|
||||
// if (e[k] !== "denied") {
|
||||
// tips[k] = PermissionTips[k]
|
||||
// } else {
|
||||
// hasDeniedPermission = true
|
||||
// }
|
||||
// }
|
||||
// setRequestPermissionTips(tips) // 更新弹框提醒,防止华为手机不出现权限申请框时权限提醒框闪烁的情况
|
||||
// if (hasDeniedPermission)
|
||||
// uni.showModal({
|
||||
// content: "权限已经被拒绝,请前往设置中开启"
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
function initializeWebView() {
|
||||
const currentWebview = getCurrentPages().pop().$getAppWebview()
|
||||
commun.setWebView(currentWebview.children()[0])
|
||||
|
97
uni_modules/rt-uni-update/changelog.md
Normal file
97
uni_modules/rt-uni-update/changelog.md
Normal file
@ -0,0 +1,97 @@
|
||||
## 1.5.2(2023-09-08)
|
||||
优化文档
|
||||
## 1.5.1(2023-05-26)
|
||||
优化文档
|
||||
## 1.5.0(2023-05-23)
|
||||
优化文档
|
||||
## 1.4.9(2023-05-23)
|
||||
文档新增后台版本管理示例图
|
||||
## 1.4.8(2023-05-23)
|
||||
优化当前版本显示
|
||||
## 1.4.7(2023-05-23)
|
||||
新增当前运行版本名称和新版本名称显示
|
||||
## 1.4.6(2023-05-22)
|
||||
新增显示安装包大小
|
||||
## 1.4.5(2023-04-27)
|
||||
优化页面不透明
|
||||
## 1.4.4(2023-04-25)
|
||||
新增pages_init.json自动注册页面
|
||||
## 1.4.3(2023-04-25)
|
||||
修改app下载链接
|
||||
## 1.4.2(2023-04-25)
|
||||
优化
|
||||
## 1.4.1(2023-04-15)
|
||||
优化bug
|
||||
## 1.4.0(2023-04-14)
|
||||
删除无用代码
|
||||
## 1.3.9(2023-04-14)
|
||||
优化
|
||||
## 1.3.8(2023-04-03)
|
||||
优化文档
|
||||
## 1.3.7(2023-03-23)
|
||||
优化文档
|
||||
## 1.3.6(2023-03-23)
|
||||
优化文档
|
||||
## 1.3.5(2023-03-08)
|
||||
新增常见问题
|
||||
## 1.3.4(2023-03-07)
|
||||
解决应用切换到后台再次打开更新弹窗叠加多个的问题
|
||||
## 1.3.3(2023-03-02)
|
||||
优化提示文档
|
||||
## 1.3.2(2023-02-02)
|
||||
优化部分wgt包无法安装的提示
|
||||
## 1.3.1(2023-01-12)
|
||||
修改示例下载文件地址
|
||||
## 1.3.0(2022-11-17)
|
||||
兼容低版本安卓手机,用户拒绝安装后,去掉自动重启,优化体验
|
||||
## 1.2.9(2022-11-14)
|
||||
优化插件
|
||||
## 1.2.8(2022-11-14)
|
||||
优化整包更新用户体验
|
||||
## 1.2.7(2022-11-14)
|
||||
修复apk整包更新时,点击拒绝安装,更新进度还在的bug
|
||||
## 1.2.6(2022-10-17)
|
||||
优化问题汇总
|
||||
## 1.2.5(2022-10-17)
|
||||
常见问题优化
|
||||
## 1.2.4(2022-09-21)
|
||||
文档新增常见问题汇总,方便更快的解决问题
|
||||
## 1.2.3(2022-09-21)
|
||||
文档新增常见问题汇总,方便更快的解决问题
|
||||
## 1.2.2(2022-09-21)
|
||||
文档新增常见问题汇总,方便更快的解决问题
|
||||
## 1.2.1(2022-09-21)
|
||||
文档新增常见问题汇总,方便更快的解决问题
|
||||
## 1.2.0(2022-08-03)
|
||||
优化插件,wgt升级重启,整包升级不重启
|
||||
## 1.1.9(2022-08-01)
|
||||
新增弹出一个合并页面路由的pages.json修改界面。插件使用者点击确认按钮即可完成插件页面向项目pages.json的注册。HBuilderX 3.5.0+支持
|
||||
## 1.1.8(2022-07-25)
|
||||
1、静默更新后提示用户重启应用,以解决样式错乱的问题
|
||||
2、跳转应用市场下载后,解决更新提示弹窗一直叠加的问题
|
||||
## 1.1.7(2022-07-22)
|
||||
优化示例代码
|
||||
## 1.1.6(2022-07-22)
|
||||
优化文档
|
||||
## 1.1.5(2022-07-19)
|
||||
优化文档
|
||||
## 1.1.4(2022-07-19)
|
||||
优化文档
|
||||
## 1.1.3(2022-07-19)
|
||||
优化文档
|
||||
## 1.1.2(2022-07-18)
|
||||
优化wgt更新文档
|
||||
## 1.1.1(2022-07-17)
|
||||
新增wgt包静默更新
|
||||
## 1.1.0(2022-05-17)
|
||||
优化readme文档
|
||||
## 1.0.9(2022-05-14)
|
||||
优化
|
||||
## 1.0.8(2022-05-05)
|
||||
修复图片不显示的bug
|
||||
## 1.0.7(2022-01-19)
|
||||
1.0.7 优化readme文档
|
||||
## 1.0.6(2022-01-19)
|
||||
正式支持uni_modules
|
||||
## 1.0.5(2022-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是整包升级 1是wgt升级
|
||||
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 //true表示强制安装,不进行版本号的校验;false则需要版本号校验,
|
||||
},
|
||||
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>
|
31
uni_modules/rt-uni-update/js_sdk/silence-update.js
Normal file
31
uni_modules/rt-uni-update/js_sdk/silence-update.js
Normal file
@ -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...');
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
80
uni_modules/rt-uni-update/package.json
Normal file
80
uni_modules/rt-uni-update/package.json
Normal file
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
192
uni_modules/rt-uni-update/readme.md
Normal file
192
uni_modules/rt-uni-update/readme.md
Normal file
@ -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的版本管理系统(可参考下图)
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
## 项目使用说明 最重要!!!
|
||||
|
||||
- 注意!!!后端返回数据要求 字段如下 (如果后端字段不一样,请在跳转更新页时手动赋值,示例见下面代码)
|
||||
|
||||
```
|
||||
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
|
BIN
uni_modules/rt-uni-update/static/app_update_close.png
Normal file
BIN
uni_modules/rt-uni-update/static/app_update_close.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
BIN
uni_modules/rt-uni-update/static/bg_top.png
Normal file
BIN
uni_modules/rt-uni-update/static/bg_top.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.6 KiB |
Loading…
Reference in New Issue
Block a user