diff --git a/android-offline/HBuilder-Integrate-AS/simpleDemo/libs/install-apk-release.aar b/android-offline/HBuilder-Integrate-AS/simpleDemo/libs/install-apk-release.aar new file mode 100644 index 0000000..dedb4d8 Binary files /dev/null and b/android-offline/HBuilder-Integrate-AS/simpleDemo/libs/install-apk-release.aar differ diff --git a/android-offline/HBuilder-Integrate-AS/simpleDemo/src/main/AndroidManifest.xml b/android-offline/HBuilder-Integrate-AS/simpleDemo/src/main/AndroidManifest.xml index a898f9c..1d30bcd 100644 --- a/android-offline/HBuilder-Integrate-AS/simpleDemo/src/main/AndroidManifest.xml +++ b/android-offline/HBuilder-Integrate-AS/simpleDemo/src/main/AndroidManifest.xml @@ -2,6 +2,11 @@ + + + { if (status === 200) { - resolve(download.filename) + const filePath = download.filename || '' + console.log('[update] 下载完成:', filePath) + resolve(filePath) } else { + console.error('[update] 下载失败 status:', status) reject(new Error(`download failed: ${status}`)) } } @@ -125,7 +128,12 @@ export function installUpdatePackage(filePath) { return } if (appEnv.isApp && typeof plus !== 'undefined') { - plus.runtime.install(filePath, {}, () => {}, () => {}) + console.log('[update] plus.runtime.install:', filePath) + // 与散单项目一致:只传路径,不传 options 与回调。 + // 实测传了 options/回调时 5+ Runtime 走静默安装路径(应用进程内 PackageParser 解析 APK), + // 无系统安装权限时 error 回调收到 null 且不回落 UI 安装器 → 打不开安装包; + // 不传回调则走系统 UI 安装器(弹出安装界面)。 + plus.runtime.install(filePath) return } } diff --git a/src/pages/login/login.vue b/src/pages/login/login.vue index db2be25..90af647 100644 --- a/src/pages/login/login.vue +++ b/src/pages/login/login.vue @@ -257,6 +257,9 @@ export default { updateInstalling: false, updateError: '', updateProgress: { received: 0, total: 0 }, + // ---- 检查更新优先于鉴权跳转 ---- + updateChecked: false, // 更新检测是否已完成(无论有无更新) + pendingAutoEnter: false, // 更新检测完成前被挂起的自动进入打包模式 } }, onUnload() { @@ -334,19 +337,37 @@ export default { isPageActive() { return this.pageActive !== false }, - /** 检测发布服务器上是否有新版本;有新版本则弹窗提示(不自动下载) */ + /** 检测发布服务器上是否有新版本;有新版本则弹窗提示(不自动下载)。 + * 检查更新优先于鉴权跳转:检测完成前自动进入打包模式被挂起, + * 有更新时弹窗,用户跳过/关闭后才继续跳转;无更新或检测失败则放行。 */ checkAppUpdate() { + console.log('[update] checkAppUpdate 开始, url =', appEnv.updateLatestUrl) if (!appEnv.updateLatestUrl) { + this.updateChecked = true + this.flushPendingAutoEnter() return } checkAppUpdate().then((info) => { + console.log('[update] 检测结果:', JSON.stringify(info), 'pageActive =', this.isPageActive()) + this.updateChecked = true if (!info || !this.isPageActive()) { + // 无更新 / 网络失败 / 页面已离开:放行挂起的鉴权跳转 + this.flushPendingAutoEnter() return } this.updateInfo = info this.updateDialogVisible = true + // 有更新:鉴权跳转继续挂起,直到用户在弹窗中跳过(可跳过时) }) }, + /** 更新检测完成后,若鉴权跳转被挂起则继续执行 */ + flushPendingAutoEnter() { + if (!this.pendingAutoEnter) { + return + } + this.pendingAutoEnter = false + this.autoEnterPackMode() + }, /** 点击“立即更新”:内置下载(带进度),完成后自动安装 */ startUpdateDownload() { const info = this.updateInfo @@ -386,7 +407,7 @@ export default { this.startUpdateDownload() } }, - /** 跳过更新:仅 canSkip===1 且未在下载/安装中时可点 */ + /** 跳过更新:仅 canSkip===1 且未在下载/安装中时可点;跳过后放行挂起的鉴权跳转 */ skipUpdate() { if (!this.updateInfo || this.updateInfo.canSkip !== 1) { return @@ -395,6 +416,7 @@ export default { return } this.updateDialogVisible = false + this.flushPendingAutoEnter() }, updatePercent() { const { received, total } = this.updateProgress @@ -1453,9 +1475,15 @@ export default { return } const storedToken = uni.getStorageSync('workbench_token') + console.log('[update][gate] autoEnterPackMode: updateChecked =', this.updateChecked, 'storedToken =', !!storedToken, 'pending =', this.pendingAutoEnter) if (!storedToken) { return } + // 检查更新优先:更新检测未完成时挂起鉴权跳转,待检测完成后由 flushPendingAutoEnter 继续 + if (!this.updateChecked) { + this.pendingAutoEnter = true + return + } this.hasStoredWorkbench = true this.clearAutoEnterPackTimer() // 延迟 500ms,期间再次确认 token 未被清除后再进入打包模式 @@ -1473,6 +1501,7 @@ export default { }, 500) }, doEnterPackMode(storedToken) { + console.log('[update][gate] doEnterPackMode 进入, updateChecked =', this.updateChecked) if (!this.isPageActive()) { return } @@ -1510,6 +1539,11 @@ export default { return } const storedToken = uni.getStorageSync('workbench_token') + // 检查更新优先:检测未完成时挂起,完成后继续 + if (!this.updateChecked) { + this.pendingAutoEnter = true + return + } this.doEnterPackMode(storedToken) }, chooseRebindWorkbench() {