From 837067e93ccee3de0f92eff9e54d361eee7b79c4 Mon Sep 17 00:00:00 2001 From: chenpei Date: Tue, 27 Jan 2026 12:52:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A=E9=99=8D=E4=BD=8E?= =?UTF-8?q?=E7=BD=91=E9=80=9F=E6=98=BE=E7=A4=BA=E5=88=B7=E6=96=B0=E9=A2=91?= =?UTF-8?q?=E7=8E=87=20-=20=E4=BB=8E0.1=E7=A7=92=E6=94=B9=E4=B8=BA1?= =?UTF-8?q?=E7=A7=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 解决速度数字跳动过快,用户看不清的问题 - 速度计算逻辑保持准确(使用5次历史平均) - 更新间隔:0.1秒 → 1秒 - 用户体验:速度数字更稳定易读 --- lib/chunk-upload.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/chunk-upload.ts b/lib/chunk-upload.ts index 80cc353..493357f 100644 --- a/lib/chunk-upload.ts +++ b/lib/chunk-upload.ts @@ -405,7 +405,11 @@ export async function chunkUpload( const timeDelta = (currentTime - lastUpdateTime) / 1000 // 秒 const bytesDelta = clampedBytes - lastUploadedBytes - if (timeDelta > 0.1) { + // 优化:降低速度显示更新频率,从0.1秒改为1秒 + // 避免速度数字跳动过快,用户无法看清 + const UPDATE_INTERVAL = 1 // 1秒更新一次 + + if (timeDelta >= UPDATE_INTERVAL) { const currentSpeed = bytesDelta / timeDelta if (currentSpeed > 0 && currentSpeed < file.size * 100) { @@ -425,6 +429,7 @@ export async function chunkUpload( lastUpdateTime = currentTime lastUploadedBytes = clampedBytes } else { + // 在更新间隔内,使用上一次的速度显示(避免数字跳动) if (speedHistory.length > 0) { const lastSpeed = speedHistory[speedHistory.length - 1] onProgress?.(progress, lastSpeed)