From f999f3364b80db353514ecd49a9a482d36f1ac09 Mon Sep 17 00:00:00 2001 From: Yukino Song Date: Wed, 28 Aug 2024 02:59:16 +0800 Subject: [PATCH] Update version check logic --- src_assets/common/assets/web/apollo_version.js | 7 ++++--- src_assets/common/assets/web/index.html | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src_assets/common/assets/web/apollo_version.js b/src_assets/common/assets/web/apollo_version.js index a238dec7..1ca74895 100644 --- a/src_assets/common/assets/web/apollo_version.js +++ b/src_assets/common/assets/web/apollo_version.js @@ -17,6 +17,7 @@ class ApolloVersion { this.versionMajor = this.versionParts ? this.versionParts[0] : null; this.versionMinor = this.versionParts ? this.versionParts[1] : null; this.versionPatch = this.versionParts ? this.versionParts[2] : null; + this.versionIncremental = this.versionParts ? this.versionParts[3] : null; } parseVersion(version) { @@ -27,10 +28,10 @@ class ApolloVersion { if (v.indexOf("v") === 0) { v = v.substring(1); } - return v.split('.').map(Number); + return v.split('.').map(i => parseInt(i, 10)); } - isGreater(otherVersion) { + isGreater(otherVersion, checkIncremental) { let otherVersionParts; if (otherVersion instanceof ApolloVersion) { otherVersionParts = otherVersion.versionParts; @@ -43,7 +44,7 @@ class ApolloVersion { if (!this.versionParts || !otherVersionParts) { return false; } - for (let i = 0; i < Math.min(3, this.versionParts.length, otherVersionParts.length); i++) { + for (let i = 0; i < Math.min(checkIncremental && 4 || 3, this.versionParts.length, otherVersionParts.length); i++) { if (this.versionParts[i] > otherVersionParts[i]) { return true; } diff --git a/src_assets/common/assets/web/index.html b/src_assets/common/assets/web/index.html index e71125c2..6ed5deab 100644 --- a/src_assets/common/assets/web/index.html +++ b/src_assets/common/assets/web/index.html @@ -135,7 +135,7 @@ if (!this.preReleaseVersion || !this.githubVersion || !this.version) { return false; } - return this.preReleaseVersion.isGreater(this.version) && this.preReleaseVersion.isGreater(this.githubVersion); + return this.preReleaseVersion.isGreater(this.version, true) && this.preReleaseVersion.isGreater(this.githubVersion, true); }, buildVersionIsDirty() { return this.version.version?.split(".").length === 5 &&