feat:更新版本记录
This commit is contained in:
+21
-1
@@ -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') {
|
||||
|
||||
Reference in New Issue
Block a user