From 32796d0da6a2ac3922300caa8a46392f185d0c8d Mon Sep 17 00:00:00 2001 From: mike Date: Wed, 4 Nov 2026 21:28:17 +0800 Subject: [PATCH] Update App.jsx via upload script - 2026-11-04 21:28:09 --- App.jsx | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/App.jsx b/App.jsx index 5ddaf05..8a9c1b0 100644 --- a/App.jsx +++ b/App.jsx @@ -3039,14 +3039,19 @@ function MainApp({ username, onLogout }) { const files = e.dataTransfer.files && Array.from(e.dataTransfer.files); if (files && files.length) setAttachmentFiles(files); } + // 上传进度文字:按钮上显示"上传中 2/3 · 45%(8.6 / 19.0 MB)" + function uploadLabel(i, n, loaded, total) { + const mb = (x) => (x / 1048576).toFixed(1); + return `上传中${n > 1 ? ` ${i + 1}/${n}` : ''} · ${Math.floor(loaded / total * 100)}%(${mb(loaded)} / ${mb(total)} MB)`; + } async function handleUploadAttachment(customerId, folderId) { if (!attachmentFiles.length) { notify('请先选择文件'); return; } setUploading(true); const failed = []; try { - for (const file of attachmentFiles) { + for (const [i, file] of attachmentFiles.entries()) { try { - const res = await uploadFile(customerId, file); + const res = await uploadFile(customerId, file, (l, t) => setUploading(uploadLabel(i, attachmentFiles.length, l, t))); const entry = { fileName: res.fileName, originalName: res.originalName, @@ -3194,9 +3199,9 @@ function MainApp({ username, onLogout }) { setSupplierUploading(true); const failed = []; try { - for (const file of supplierAttachmentFiles) { + for (const [i, file] of supplierAttachmentFiles.entries()) { try { - const res = await uploadFile(supplierId, file); + const res = await uploadFile(supplierId, file, (l, t) => setSupplierUploading(uploadLabel(i, supplierAttachmentFiles.length, l, t))); const entry = { fileName: res.fileName, originalName: res.originalName, note: supplierAttachmentNote.trim(), date: todayStr() }; setSuppliers(prev => prev.map(s => (s.id === supplierId ? { ...s, attachments: [entry, ...(s.attachments || [])] } : s))); } catch (e) { @@ -5771,7 +5776,7 @@ function SupplierDetail({ value={attachmentNote} onChange={e => setAttachmentNote(e.target.value)} /> @@ -6129,7 +6134,7 @@ function CustomerDetail({ value={attachmentNote} onChange={e => setAttachmentNote(e.target.value)} />