fix: parseVersionCode修复—major*100+lastNum, T1.0.10→110匹配服务器
This commit is contained in:
@ -31,11 +31,14 @@ export default {
|
||||
// OTA 热更新雷达 — 版本检测 + WGT 下载 + 静默安装
|
||||
// ==========================================================
|
||||
checkUpdate() {
|
||||
// 🔧 直接用 manifest.json 的 versionCode 与服务器对比(避免 parseVersionCode 精度丢失)
|
||||
const currentVersionCode = plus.runtime.versionCode || 0;
|
||||
// 🔧 appWgtVersion 跟随 WGT 更新,解析算法: major*100 + lastNum
|
||||
// "T1.0.1"→101, "T1.0.10"→110, "T1.0.99"→199
|
||||
const sysInfo = uni.getSystemInfoSync();
|
||||
const wgtVer = sysInfo.appWgtVersion || sysInfo.appVersion || "0";
|
||||
const currentVersionCode = this.parseVersionCode(wgtVer);
|
||||
const baseUrl = uni.getStorageSync("env_base_url") || "http://track_back.iris-rs.cn/api/v1";
|
||||
|
||||
console.log("[OTA] 本地 versionCode:", currentVersionCode);
|
||||
console.log("[OTA] 本地版本:", wgtVer, "→ 数字:", currentVersionCode);
|
||||
|
||||
uni.request({
|
||||
url: `${baseUrl}/app/check-update`,
|
||||
@ -67,6 +70,14 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
/** 版本号→数字: "T1.0.10" → 1*100+10 = 110 */
|
||||
parseVersionCode(v) {
|
||||
if (!v) return 0;
|
||||
const nums = v.match(/\d+/g);
|
||||
if (!nums || nums.length < 2) return 0;
|
||||
return parseInt(nums[0], 10) * 100 + parseInt(nums[nums.length - 1], 10);
|
||||
},
|
||||
|
||||
downloadAndInstall(wgtUrl, newVersion, description) {
|
||||
if (!wgtUrl) {
|
||||
console.log("[OTA] 无 WGT 下载地址");
|
||||
|
||||
Reference in New Issue
Block a user