mirror of https://github.com/ElemeFE/element
misc update
parent
5bec4d7f31
commit
a94d35fb39
4
Makefile
4
Makefile
|
@ -2,9 +2,7 @@
|
||||||
default: help
|
default: help
|
||||||
|
|
||||||
# build all theme
|
# build all theme
|
||||||
build-theme: build-theme-default
|
build-theme:
|
||||||
|
|
||||||
build-theme-default:
|
|
||||||
npm run build:theme
|
npm run build:theme
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
@ -20,17 +20,6 @@ function getBody(xhr) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// option {
|
|
||||||
// onProgress: (event: { percent: number }): void,
|
|
||||||
// onError: (event: Error, body?: Object): void,
|
|
||||||
// onSuccess: (body: Object): void,
|
|
||||||
// data: Object,
|
|
||||||
// filename: String,
|
|
||||||
// file: File,
|
|
||||||
// withCredentials: Boolean,
|
|
||||||
// action: String,
|
|
||||||
// headers: Object,
|
|
||||||
// }
|
|
||||||
export default function upload(action, option) {
|
export default function upload(action, option) {
|
||||||
if (typeof XMLHttpRequest === 'undefined') {
|
if (typeof XMLHttpRequest === 'undefined') {
|
||||||
return;
|
return;
|
||||||
|
@ -61,8 +50,6 @@ export default function upload(action, option) {
|
||||||
};
|
};
|
||||||
|
|
||||||
xhr.onload = function onload() {
|
xhr.onload = function onload() {
|
||||||
// allow success when 2xx status
|
|
||||||
// see https://github.com/react-component/upload/issues/34
|
|
||||||
if (xhr.status < 200 || xhr.status >= 300) {
|
if (xhr.status < 200 || xhr.status >= 300) {
|
||||||
return option.onError(getError(action, option, xhr), getBody(xhr));
|
return option.onError(getError(action, option, xhr), getBody(xhr));
|
||||||
}
|
}
|
||||||
|
@ -72,19 +59,12 @@ export default function upload(action, option) {
|
||||||
|
|
||||||
xhr.open('post', action, true);
|
xhr.open('post', action, true);
|
||||||
|
|
||||||
// Has to be after `.open()`. See https://github.com/enyo/dropzone/issues/179
|
|
||||||
if (option.withCredentials && 'withCredentials' in xhr) {
|
if (option.withCredentials && 'withCredentials' in xhr) {
|
||||||
xhr.withCredentials = true;
|
xhr.withCredentials = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const headers = option.headers || {};
|
const headers = option.headers || {};
|
||||||
|
|
||||||
// when set headers['X-Requested-With'] = null , can close default XHR header
|
|
||||||
// see https://github.com/react-component/upload/issues/33
|
|
||||||
// if (headers['X-Requested-With'] !== null) {
|
|
||||||
// xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
|
||||||
// }
|
|
||||||
|
|
||||||
for (let item in headers) {
|
for (let item in headers) {
|
||||||
if (headers.hasOwnProperty(item) && headers[item] !== null) {
|
if (headers.hasOwnProperty(item) && headers[item] !== null) {
|
||||||
xhr.setRequestHeader(item, headers[item]);
|
xhr.setRequestHeader(item, headers[item]);
|
||||||
|
|
Loading…
Reference in New Issue