feat:更新版本记录

This commit is contained in:
2026-06-23 13:29:38 +08:00
parent 90fc557ac8
commit ab8e8371cf
4 changed files with 52 additions and 8 deletions
+21 -1
View File
@@ -180,6 +180,21 @@ export const downloadFileWithProgress = (url, { progress, stageText = '下载中
reject(new Error('empty url'))
return
}
const markHotUpdateInFlight = (delta) => {
try {
const current = Number(uni.__hotUpdateInFlightCount || 0)
const next = Math.max(0, current + Number(delta || 0))
uni.__hotUpdateInFlightCount = next
uni.__hotUpdateInFlight = next > 0
} catch (e) {}
}
let cleaned = false
const cleanup = () => {
if (cleaned) return
cleaned = true
markHotUpdateInFlight(-1)
}
markHotUpdateInFlight(1)
const setter = createProgressSetter(progress)
setter.reset()
if (progress?.show) progress.show(stageText)
@@ -189,13 +204,18 @@ export const downloadFileWithProgress = (url, { progress, stageText = '下载中
url,
success: (res) => {
if (!res || res.statusCode !== 200) {
cleanup()
reject(new Error('download failed'))
return
}
setter.set(100, stageText)
cleanup()
resolve(res.tempFilePath)
},
fail: () => reject(new Error('download failed')),
fail: () => {
cleanup()
reject(new Error('download failed'))
},
})
if (task && typeof task.onProgressUpdate === 'function') {