Skip to content

Commit

Permalink
Merge 8a4149f into 50a464e
Browse files Browse the repository at this point in the history
  • Loading branch information
gxdvip committed Sep 2, 2021
2 parents 50a464e + 8a4149f commit d9260b3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/upload/src/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function upload(option) {
const xhr = new XMLHttpRequest();
const action = option.action;

if (xhr.upload) {
if (xhr.upload && option.onProgress(false) !== false) {
xhr.upload.onprogress = function progress(e) {
if (e.total > 0) {
e.percent = e.loaded / e.total * 100;
Expand Down
12 changes: 8 additions & 4 deletions packages/upload/src/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,14 @@ export default {
this.onChange(file, this.uploadFiles);
},
handleProgress(ev, rawFile) {
const file = this.getFile(rawFile);
this.onProgress(ev, file, this.uploadFiles);
file.status = 'uploading';
file.percentage = ev.percent || 0;
if (ev === false) {
return this.onProgress();
} else {
const file = this.getFile(rawFile);
this.onProgress(ev, file, this.uploadFiles);
file.status = 'uploading';
file.percentage = ev.percent || 0;
}
},
handleSuccess(res, rawFile) {
const file = this.getFile(rawFile);
Expand Down
2 changes: 1 addition & 1 deletion packages/upload/src/upload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export default {
filename: this.name,
action: this.action,
onProgress: e => {
this.onProgress(e, rawFile);
return this.onProgress(e, rawFile);
},
onSuccess: res => {
this.onSuccess(res, rawFile);
Expand Down

0 comments on commit d9260b3

Please sign in to comment.