From 0b6c4a7f8b183a7baada5f74d1924097282a508e Mon Sep 17 00:00:00 2001 From: duxingchen Date: Mon, 10 Aug 2026 14:12:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20OTA=E7=89=88=E6=9C=AC=E5=AF=B9=E6=AF=94?= =?UTF-8?q?=E6=94=B9=E7=94=A8plus.runtime.versionCode=E7=9B=B4=E6=8E=A5?= =?UTF-8?q?=E5=AF=B9=E6=AF=94,=E4=BF=AE=E5=A4=8DT1.0.10=E8=AF=AF=E5=88=A4?= =?UTF-8?q?=E4=B8=BA=E6=97=A7=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- track-uniapp/src/App.vue | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/track-uniapp/src/App.vue b/track-uniapp/src/App.vue index 6746c56..8bcfa86 100644 --- a/track-uniapp/src/App.vue +++ b/track-uniapp/src/App.vue @@ -31,13 +31,11 @@ export default { // OTA 热更新雷达 — 版本检测 + WGT 下载 + 静默安装 // ========================================================== checkUpdate() { - // 获取当前 App 的 WGT 资源版本号(uni-app 编译后的版本标识) - const sysInfo = uni.getSystemInfoSync(); - const currentWgtVersion = sysInfo.appWgtVersion || sysInfo.appVersion || "0"; - const currentVersionCode = this.parseVersionCode(currentWgtVersion); + // 🔧 直接用 manifest.json 的 versionCode 与服务器对比(避免 parseVersionCode 精度丢失) + const currentVersionCode = plus.runtime.versionCode || 0; const baseUrl = uni.getStorageSync("env_base_url") || "http://track_back.iris-rs.cn/api/v1"; - console.log("[OTA] 本地WGT版本:", currentWgtVersion, "| 数字版本:", currentVersionCode); + console.log("[OTA] 本地 versionCode:", currentVersionCode); uni.request({ url: `${baseUrl}/app/check-update`, @@ -69,15 +67,6 @@ export default { }); }, - /** 从版本字符串提取数字版本号用于对比 */ - parseVersionCode(versionStr) { - if (!versionStr) return 0; - const nums = versionStr.match(/\d+/g); - if (!nums) return 0; - // 取后三位拼成整数: "T1.0.2" → [1,0,1] → 101 - return parseInt(nums.slice(-3).join("").padEnd(3, "0").slice(0, 3), 10); - }, - downloadAndInstall(wgtUrl, newVersion, description) { if (!wgtUrl) { console.log("[OTA] 无 WGT 下载地址");