dam-7 feat 优化版本判断逻辑

master
hou 3 years ago
parent a9b26184fe
commit ee361e9221

@ -151,10 +151,34 @@ export default class LoginPage extends BasePage {
console.log('Version////', this.Version);
}
Version = '1.0.9';
compareVersion(version1: any, version2: any) {
//version1 1 &&& version2 -1
const newVersion1 = `${version1}`.split('.').length < 3 ? `${version1}`.concat('.0') : `${version1}`;
const newVersion2 = `${version2}`.split('.').length < 3 ? `${version2}`.concat('.0') : `${version2}`;
//,
function toNum(a) {
const c = a.toString().split('.');
const num_place = ['', '0', '00', '000', '0000'],
r = num_place.reverse();
for (let i = 0; i < c.length; i++) {
const len = c[i].length;
c[i] = r[len] + c[i];
}
return c.join('');
}
//
function checkPlugin(a, b) {
const numA = toNum(a);
const numB = toNum(b);
return numA > numB ? 1 : numA < numB ? -1 : 0;
}
return checkPlugin(newVersion1, newVersion2);
}
async update() {
try {
await session.QueryVersion(server.serverAddress);
if (this.Version < session.Version) {
let versionNumber = this.compareVersion(this.Version, session.Version);
if (versionNumber == -1) {
//
uni.showModal({
content: (this.$t('message.Tip3') + session.Version + ',' + this.$t('message.Tip1')) as string,

Loading…
Cancel
Save