fix: 应用内更新安装器无法调起(补齐 install-apk 模块)
- 根因: simpleDemo/libs 缺 install-apk-release.aar(提取 SDK 时漏拷), plus.runtime.install 走静默安装路径失败且不回落 UI 安装器 - 补齐 install-apk-release.aar(与散单工程一致) - AndroidManifest 补 INSTALL_PACKAGES/REQUEST_INSTALL_PACKAGES 权限(与散单权限集一致) - update.js: installUpdatePackage 改为无参调用 plus.runtime.install(filePath)(带 options/回调会走静默安装分支),下载恢复默认路径 - login.vue: 检查更新优先于鉴权跳转(updateChecked/pendingAutoEnter 门控,检测完成前挂起自动进入打包模式) - 版本号 1.0.19(用户已改) - 真机端到端验证: 1.0.18 降级包 → 更新弹窗 → 下载 → 系统安装器弹出 → 安装成功 1.0.19
This commit is contained in:
parent
3a99587cc5
commit
c9bfbc2781
Binary file not shown.
@ -2,6 +2,11 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
|
<!-- 应用内更新安装 APK(与散单项目权限集一致):
|
||||||
|
INSTALL_PACKAGES 为 5+ Runtime plus.runtime.install 静默安装路径所需声明(非系统应用实际仍走 UI 安装器);
|
||||||
|
REQUEST_INSTALL_PACKAGES 为 Android 8+ 未知来源安装授权,7.x 及以下仅依赖全局未知来源开关 -->
|
||||||
|
<uses-permission android:name="android.permission.INSTALL_PACKAGES" />
|
||||||
|
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "wms-worker-station",
|
"name": "wms-worker-station",
|
||||||
"version": "1.0.18",
|
"version": "1.0.20",
|
||||||
"description": "WMS仓库工作台桌面端",
|
"description": "WMS仓库工作台桌面端",
|
||||||
"author": "tianbao",
|
"author": "tianbao",
|
||||||
"main": "electron/main.js",
|
"main": "electron/main.js",
|
||||||
|
|||||||
@ -69,7 +69,7 @@ export function formatUpdateSize(bytes) {
|
|||||||
/**
|
/**
|
||||||
* 内置下载更新安装包(带进度)
|
* 内置下载更新安装包(带进度)
|
||||||
* - Electron:主进程下载(https + 重定向),通过 electronAPI 回传进度
|
* - Electron:主进程下载(https + 重定向),通过 electronAPI 回传进度
|
||||||
* - App:plus.downloader
|
* - App:plus.downloader(默认下载目录)
|
||||||
* resolve(本地文件路径)
|
* resolve(本地文件路径)
|
||||||
*/
|
*/
|
||||||
export function startUpdateDownload(url, onProgress) {
|
export function startUpdateDownload(url, onProgress) {
|
||||||
@ -99,8 +99,11 @@ export function startUpdateDownload(url, onProgress) {
|
|||||||
{},
|
{},
|
||||||
(download, status) => {
|
(download, status) => {
|
||||||
if (status === 200) {
|
if (status === 200) {
|
||||||
resolve(download.filename)
|
const filePath = download.filename || ''
|
||||||
|
console.log('[update] 下载完成:', filePath)
|
||||||
|
resolve(filePath)
|
||||||
} else {
|
} else {
|
||||||
|
console.error('[update] 下载失败 status:', status)
|
||||||
reject(new Error(`download failed: ${status}`))
|
reject(new Error(`download failed: ${status}`))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,7 +128,12 @@ export function installUpdatePackage(filePath) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (appEnv.isApp && typeof plus !== 'undefined') {
|
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
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -257,6 +257,9 @@ export default {
|
|||||||
updateInstalling: false,
|
updateInstalling: false,
|
||||||
updateError: '',
|
updateError: '',
|
||||||
updateProgress: { received: 0, total: 0 },
|
updateProgress: { received: 0, total: 0 },
|
||||||
|
// ---- 检查更新优先于鉴权跳转 ----
|
||||||
|
updateChecked: false, // 更新检测是否已完成(无论有无更新)
|
||||||
|
pendingAutoEnter: false, // 更新检测完成前被挂起的自动进入打包模式
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onUnload() {
|
onUnload() {
|
||||||
@ -334,19 +337,37 @@ export default {
|
|||||||
isPageActive() {
|
isPageActive() {
|
||||||
return this.pageActive !== false
|
return this.pageActive !== false
|
||||||
},
|
},
|
||||||
/** 检测发布服务器上是否有新版本;有新版本则弹窗提示(不自动下载) */
|
/** 检测发布服务器上是否有新版本;有新版本则弹窗提示(不自动下载)。
|
||||||
|
* 检查更新优先于鉴权跳转:检测完成前自动进入打包模式被挂起,
|
||||||
|
* 有更新时弹窗,用户跳过/关闭后才继续跳转;无更新或检测失败则放行。 */
|
||||||
checkAppUpdate() {
|
checkAppUpdate() {
|
||||||
|
console.log('[update] checkAppUpdate 开始, url =', appEnv.updateLatestUrl)
|
||||||
if (!appEnv.updateLatestUrl) {
|
if (!appEnv.updateLatestUrl) {
|
||||||
|
this.updateChecked = true
|
||||||
|
this.flushPendingAutoEnter()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
checkAppUpdate().then((info) => {
|
checkAppUpdate().then((info) => {
|
||||||
|
console.log('[update] 检测结果:', JSON.stringify(info), 'pageActive =', this.isPageActive())
|
||||||
|
this.updateChecked = true
|
||||||
if (!info || !this.isPageActive()) {
|
if (!info || !this.isPageActive()) {
|
||||||
|
// 无更新 / 网络失败 / 页面已离开:放行挂起的鉴权跳转
|
||||||
|
this.flushPendingAutoEnter()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.updateInfo = info
|
this.updateInfo = info
|
||||||
this.updateDialogVisible = true
|
this.updateDialogVisible = true
|
||||||
|
// 有更新:鉴权跳转继续挂起,直到用户在弹窗中跳过(可跳过时)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
/** 更新检测完成后,若鉴权跳转被挂起则继续执行 */
|
||||||
|
flushPendingAutoEnter() {
|
||||||
|
if (!this.pendingAutoEnter) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.pendingAutoEnter = false
|
||||||
|
this.autoEnterPackMode()
|
||||||
|
},
|
||||||
/** 点击“立即更新”:内置下载(带进度),完成后自动安装 */
|
/** 点击“立即更新”:内置下载(带进度),完成后自动安装 */
|
||||||
startUpdateDownload() {
|
startUpdateDownload() {
|
||||||
const info = this.updateInfo
|
const info = this.updateInfo
|
||||||
@ -386,7 +407,7 @@ export default {
|
|||||||
this.startUpdateDownload()
|
this.startUpdateDownload()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/** 跳过更新:仅 canSkip===1 且未在下载/安装中时可点 */
|
/** 跳过更新:仅 canSkip===1 且未在下载/安装中时可点;跳过后放行挂起的鉴权跳转 */
|
||||||
skipUpdate() {
|
skipUpdate() {
|
||||||
if (!this.updateInfo || this.updateInfo.canSkip !== 1) {
|
if (!this.updateInfo || this.updateInfo.canSkip !== 1) {
|
||||||
return
|
return
|
||||||
@ -395,6 +416,7 @@ export default {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.updateDialogVisible = false
|
this.updateDialogVisible = false
|
||||||
|
this.flushPendingAutoEnter()
|
||||||
},
|
},
|
||||||
updatePercent() {
|
updatePercent() {
|
||||||
const { received, total } = this.updateProgress
|
const { received, total } = this.updateProgress
|
||||||
@ -1453,9 +1475,15 @@ export default {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
const storedToken = uni.getStorageSync('workbench_token')
|
const storedToken = uni.getStorageSync('workbench_token')
|
||||||
|
console.log('[update][gate] autoEnterPackMode: updateChecked =', this.updateChecked, 'storedToken =', !!storedToken, 'pending =', this.pendingAutoEnter)
|
||||||
if (!storedToken) {
|
if (!storedToken) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// 检查更新优先:更新检测未完成时挂起鉴权跳转,待检测完成后由 flushPendingAutoEnter 继续
|
||||||
|
if (!this.updateChecked) {
|
||||||
|
this.pendingAutoEnter = true
|
||||||
|
return
|
||||||
|
}
|
||||||
this.hasStoredWorkbench = true
|
this.hasStoredWorkbench = true
|
||||||
this.clearAutoEnterPackTimer()
|
this.clearAutoEnterPackTimer()
|
||||||
// 延迟 500ms,期间再次确认 token 未被清除后再进入打包模式
|
// 延迟 500ms,期间再次确认 token 未被清除后再进入打包模式
|
||||||
@ -1473,6 +1501,7 @@ export default {
|
|||||||
}, 500)
|
}, 500)
|
||||||
},
|
},
|
||||||
doEnterPackMode(storedToken) {
|
doEnterPackMode(storedToken) {
|
||||||
|
console.log('[update][gate] doEnterPackMode 进入, updateChecked =', this.updateChecked)
|
||||||
if (!this.isPageActive()) {
|
if (!this.isPageActive()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -1510,6 +1539,11 @@ export default {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
const storedToken = uni.getStorageSync('workbench_token')
|
const storedToken = uni.getStorageSync('workbench_token')
|
||||||
|
// 检查更新优先:检测未完成时挂起,完成后继续
|
||||||
|
if (!this.updateChecked) {
|
||||||
|
this.pendingAutoEnter = true
|
||||||
|
return
|
||||||
|
}
|
||||||
this.doEnterPackMode(storedToken)
|
this.doEnterPackMode(storedToken)
|
||||||
},
|
},
|
||||||
chooseRebindWorkbench() {
|
chooseRebindWorkbench() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user