Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Element
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林焕东
Element
Commits
b295e1b9
Commit
b295e1b9
authored
May 02, 2017
by
baiyaaaaa
Committed by
杨奕
May 03, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support upload abort
parent
378c33d0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
6 deletions
+37
-6
examples/docs/en-US/upload.md
examples/docs/en-US/upload.md
+3
-2
examples/docs/zh-CN/upload.md
examples/docs/zh-CN/upload.md
+1
-0
packages/upload/src/index.vue
packages/upload/src/index.vue
+8
-0
packages/upload/src/upload.vue
packages/upload/src/upload.vue
+25
-4
No files found.
examples/docs/en-US/upload.md
View file @
b295e1b9
...
...
@@ -367,7 +367,8 @@ auto-upload | whether to auto upload file | boolean | — | true |
http-request | override default xhr behavior, allowing you to implement your own upload-file's request | function | — | — |
disabled | whether to disable upload | boolean | — | false |
###
Event
s
|
Event
Name | Description | Parameters |
###
Method
s
|
Methods
Name | Description | Parameters |
|---------- |-------- |---------- |
| clearFiles | clear the uploaded file list | — |
| abort | cancel upload request | ( file: fileList's item ) |
examples/docs/zh-CN/upload.md
View file @
b295e1b9
...
...
@@ -420,3 +420,4 @@
| 方法名 | 说明 | 参数 |
|---------- |-------------- | -- |
| clearFiles | 清空已上传的文件列表 | — |
| abort | 取消上传请求 | ( file: fileList 中的 file 对象 ) |
packages/upload/src/index.vue
View file @
b295e1b9
...
...
@@ -19,6 +19,10 @@ export default {
IframeUpload
},
provide
:
{
uploader
:
this
},
props
:
{
action
:
{
type
:
String
,
...
...
@@ -166,6 +170,7 @@ export default {
if
(
raw
)
{
file
=
this
.
getFile
(
raw
);
}
this
.
abort
(
file
);
var
fileList
=
this
.
uploadFiles
;
fileList
.
splice
(
fileList
.
indexOf
(
file
),
1
);
this
.
onRemove
(
file
,
fileList
);
...
...
@@ -179,6 +184,9 @@ export default {
});
return
target
;
},
abort
(
file
)
{
this
.
$refs
[
'
upload-inner
'
].
abort
(
file
);
},
clearFiles
()
{
this
.
uploadFiles
=
[];
},
...
...
packages/upload/src/upload.vue
View file @
b295e1b9
...
...
@@ -3,6 +3,7 @@ import ajax from './ajax';
import
UploadDragger
from
'
./upload-dragger.vue
'
;
export
default
{
inject
:
[
'
uploader
'
],
components
:
{
UploadDragger
},
...
...
@@ -47,7 +48,8 @@ export default {
data
()
{
return
{
mouseover
:
false
mouseover
:
false
,
reqs
:
{}
};
},
...
...
@@ -95,7 +97,23 @@ export default {
this
.
onRemove
(
rawFile
,
true
);
}
},
abort
(
file
)
{
const
{
reqs
}
=
this
;
if
(
file
)
{
let
uid
=
file
;
if
(
file
.
uid
)
uid
=
file
.
uid
;
if
(
reqs
[
uid
])
{
reqs
[
uid
].
abort
();
}
}
else
{
Object
.
keys
(
reqs
).
forEach
((
uid
)
=>
{
if
(
reqs
[
uid
])
reqs
[
uid
].
abort
();
delete
reqs
[
uid
];
});
}
},
post
(
rawFile
)
{
const
{
uid
}
=
rawFile
;
const
options
=
{
headers
:
this
.
headers
,
withCredentials
:
this
.
withCredentials
,
...
...
@@ -108,14 +126,17 @@ export default {
},
onSuccess
:
res
=>
{
this
.
onSuccess
(
res
,
rawFile
);
delete
this
.
reqs
[
uid
];
},
onError
:
err
=>
{
this
.
onError
(
err
,
rawFile
);
delete
this
.
reqs
[
uid
];
}
};
const
requestPromise
=
this
.
httpRequest
(
options
);
if
(
requestPromise
&&
requestPromise
.
then
)
{
requestPromise
.
then
(
options
.
onSuccess
,
options
.
onError
);
const
req
=
this
.
httpRequest
(
options
);
this
.
reqs
[
uid
]
=
req
;
if
(
req
&&
req
.
then
)
{
req
.
then
(
options
.
onSuccess
,
options
.
onError
);
}
},
handleClick
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment