优化
This commit is contained in:
@@ -58,14 +58,14 @@
|
||||
</div>
|
||||
<div class="drawerbox_bo_box_icontext">叫号</div>
|
||||
</div> -->
|
||||
<div class="drawerbox_bo_box_itembox" @click="screenref.shows()">
|
||||
<!-- <div class="drawerbox_bo_box_itembox" @click="screenref.shows()">
|
||||
<div class="drawerbox_bo_box_icon">
|
||||
<el-icon size="40">
|
||||
<Lock />
|
||||
</el-icon>
|
||||
</div>
|
||||
<div class="drawerbox_bo_box_icontext">锁屏</div>
|
||||
</div>
|
||||
</div> -->
|
||||
<!-- <div class="drawerbox_bo_box_itembox" @click="to('webview', {
|
||||
url: 'https://cashiernewadmin.sxczgkj.cn/',
|
||||
title: '后台管理'
|
||||
|
||||
@@ -57,10 +57,19 @@ async function findVersionAjax() {
|
||||
let updateFlag = useStorage.get('updateFlag')
|
||||
const res = await findVersion()
|
||||
if (res && res.version) {
|
||||
let reg = /\./g;
|
||||
if (res.version.replace(reg, '') > packageData.version.replace(reg, '') && res.url && !updateFlag) {
|
||||
showDialog.value = true
|
||||
updataInfo.value = res
|
||||
const newVersion = res.version;
|
||||
const oldVersion = packageData.version;
|
||||
const result = compareVersions(newVersion, oldVersion);
|
||||
if (result > 0) {
|
||||
console.log(`${newVersion} 比 ${oldVersion} 大`);
|
||||
if (!updateFlag) {
|
||||
showDialog.value = true
|
||||
updataInfo.value = res
|
||||
}
|
||||
} else if (result < 0) {
|
||||
console.log(`${newVersion} 比 ${oldVersion} 小`);
|
||||
} else {
|
||||
console.log(`${newVersion} 与 ${oldVersion} 相等`);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -68,6 +77,25 @@ async function findVersionAjax() {
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
function compareVersions(version1, version2) {
|
||||
const v1 = version1.split('.').map(Number);
|
||||
const v2 = version2.split('.').map(Number);
|
||||
const maxLength = Math.max(v1.length, v2.length);
|
||||
|
||||
for (let i = 0; i < maxLength; i++) {
|
||||
const num1 = v1[i] || 0;
|
||||
const num2 = v2[i] || 0;
|
||||
|
||||
if (num1 > num2) {
|
||||
return 1;
|
||||
} else if (num1 < num2) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 下载新版本
|
||||
async function uplaodHandle() {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user