fix: version check

This commit is contained in:
tbphp
2025-07-17 19:03:27 +08:00
parent c286e5f162
commit 0ea25bac66
2 changed files with 23 additions and 23 deletions

View File

@@ -45,6 +45,12 @@ class VersionService {
return null;
}
// 检查缓存中的版本号是否与当前应用版本号一致
if (versionInfo.currentVersion !== this.currentVersion) {
this.clearCache();
return null;
}
return versionInfo;
} catch (error) {
console.warn("Failed to parse cached version info:", error);
@@ -144,6 +150,9 @@ class VersionService {
versionInfo.isLatest = comparison >= 0;
versionInfo.hasUpdate = comparison < 0;
versionInfo.status = comparison < 0 ? "update-available" : "latest";
// 只在成功时缓存结果
this.setCachedVersionInfo(versionInfo);
} else {
versionInfo.status = "error";
}
@@ -152,9 +161,6 @@ class VersionService {
versionInfo.status = "error";
}
// 缓存结果
this.setCachedVersionInfo(versionInfo);
return versionInfo;
}