修改版本号
This commit is contained in:
24
App.vue
24
App.vue
@@ -448,12 +448,16 @@ export default {
|
||||
|
||||
function checkUpdate() {
|
||||
const localVersion = plus.runtime.version;
|
||||
const localWgtVersion = uni.getStorageSync('wgtVersion') || localVersion;
|
||||
uni.request({
|
||||
url: 'https://your-server.com/update/version.json',
|
||||
url: 'http://47.117.71.33:11295/fadapp-update/version.json?t=' + Date.now(),
|
||||
success: (res) => {
|
||||
const remoteVersion = res.data.version;
|
||||
const wgtUrl = res.data.wgtUrl;
|
||||
if (compareVersion(remoteVersion, localVersion) > 0) {
|
||||
// 取本地基座和本地wgt的最大版本
|
||||
const currentVersion = compareVersion(localWgtVersion, localVersion) > 0 ? localWgtVersion : localVersion;
|
||||
console.log('本地基座版本:', localVersion, '本地wgt版本:', localWgtVersion, '当前对比版本:', currentVersion, '远程版本:', remoteVersion);
|
||||
if (compareVersion(remoteVersion, currentVersion) > 0) {
|
||||
uni.showModal({
|
||||
title: '发现新版本',
|
||||
content: `检测到新版本(${remoteVersion}),是否立即下载并更新?`,
|
||||
@@ -468,6 +472,8 @@ function checkUpdate() {
|
||||
uni.hideLoading();
|
||||
if (downloadResult.statusCode === 200) {
|
||||
plus.runtime.install(downloadResult.tempFilePath, {force: true}, function() {
|
||||
// 更新本地wgt版本号
|
||||
uni.setStorageSync('wgtVersion', remoteVersion);
|
||||
uni.showModal({
|
||||
title: '更新完成',
|
||||
content: '应用需要重启才能生效,是否立即重启?',
|
||||
@@ -501,13 +507,17 @@ function checkUpdate() {
|
||||
}
|
||||
});
|
||||
}
|
||||
function extractVersionNum(str) {
|
||||
const match = str.match(/(\\d+\\.\\d+(?:\\.\\d+)?)/);
|
||||
return match ? match[1] : '0.0.0';
|
||||
}
|
||||
|
||||
function compareVersion(v1, v2) {
|
||||
v1 = v1.split('.');
|
||||
v2 = v2.split('.');
|
||||
for (let i = 0; i < v1.length; ++i) {
|
||||
const n1 = parseInt(v1[i] || '0');
|
||||
const n2 = parseInt(v2[i] || '0');
|
||||
v1 = extractVersionNum(v1).split('.').map(Number);
|
||||
v2 = extractVersionNum(v2).split('.').map(Number);
|
||||
for (let i = 0; i < Math.max(v1.length, v2.length); i++) {
|
||||
const n1 = v1[i] || 0;
|
||||
const n2 = v2[i] || 0;
|
||||
if (n1 > n2) return 1;
|
||||
if (n1 < n2) return -1;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,15 @@
|
||||
<image class="entry-icon" src="/static/images/baogong.png" mode="aspectFit" />
|
||||
<text class="entry-text">每日报工</text>
|
||||
</view>
|
||||
<!-- <view class="divider"></view>
|
||||
<view class="entry-item" @click="goReportWork">
|
||||
<image class="entry-icon" src="/static/images/baogong.png" mode="aspectFit" />
|
||||
<text class="entry-text">热更新</text>
|
||||
</view>
|
||||
<view class="entry-item" @click="goReportWork">
|
||||
<image class="entry-icon" src="/static/images/baogong.png" mode="aspectFit" />
|
||||
<text class="entry-text">成功与否</text>
|
||||
</view> -->
|
||||
<view class="divider"></view>
|
||||
<view class="entry-item" @click="goConstruction">
|
||||
<image class="entry-icon" src="/static/images/shigong.png" mode="aspectFit" />
|
||||
|
||||
Reference in New Issue
Block a user