From d319cb576e0a727175009b77475a7042da390bea Mon Sep 17 00:00:00 2001 From: yaojn Date: Mon, 17 Mar 2025 18:42:55 +0800 Subject: [PATCH] =?UTF-8?q?-=20[=E5=8A=9F=E8=83=BD]=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E7=BB=84=E4=BB=B6=E5=8F=96=E6=B6=88=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=A7=E5=B0=8F=E9=99=90=E5=88=B6=20=20=20=20-=20[?= =?UTF-8?q?=E5=85=B3=E8=81=94]#[1361642678353920]=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E7=BB=84=E4=BB=B6=E5=8F=96=E6=B6=88=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=A7=E5=B0=8F=E9=99=90=E5=88=B6=20http://192.168.?= =?UTF-8?q?0.96:8090/demo/rdm.html#/story-detail/939050947543040/939050947?= =?UTF-8?q?543042/1361642678353920?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/UpLoad/UpLoad.vue | 26 +++++++++++++------------- component/UserCard/UserCard.vue | 18 +++++++++--------- iview/components/upload/ajax.js | 1 + iview/components/upload/upload.vue | 20 ++++++++++++++++++-- package.json | 2 +- 5 files changed, 42 insertions(+), 25 deletions(-) diff --git a/component/UpLoad/UpLoad.vue b/component/UpLoad/UpLoad.vue index c5599cd..e2d58be 100644 --- a/component/UpLoad/UpLoad.vue +++ b/component/UpLoad/UpLoad.vue @@ -33,19 +33,19 @@
-
- - {{ item.name }} - - - -
+
+ + {{ item.name }} + + + +
diff --git a/component/UserCard/UserCard.vue b/component/UserCard/UserCard.vue index 223b1a0..97f0ecc 100644 --- a/component/UserCard/UserCard.vue +++ b/component/UserCard/UserCard.vue @@ -29,15 +29,15 @@
-
- - {{ user.userName }} -
+
+ + {{ user.userName }} +
diff --git a/iview/components/upload/ajax.js b/iview/components/upload/ajax.js index 1089c4e..59f16ae 100644 --- a/iview/components/upload/ajax.js +++ b/iview/components/upload/ajax.js @@ -81,4 +81,5 @@ export default function upload(option) { } } xhr.send(formData); + return xhr; // 返回xhr对象,可用于中断上传 } diff --git a/iview/components/upload/upload.vue b/iview/components/upload/upload.vue index 53d5baf..718a02b 100644 --- a/iview/components/upload/upload.vue +++ b/iview/components/upload/upload.vue @@ -231,11 +231,11 @@ export default { } } - this.handleStart(file); + const _file = this.handleStart(file); let formData = new FormData(); formData.append(this.name, file); - ajax({ + _file.xhr = ajax({ headers: this.headers, withCredentials: this.withCredentials, file: file, @@ -252,6 +252,7 @@ export default { this.handleError(err, response, file); } }); + return _file; }, handleStart(file) { file.uid = Date.now() + this.tempIndex++; @@ -265,6 +266,7 @@ export default { }; this.fileList.push(_file); + return _file; }, getFile(file) { const fileList = this.fileList; @@ -308,15 +310,29 @@ export default { }, handleRemove(file) { const fileList = this.fileList; + if(file && file.xhr) { + file.xhr.abort(); + } fileList.splice(fileList.indexOf(file), 1); this.onRemove(file, fileList); }, + handleCancelAjax(file) { + // 处理取消上传 + if(file && file.xhr && file.status == 'uploading') { + file.xhr.abort(); + } + }, handlePreview(file) { if (file.status === 'finished') { this.onPreview(file); } }, clearFiles() { + this.fileList.forEach(file => { + if(file && file.xhr) { + file.xhr.abort(); + } + }); this.fileList = []; } }, diff --git a/package.json b/package.json index f2c2f89..1b3f6e4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "neatlogic-ui", - "version": "1.0.6", + "version": "1.0.7", "private": false, "main": "dist/neatlogic-ui.umd.min.js", "author": "neatlogic", -- Gitee