Skip to content

Commit

Permalink
4.x 优化针对进度回退的处理 (#681)
Browse files Browse the repository at this point in the history
* 适当降低虚拟进度条的输出速度

* 细节优化
  • Loading branch information
yinxulai authored Oct 24, 2024
1 parent 12efc5e commit b989d36
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/browser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "qiniu-js",
"version": "4.0.0-beta.5",
"version": "4.0.0-beta.6",
"description": "Qiniu browser upload sdk",
"miniprogram": "output",
"main": "output/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/helper/progress/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class MockProgress {

let time = 0
this.progress = 0
const intervalFrequency = 100
const intervalFrequency = 400
const intervalIds = setInterval(() => {
time += intervalFrequency
this.setProgress(1 - Math.exp(-1 * time / (this.timeConstant * 1000)))
Expand Down
5 changes: 1 addition & 4 deletions packages/common/src/upload/common/context/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ export function updateTotalIntoProgress(progress: Progress): Progress {
}

const newPercent = totalPercent / detailValues.length

// 在失败重试等场景中,进度回退是正常业务导致的,但是客户要求进度不能回退
if (newPercent > progress.percent) progress.percent = newPercent // 防止进度倒流

progress.percent = newPercent
progress.size = totalSize
return progress
}
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/upload/multipartv1/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export const createMultipartUploadV1Task = (file: UploadFile, config: UploadConf
prefix: 'MultipartUploadChildQueue'
},
concurrentLimit: 1, // 此接口只能串行
// TODO 动态创建任务会导致任务进度倒退
// FIXME 动态创建任务会导致任务进度倒退
tasksCreator: async () => {
const sliceResult = await file.slice(4 * 1024 * 1024)
if (isErrorResult(sliceResult)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/upload/multipartv2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ export const createMultipartUploadV2Task = (file: UploadFile, config: UploadConf
},
concurrentLimit: 3,

// TODO 动态创建任务会导致任务进度倒退
// FIXME: 动态创建任务会导致任务进度倒退
tasksCreator: async () => {
const sliceResult = await file.slice(4 * 1024 * 1024)
if (isErrorResult(sliceResult)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/wechat-miniprogram/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@qiniu/wechat-miniprogram-upload",
"version": "1.0.3",
"version": "1.0.4",
"description": "Qiniu wechat-miniprogram upload sdk",
"miniprogram": "output",
"main": "output/index.js",
Expand Down

0 comments on commit b989d36

Please sign in to comment.