feat(lightweight-extension): 拖拽/选取上传进度上报

挂载 lightweightUploadProgress 到 handleDrop/handlePick,
读取本地文件时初始化进度并显示状态,失败时关闭进度。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
potaser
2026-08-21 10:14:33 +08:00
co-authored by Claude Opus 5
parent 509f5ff11b
commit 23f265f2b1
3 changed files with 15 additions and 0 deletions
+2
View File
@@ -24565,6 +24565,7 @@ compare: [[flesh, peel]]`;
appendExtensionFiles,
buildLightweightExtensionStage,
lightweightExtensionTestStatus,
lightweightUploadProgress,
uploadExtensionWithProgress,
}, event),
handleLightweightExtensionFolderPick: (event) => window.LightWeightExtensionTest && window.LightWeightExtensionTest.handlePick({
@@ -24574,6 +24575,7 @@ compare: [[flesh, peel]]`;
appendExtensionFiles,
buildLightweightExtensionStage,
lightweightExtensionTestStatus,
lightweightUploadProgress,
uploadExtensionWithProgress,
}, event),
openLightweightExtensionFolderPicker: () => window.LightWeightExtensionTest && window.LightWeightExtensionTest.openPicker(),
+2
View File
@@ -24401,6 +24401,7 @@ compare: [[flesh, peel]]`;
appendExtensionFiles,
buildLightweightExtensionStage,
lightweightExtensionTestStatus,
lightweightUploadProgress,
uploadExtensionWithProgress,
}, event),
handleLightweightExtensionFolderPick: (event) => window.LightWeightExtensionTest && window.LightWeightExtensionTest.handlePick({
@@ -24410,6 +24411,7 @@ compare: [[flesh, peel]]`;
appendExtensionFiles,
buildLightweightExtensionStage,
lightweightExtensionTestStatus,
lightweightUploadProgress,
uploadExtensionWithProgress,
}, event),
openLightweightExtensionFolderPicker: () => window.LightWeightExtensionTest && window.LightWeightExtensionTest.openPicker(),
+11
View File
@@ -282,12 +282,23 @@
function mountApi() {
window.LightWeightExtensionTest = {
async handleDrop(hooks, event) {
const progress = hooks.lightweightUploadProgress;
try {
if (progress) {
progress.active = true;
progress.percent = 0;
progress.loaded = 0;
progress.total = 0;
progress.speed = 0;
progress.label = '本地文件读取中';
}
hooks.lightweightExtensionTestStatus.value = '本地文件读取中...';
const files = await readDroppedFiles(event?.dataTransfer);
await processFolderFiles(hooks, files);
} catch (error) {
const message = `失败:${error.message || '目录处理失败'}`;
hooks.lightweightExtensionTestStatus.value = message;
if (progress) progress.active = false;
notifyError(message);
}
},