From 2617e1786c3fddc43b18df31c8236b97ce4ee60f Mon Sep 17 00:00:00 2001
From: zjk <852185829@qq.com>
Date: 星期五, 31 七月 2026 16:26:20 +0800
Subject: [PATCH] feat: 添加应用更新进度显示与安装权限
---
utils/fs.js | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/utils/fs.js b/utils/fs.js
index ce6a048..f234b5e 100644
--- a/utils/fs.js
+++ b/utils/fs.js
@@ -91,6 +91,7 @@
directoryName = 'downloads',
fileNamePrefix = 'file',
fallbackExtension = 'jpg',
+ onProgress = null,
} = options;
return new Promise((resolve, reject) => {
@@ -101,7 +102,7 @@
}
// #ifdef APP-PLUS
- uni.downloadFile({
+ const downloadTask = uni.downloadFile({
url: normalizedRemoteUrl,
success: (downloadResult) => {
if (downloadResult.statusCode !== 200 || !downloadResult.tempFilePath) {
@@ -121,6 +122,17 @@
reject(error);
},
});
+
+ if (downloadTask && typeof downloadTask.onProgressUpdate === 'function' && typeof onProgress === 'function') {
+ // 统一把原生下载进度透传出去,方便调用方展示更细的 UI 状态。
+ downloadTask.onProgressUpdate((progressEvent) => {
+ onProgress({
+ progress: Number(progressEvent?.progress || 0),
+ totalBytesWritten: Number(progressEvent?.totalBytesWritten || 0),
+ totalBytesExpectedToWrite: Number(progressEvent?.totalBytesExpectedToWrite || 0),
+ });
+ });
+ }
// #endif
// #ifndef APP-PLUS
--
Gitblit v1.7.1