提交判断版本号

This commit is contained in:
duan 2025-01-20 10:42:53 +08:00
parent 18549d562f
commit 1674a62fec
1 changed files with 16 additions and 1 deletions

View File

@ -70,11 +70,26 @@ export const useCommonStore = defineStore("common", {
// a是當前應用的版本號 b是接口拿的
let appversion = (a.split('.').join('')) * 1
let resversion = (b.split('.').join('')) * 1
console.log('當前版本-' + appversion, '接口版本-' + resversion, '返回-' + this.isIosExamine,'判斷值-'+this.isExamines)
console.log('當前版本-' + appversion, '接口版本-' + resversion, '返回-' + this.isIosExamine, '判斷值-' + this
.isExamines)
if (appversion > resversion) {
// 再審核
this.isExamines = 1
}
},
// 判断版本号
compare(version1, version2) {
let arr1 = version1.split(".");
let arr2 = version2.split(".");
let length = Math.max(arr1.length, arr2.length);
for (let i = 0; i < length; i++) {
const n1 = Number(arr1[i] || 0)
const n2 = Number(arr2[i] || 0)
// version1 > version2 返回1如果 version1 < version2 返回-1不然返回0
if (n1 > n2) return 1
if (n1 < n2) return -1
}
return 0
}
},