优化:降低网速显示刷新频率 - 从0.1秒改为1秒
- 解决速度数字跳动过快,用户看不清的问题 - 速度计算逻辑保持准确(使用5次历史平均) - 更新间隔:0.1秒 → 1秒 - 用户体验:速度数字更稳定易读
This commit is contained in:
parent
9dc0f10446
commit
837067e93c
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user