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)