1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import _extends from 'babel-runtime/helpers/extends';
import PropTypes from '../../_util/vue-types';
import { initDefaultProps } from '../../_util/props-util';
import BaseMixin from '../../_util/BaseMixin';
import AjaxUpload from './AjaxUploader';
import IframeUpload from './IframeUploader';
function empty() {}
var uploadProps = {
componentTag: PropTypes.string,
prefixCls: PropTypes.string,
action: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
name: PropTypes.string,
multipart: PropTypes.bool,
directory: PropTypes.bool,
// onError: PropTypes.func,
// onSuccess: PropTypes.func,
// onProgress: PropTypes.func,
// onStart: PropTypes.func,
data: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
headers: PropTypes.object,
accept: PropTypes.string,
multiple: PropTypes.bool,
disabled: PropTypes.bool,
beforeUpload: PropTypes.func,
customRequest: PropTypes.func,
// onReady: PropTypes.func,
withCredentials: PropTypes.bool,
supportServerRender: PropTypes.bool,
openFileDialogOnClick: PropTypes.bool
};
export default {
name: 'Upload',
mixins: [BaseMixin],
inheritAttrs: false,
props: initDefaultProps(uploadProps, {
componentTag: 'span',
prefixCls: 'rc-upload',
data: {},
headers: {},
name: 'file',
multipart: false,
// onReady: empty,
// onStart: empty,
// onError: empty,
// onSuccess: empty,
supportServerRender: false,
multiple: false,
beforeUpload: empty,
withCredentials: false,
openFileDialogOnClick: true
}),
data: function data() {
return {
Component: null
};
},
mounted: function mounted() {
var _this = this;
this.$nextTick(function () {
if (_this.supportServerRender) {
/* eslint react/no-did-mount-set-state:0 */
_this.setState({
Component: _this.getComponent()
}, function () {
_this.$emit('ready');
});
}
});
},
methods: {
getComponent: function getComponent() {
return typeof File !== 'undefined' ? AjaxUpload : IframeUpload;
},
abort: function abort(file) {
this.$refs.uploaderRef.abort(file);
}
},
render: function render() {
var h = arguments[0];
var componentProps = {
props: _extends({}, this.$props),
on: this.$listeners,
ref: 'uploaderRef',
attrs: this.$attrs
};
if (this.supportServerRender) {
var _ComponentUploader = this.Component;
if (_ComponentUploader) {
return h(
_ComponentUploader,
componentProps,
[this.$slots['default']]
);
}
return null;
}
var ComponentUploader = this.getComponent();
return h(
ComponentUploader,
componentProps,
[this.$slots['default']]
);
}
};