vue-devui 1.0.0-beta.1 → 1.0.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -45
- package/accordion/index.d.ts +7 -0
- package/accordion/index.es.js +460 -142
- package/accordion/index.umd.js +1 -1
- package/accordion/style.css +1 -1
- package/alert/index.d.ts +7 -0
- package/alert/index.es.js +7 -5
- package/alert/index.umd.js +1 -1
- package/alert/style.css +1 -1
- package/anchor/index.d.ts +7 -0
- package/avatar/index.d.ts +7 -0
- package/avatar/index.es.js +1 -1
- package/avatar/index.umd.js +1 -1
- package/back-top/index.d.ts +7 -0
- package/back-top/index.es.js +128 -0
- package/back-top/index.umd.js +1 -0
- package/back-top/package.json +7 -0
- package/back-top/style.css +1 -0
- package/badge/index.d.ts +7 -0
- package/badge/index.es.js +1 -1
- package/badge/index.umd.js +1 -1
- package/breadcrumb/index.d.ts +7 -0
- package/button/index.d.ts +7 -0
- package/button/index.es.js +218 -12
- package/button/index.umd.js +1 -1
- package/button/style.css +1 -1
- package/card/index.d.ts +7 -0
- package/card/index.es.js +1 -1
- package/card/index.umd.js +1 -1
- package/carousel/index.d.ts +7 -0
- package/carousel/index.es.js +5 -4
- package/carousel/index.umd.js +1 -1
- package/cascader/index.d.ts +7 -0
- package/cascader/index.es.js +1239 -83
- package/cascader/index.umd.js +1 -1
- package/cascader/style.css +1 -1
- package/checkbox/index.d.ts +7 -0
- package/checkbox/index.es.js +43 -8
- package/checkbox/index.umd.js +1 -1
- package/color-picker/index.d.ts +7 -0
- package/color-picker/index.es.js +2960 -0
- package/color-picker/index.umd.js +1 -0
- package/color-picker/package.json +7 -0
- package/color-picker/style.css +1 -0
- package/comment/index.d.ts +7 -0
- package/comment/index.es.js +85 -0
- package/comment/index.umd.js +1 -0
- package/comment/package.json +7 -0
- package/comment/style.css +1 -0
- package/countdown/index.d.ts +7 -0
- package/countdown/index.es.js +176 -0
- package/countdown/index.umd.js +1 -0
- package/countdown/package.json +7 -0
- package/countdown/style.css +1 -0
- package/date-picker/index.d.ts +7 -0
- package/date-picker/index.es.js +32 -21
- package/date-picker/index.umd.js +1 -1
- package/date-picker/style.css +1 -1
- package/dragdrop/index.d.ts +7 -0
- package/dragdrop/index.es.js +157 -0
- package/dragdrop/index.umd.js +1 -0
- package/dragdrop/package.json +7 -0
- package/drawer/index.d.ts +7 -0
- package/drawer/index.es.js +194 -42
- package/drawer/index.umd.js +1 -1
- package/drawer/style.css +1 -1
- package/dropdown/index.d.ts +7 -0
- package/dropdown/index.es.js +535 -0
- package/dropdown/index.umd.js +1 -0
- package/dropdown/package.json +7 -0
- package/dropdown/style.css +1 -0
- package/editable-select/index.d.ts +7 -0
- package/editable-select/index.es.js +5782 -469
- package/editable-select/index.umd.js +27 -1
- package/editable-select/style.css +1 -1
- package/form/index.d.ts +7 -0
- package/form/index.es.js +2257 -0
- package/form/index.umd.js +1 -0
- package/form/package.json +7 -0
- package/form/style.css +1 -0
- package/fullscreen/index.d.ts +7 -0
- package/fullscreen/index.es.js +14 -4
- package/fullscreen/index.umd.js +1 -1
- package/gantt/index.d.ts +7 -0
- package/gantt/index.es.js +535 -0
- package/gantt/index.umd.js +1 -0
- package/gantt/package.json +7 -0
- package/gantt/style.css +1 -0
- package/grid/index.d.ts +7 -0
- package/grid/index.es.js +269 -0
- package/grid/index.umd.js +1 -0
- package/grid/package.json +7 -0
- package/grid/style.css +1 -0
- package/icon/index.d.ts +7 -0
- package/icon/index.es.js +6 -5
- package/icon/index.umd.js +1 -1
- package/image-preview/index.d.ts +7 -0
- package/image-preview/index.es.js +99 -20
- package/image-preview/index.umd.js +1 -1
- package/image-preview/style.css +1 -1
- package/index.d.ts +7 -0
- package/input/index.d.ts +7 -0
- package/input/index.es.js +24 -13
- package/input/index.umd.js +1 -1
- package/input-icon/index.d.ts +7 -0
- package/input-icon/index.es.js +332 -0
- package/input-icon/index.umd.js +1 -0
- package/input-icon/package.json +7 -0
- package/input-icon/style.css +1 -0
- package/input-number/index.d.ts +7 -0
- package/input-number/index.es.js +5 -4
- package/input-number/index.umd.js +1 -1
- package/layout/index.d.ts +7 -0
- package/layout/index.es.js +1 -1
- package/layout/index.umd.js +1 -1
- package/loading/index.d.ts +7 -0
- package/loading/index.es.js +1 -1
- package/loading/index.umd.js +1 -1
- package/modal/index.d.ts +7 -0
- package/modal/index.es.js +328 -109
- package/modal/index.umd.js +1 -1
- package/modal/style.css +1 -1
- package/nav-sprite/index.d.ts +7 -0
- package/nuxt/components/Accordion.js +3 -0
- package/nuxt/components/Alert.js +3 -0
- package/nuxt/components/Anchor.js +3 -0
- package/nuxt/components/Aside.js +3 -0
- package/nuxt/components/Avatar.js +3 -0
- package/nuxt/components/BackTop.js +3 -0
- package/nuxt/components/Badge.js +3 -0
- package/nuxt/components/Breadcrumb.js +3 -0
- package/nuxt/components/Button.js +3 -0
- package/nuxt/components/Card.js +3 -0
- package/nuxt/components/Carousel.js +3 -0
- package/nuxt/components/Cascader.js +3 -0
- package/nuxt/components/Checkbox.js +3 -0
- package/nuxt/components/Col.js +3 -0
- package/nuxt/components/ColorPicker.js +3 -0
- package/nuxt/components/Column.js +3 -0
- package/nuxt/components/Comment.js +3 -0
- package/nuxt/components/Content.js +3 -0
- package/nuxt/components/Countdown.js +3 -0
- package/nuxt/components/DatePicker.js +3 -0
- package/nuxt/components/Drawer.js +3 -0
- package/nuxt/components/DrawerService.js +3 -0
- package/nuxt/components/Dropdown.js +3 -0
- package/nuxt/components/EditableSelect.js +3 -0
- package/nuxt/components/FixedOverlay.js +3 -0
- package/nuxt/components/FlexibleOverlay.js +3 -0
- package/nuxt/components/Footer.js +3 -0
- package/nuxt/components/Form.js +3 -0
- package/nuxt/components/FormControl.js +3 -0
- package/nuxt/components/FormItem.js +3 -0
- package/nuxt/components/FormLabel.js +3 -0
- package/nuxt/components/FormOperation.js +3 -0
- package/nuxt/components/Fullscreen.js +3 -0
- package/nuxt/components/Gantt.js +3 -0
- package/nuxt/components/Header.js +3 -0
- package/nuxt/components/Icon.js +2 -0
- package/nuxt/components/ImagePreviewService.js +3 -0
- package/nuxt/components/Input.js +3 -0
- package/nuxt/components/InputIcon.js +3 -0
- package/nuxt/components/InputNumber.js +3 -0
- package/nuxt/components/Layout.js +3 -0
- package/nuxt/components/Loading.js +3 -0
- package/nuxt/components/LoadingService.js +3 -0
- package/nuxt/components/Modal.js +3 -0
- package/nuxt/components/NavSprite.js +2 -0
- package/nuxt/components/Pagination.js +3 -0
- package/nuxt/components/Panel.js +3 -0
- package/nuxt/components/Popover.js +3 -0
- package/nuxt/components/Progress.js +3 -0
- package/nuxt/components/QuadrantDiagram.js +3 -0
- package/nuxt/components/Radio.js +3 -0
- package/nuxt/components/RadioGroup.js +3 -0
- package/nuxt/components/Rate.js +3 -0
- package/nuxt/components/ReadTip.js +3 -0
- package/nuxt/components/Result.js +3 -0
- package/nuxt/components/Row.js +3 -0
- package/nuxt/components/Search.js +3 -0
- package/nuxt/components/Select.js +3 -0
- package/nuxt/components/Skeleton.js +3 -0
- package/nuxt/components/SkeletonItem.js +3 -0
- package/nuxt/components/Slider.js +3 -0
- package/nuxt/components/Splitter.js +3 -0
- package/nuxt/components/Statistic.js +3 -0
- package/nuxt/components/Status.js +3 -0
- package/nuxt/components/StepsGuide.js +3 -0
- package/nuxt/components/StickSlider.js +3 -0
- package/nuxt/components/Sticky.js +2 -0
- package/nuxt/components/Switch.js +3 -0
- package/nuxt/components/Table.js +3 -0
- package/nuxt/components/Tabs.js +3 -0
- package/nuxt/components/Tag.js +3 -0
- package/nuxt/components/TagInput.js +3 -0
- package/nuxt/components/Textarea.js +3 -0
- package/nuxt/components/TimeAxis.js +3 -0
- package/nuxt/components/TimeAxisItem.js +3 -0
- package/nuxt/components/TimePicker.js +3 -0
- package/nuxt/components/Toast.js +3 -0
- package/nuxt/components/ToastService.js +3 -0
- package/nuxt/components/Tooltip.js +3 -0
- package/nuxt/components/Transfer.js +3 -0
- package/nuxt/components/Tree.js +3 -0
- package/nuxt/components/TreeSelect.js +3 -0
- package/nuxt/components/Upload.js +3 -0
- package/nuxt/components/buttonProps.js +3 -0
- package/nuxt/index.js +13 -0
- package/overlay/index.d.ts +7 -0
- package/overlay/index.es.js +111 -94
- package/overlay/index.umd.js +1 -1
- package/overlay/style.css +1 -1
- package/package.json +5 -47
- package/pagination/index.d.ts +7 -0
- package/pagination/index.es.js +3 -3
- package/pagination/index.umd.js +1 -1
- package/panel/index.d.ts +7 -0
- package/panel/index.es.js +25 -22
- package/panel/index.umd.js +1 -1
- package/panel/style.css +1 -1
- package/popover/index.d.ts +7 -0
- package/popover/index.es.js +18 -6
- package/popover/index.umd.js +1 -1
- package/progress/index.d.ts +7 -0
- package/progress/index.es.js +9 -9
- package/progress/index.umd.js +3 -3
- package/quadrant-diagram/index.d.ts +7 -0
- package/radio/index.d.ts +7 -0
- package/radio/index.es.js +6 -6
- package/radio/index.umd.js +1 -1
- package/rate/index.d.ts +7 -0
- package/rate/index.es.js +1 -1
- package/rate/index.umd.js +1 -1
- package/read-tip/index.d.ts +7 -0
- package/read-tip/index.es.js +258 -0
- package/read-tip/index.umd.js +1 -0
- package/read-tip/package.json +7 -0
- package/read-tip/style.css +1 -0
- package/result/index.d.ts +7 -0
- package/result/index.es.js +119 -0
- package/result/index.umd.js +1 -0
- package/result/package.json +7 -0
- package/result/style.css +1 -0
- package/ripple/index.d.ts +7 -0
- package/ripple/index.es.js +5 -2
- package/ripple/index.umd.js +1 -1
- package/search/index.d.ts +7 -0
- package/search/index.es.js +35 -21
- package/search/index.umd.js +1 -1
- package/select/index.d.ts +7 -0
- package/select/index.es.js +47 -11
- package/select/index.umd.js +1 -1
- package/skeleton/index.d.ts +7 -0
- package/skeleton/index.es.js +148 -26
- package/skeleton/index.umd.js +1 -1
- package/skeleton/style.css +1 -1
- package/slider/index.d.ts +7 -0
- package/slider/index.es.js +32 -182
- package/slider/index.umd.js +1 -1
- package/slider/style.css +1 -1
- package/splitter/index.d.ts +7 -0
- package/splitter/index.es.js +295 -100
- package/splitter/index.umd.js +1 -1
- package/splitter/style.css +1 -1
- package/statistic/index.d.ts +7 -0
- package/statistic/index.es.js +280 -0
- package/statistic/index.umd.js +1 -0
- package/statistic/package.json +7 -0
- package/statistic/style.css +1 -0
- package/status/index.d.ts +7 -0
- package/status/index.es.js +2 -2
- package/status/index.umd.js +1 -1
- package/steps-guide/index.d.ts +7 -0
- package/steps-guide/index.es.js +101 -73
- package/steps-guide/index.umd.js +1 -1
- package/steps-guide/style.css +1 -1
- package/sticky/index.d.ts +7 -0
- package/style.css +1 -1
- package/switch/index.d.ts +7 -0
- package/switch/index.es.js +1 -1
- package/switch/index.umd.js +1 -1
- package/table/index.d.ts +7 -0
- package/table/index.es.js +1708 -156
- package/table/index.umd.js +1 -1
- package/table/style.css +1 -1
- package/tabs/index.d.ts +7 -0
- package/tabs/index.es.js +6 -3
- package/tabs/index.umd.js +1 -1
- package/tag/index.d.ts +7 -0
- package/tag/index.es.js +131 -0
- package/tag/index.umd.js +1 -0
- package/tag/package.json +7 -0
- package/tag/style.css +1 -0
- package/tag-input/index.d.ts +7 -0
- package/tag-input/index.es.js +1 -13
- package/tag-input/index.umd.js +1 -1
- package/textarea/index.d.ts +7 -0
- package/textarea/index.es.js +132 -0
- package/textarea/index.umd.js +1 -0
- package/textarea/package.json +7 -0
- package/textarea/style.css +1 -0
- package/time-axis/index.d.ts +7 -0
- package/time-axis/index.es.js +241 -21
- package/time-axis/index.umd.js +1 -1
- package/time-axis/style.css +1 -1
- package/time-picker/index.d.ts +7 -0
- package/time-picker/index.es.js +266 -32
- package/time-picker/index.umd.js +1 -1
- package/time-picker/style.css +1 -1
- package/toast/index.d.ts +7 -0
- package/toast/index.es.js +16 -12
- package/toast/index.umd.js +1 -1
- package/toast/style.css +1 -1
- package/tooltip/index.d.ts +7 -0
- package/transfer/index.d.ts +7 -0
- package/transfer/index.es.js +575 -83
- package/transfer/index.umd.js +1 -1
- package/transfer/style.css +1 -1
- package/tree/index.d.ts +7 -0
- package/tree/index.es.js +171 -35
- package/tree/index.umd.js +1 -1
- package/tree-select/index.d.ts +7 -0
- package/tree-select/index.es.js +528 -0
- package/tree-select/index.umd.js +1 -0
- package/tree-select/package.json +7 -0
- package/tree-select/style.css +1 -0
- package/upload/index.d.ts +7 -0
- package/upload/index.es.js +172 -513
- package/upload/index.umd.js +1 -1
- package/upload/style.css +1 -1
- package/vue-devui.es.js +22079 -8773
- package/vue-devui.umd.js +29 -3
package/upload/index.es.js
CHANGED
|
@@ -21,7 +21,7 @@ var __publicField = (obj, key, value) => {
|
|
|
21
21
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
22
22
|
return value;
|
|
23
23
|
};
|
|
24
|
-
import { defineComponent, createVNode,
|
|
24
|
+
import { defineComponent, createVNode, getCurrentInstance, ref, computed, watch, nextTick, onUnmounted, mergeProps, createApp, toRefs, withDirectives, resolveComponent, isVNode, resolveDirective } from "vue";
|
|
25
25
|
var toast = "";
|
|
26
26
|
const toastProps = {
|
|
27
27
|
value: {
|
|
@@ -85,11 +85,12 @@ var Icon = defineComponent({
|
|
|
85
85
|
color,
|
|
86
86
|
classPrefix
|
|
87
87
|
} = this;
|
|
88
|
-
return
|
|
88
|
+
return /^((https?):)?\/\//.test(name) ? createVNode("img", {
|
|
89
89
|
"src": name,
|
|
90
90
|
"alt": name.split("/")[name.split("/").length - 1],
|
|
91
91
|
"style": {
|
|
92
|
-
width: size
|
|
92
|
+
width: size,
|
|
93
|
+
verticalAlign: "text-bottom"
|
|
93
94
|
}
|
|
94
95
|
}, null) : createVNode("i", {
|
|
95
96
|
"class": `${classPrefix} ${classPrefix}-${name}`,
|
|
@@ -97,7 +98,7 @@ var Icon = defineComponent({
|
|
|
97
98
|
fontSize: size,
|
|
98
99
|
color
|
|
99
100
|
}
|
|
100
|
-
}, null)
|
|
101
|
+
}, null);
|
|
101
102
|
}
|
|
102
103
|
});
|
|
103
104
|
Icon.install = function(app) {
|
|
@@ -140,7 +141,7 @@ var ToastImage = defineComponent({
|
|
|
140
141
|
const severityIconMap = {
|
|
141
142
|
info: "info-o",
|
|
142
143
|
success: "right-o",
|
|
143
|
-
|
|
144
|
+
warning: "warning-o",
|
|
144
145
|
error: "error-o"
|
|
145
146
|
};
|
|
146
147
|
const showIcon = () => severity !== "common";
|
|
@@ -148,7 +149,7 @@ var ToastImage = defineComponent({
|
|
|
148
149
|
"class": wrapperCls
|
|
149
150
|
}, [showIcon() ? createVNode(Icon, {
|
|
150
151
|
"name": severityIconMap[severity],
|
|
151
|
-
"size": "
|
|
152
|
+
"size": "16px"
|
|
152
153
|
}, null) : null]);
|
|
153
154
|
}
|
|
154
155
|
});
|
|
@@ -1739,7 +1740,7 @@ function useToastEvent() {
|
|
|
1739
1740
|
function useToastHelper() {
|
|
1740
1741
|
function severityDelay(msg) {
|
|
1741
1742
|
switch (msg.severity) {
|
|
1742
|
-
case "
|
|
1743
|
+
case "warning":
|
|
1743
1744
|
case "error":
|
|
1744
1745
|
return 1e4;
|
|
1745
1746
|
default:
|
|
@@ -1840,19 +1841,22 @@ var Toast = defineComponent({
|
|
|
1840
1841
|
if (props.lifeMode === "single") {
|
|
1841
1842
|
setTimeout(() => {
|
|
1842
1843
|
messages.value.forEach((msg, i) => {
|
|
1843
|
-
timeoutArr[i] = setTimeout(() => singleModeRemove(msg
|
|
1844
|
+
timeoutArr[i] = setTimeout(() => singleModeRemove(msg), msg.life || severityDelay(msg));
|
|
1844
1845
|
});
|
|
1845
1846
|
});
|
|
1846
1847
|
} else {
|
|
1847
1848
|
timeout = setTimeout(() => removeAll(), defaultLife.value);
|
|
1848
1849
|
}
|
|
1849
1850
|
}
|
|
1850
|
-
function singleModeRemove(msg
|
|
1851
|
+
function singleModeRemove(msg) {
|
|
1851
1852
|
removeMsgAnimation(msg);
|
|
1852
1853
|
setTimeout(() => {
|
|
1853
1854
|
onCloseEvent(msg);
|
|
1854
1855
|
if (hasMsgAnimation()) {
|
|
1855
|
-
messages.value.
|
|
1856
|
+
const index2 = messages.value.indexOf(msg);
|
|
1857
|
+
if (index2 !== -1) {
|
|
1858
|
+
messages.value.splice(index2, 1);
|
|
1859
|
+
}
|
|
1856
1860
|
} else {
|
|
1857
1861
|
messages.value = [];
|
|
1858
1862
|
}
|
|
@@ -1912,7 +1916,7 @@ var Toast = defineComponent({
|
|
|
1912
1916
|
if (props.lifeMode === "single") {
|
|
1913
1917
|
const msgLife = msg.life || severityDelay(msg);
|
|
1914
1918
|
const remainTime = msgLife - (Date.now() - timestamp);
|
|
1915
|
-
timeoutArr[i] = setTimeout(() => singleModeRemove(msg
|
|
1919
|
+
timeoutArr[i] = setTimeout(() => singleModeRemove(msg), remainTime);
|
|
1916
1920
|
} else {
|
|
1917
1921
|
resetDelay(() => removeAll());
|
|
1918
1922
|
}
|
|
@@ -2059,13 +2063,20 @@ var UploadStatus;
|
|
|
2059
2063
|
UploadStatus2[UploadStatus2["failed"] = 3] = "failed";
|
|
2060
2064
|
})(UploadStatus || (UploadStatus = {}));
|
|
2061
2065
|
const uploadProps = {
|
|
2066
|
+
accept: {
|
|
2067
|
+
type: String
|
|
2068
|
+
},
|
|
2069
|
+
webkitdirectory: {
|
|
2070
|
+
type: Boolean,
|
|
2071
|
+
default: false
|
|
2072
|
+
},
|
|
2062
2073
|
uploadOptions: {
|
|
2063
2074
|
type: Object,
|
|
2064
2075
|
required: true
|
|
2065
2076
|
},
|
|
2066
|
-
|
|
2067
|
-
type:
|
|
2068
|
-
|
|
2077
|
+
multiple: {
|
|
2078
|
+
type: Boolean,
|
|
2079
|
+
default: false
|
|
2069
2080
|
},
|
|
2070
2081
|
autoUpload: {
|
|
2071
2082
|
type: Boolean,
|
|
@@ -2101,10 +2112,6 @@ const uploadProps = {
|
|
|
2101
2112
|
type: Boolean,
|
|
2102
2113
|
default: false
|
|
2103
2114
|
},
|
|
2104
|
-
showTip: {
|
|
2105
|
-
type: Boolean,
|
|
2106
|
-
default: false
|
|
2107
|
-
},
|
|
2108
2115
|
onChange: {
|
|
2109
2116
|
type: Function
|
|
2110
2117
|
},
|
|
@@ -2120,96 +2127,128 @@ const uploadProps = {
|
|
|
2120
2127
|
type: Function,
|
|
2121
2128
|
default: void 0
|
|
2122
2129
|
},
|
|
2123
|
-
|
|
2130
|
+
deleteUploadedFile: {
|
|
2124
2131
|
type: Function,
|
|
2125
2132
|
default: void 0
|
|
2126
2133
|
},
|
|
2127
|
-
|
|
2134
|
+
"on-error": {
|
|
2128
2135
|
type: Function,
|
|
2129
2136
|
default: void 0
|
|
2130
2137
|
},
|
|
2131
|
-
|
|
2138
|
+
"on-success": {
|
|
2132
2139
|
type: Function,
|
|
2133
2140
|
default: void 0
|
|
2134
|
-
}
|
|
2135
|
-
};
|
|
2136
|
-
const multiUploadProps = {
|
|
2137
|
-
uploadOptions: {
|
|
2138
|
-
type: Object,
|
|
2139
|
-
required: true
|
|
2140
|
-
},
|
|
2141
|
-
fileOptions: {
|
|
2142
|
-
type: Object,
|
|
2143
|
-
required: true
|
|
2144
|
-
},
|
|
2145
|
-
autoUpload: {
|
|
2146
|
-
type: Boolean,
|
|
2147
|
-
default: false
|
|
2148
|
-
},
|
|
2149
|
-
withoutBtn: {
|
|
2150
|
-
type: Boolean,
|
|
2151
|
-
default: false
|
|
2152
|
-
},
|
|
2153
|
-
showTip: {
|
|
2154
|
-
type: Boolean,
|
|
2155
|
-
default: false
|
|
2156
|
-
},
|
|
2157
|
-
uploadedFiles: {
|
|
2158
|
-
type: Array,
|
|
2159
|
-
default: () => []
|
|
2160
|
-
},
|
|
2161
|
-
enableDrop: {
|
|
2162
|
-
type: Boolean,
|
|
2163
|
-
default: false
|
|
2164
|
-
},
|
|
2165
|
-
placeholderText: {
|
|
2166
|
-
type: String,
|
|
2167
|
-
default: "\u9009\u62E9\u6587\u4EF6"
|
|
2168
|
-
},
|
|
2169
|
-
uploadText: {
|
|
2170
|
-
type: String,
|
|
2171
|
-
default: "\u4E0A\u4F20"
|
|
2172
2141
|
},
|
|
2173
2142
|
oneTimeUpload: {
|
|
2174
2143
|
type: Boolean,
|
|
2175
2144
|
default: false
|
|
2176
|
-
},
|
|
2177
|
-
disabled: {
|
|
2178
|
-
type: Boolean,
|
|
2179
|
-
default: false
|
|
2180
|
-
},
|
|
2181
|
-
beforeUpload: {
|
|
2182
|
-
type: Function
|
|
2183
|
-
},
|
|
2184
|
-
fileDrop: {
|
|
2185
|
-
type: Function,
|
|
2186
|
-
default: void 0
|
|
2187
|
-
},
|
|
2188
|
-
fileOver: {
|
|
2189
|
-
type: Function,
|
|
2190
|
-
default: void 0
|
|
2191
|
-
},
|
|
2192
|
-
fileSelect: {
|
|
2193
|
-
type: Function,
|
|
2194
|
-
default: void 0
|
|
2195
|
-
},
|
|
2196
|
-
errorEvent: {
|
|
2197
|
-
type: Function,
|
|
2198
|
-
default: void 0
|
|
2199
|
-
},
|
|
2200
|
-
successEvent: {
|
|
2201
|
-
type: Function,
|
|
2202
|
-
default: void 0
|
|
2203
|
-
},
|
|
2204
|
-
deleteUploadedFileEvent: {
|
|
2205
|
-
type: Function,
|
|
2206
|
-
default: void 0
|
|
2207
|
-
},
|
|
2208
|
-
setCustomUploadOptions: {
|
|
2209
|
-
type: Function,
|
|
2210
|
-
default: void 0
|
|
2211
2145
|
}
|
|
2212
2146
|
};
|
|
2147
|
+
const getFailedFilesCount = (failedCount) => `${failedCount}\u4E2A\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25\uFF01`;
|
|
2148
|
+
const getUploadingFilesCount = (uploadingCount, filesCount) => `${uploadingCount}/${filesCount}\u6B63\u5728\u4E0A\u4F20`;
|
|
2149
|
+
const getSelectedFilesCount = (filesCount) => `\u5DF2\u6DFB\u52A0${filesCount}\u4E2A\u6587\u4EF6`;
|
|
2150
|
+
const getAllFilesBeyondMaximalFileSizeMsg = (maximalSize) => `\u6700\u5927\u652F\u6301\u4E0A\u4F20${maximalSize}MB\u7684\u6587\u4EF6, \u60A8\u672C\u6B21\u4E0A\u4F20\u7684\u6240\u6709\u6587\u4EF6\u8D85\u8FC7\u53EF\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F`;
|
|
2151
|
+
const getBeyondMaximalFileSizeMsg = (filename, maximalSize) => {
|
|
2152
|
+
return `\u6700\u5927\u652F\u6301\u4E0A\u4F20${maximalSize}MB\u7684\u6587\u4EF6, \u60A8\u4E0A\u4F20\u7684\u6587\u4EF6"${filename}"\u8D85\u8FC7\u53EF\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F`;
|
|
2153
|
+
};
|
|
2154
|
+
const getNotAllowedFileTypeMsg = (filename, scope) => {
|
|
2155
|
+
return `\u652F\u6301\u7684\u6587\u4EF6\u7C7B\u578B: "${scope}", \u60A8\u4E0A\u4F20\u7684\u6587\u4EF6"${filename}"\u4E0D\u5728\u5141\u8BB8\u8303\u56F4\u5185\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6`;
|
|
2156
|
+
};
|
|
2157
|
+
const getExistSameNameFilesMsg = (sameNames) => {
|
|
2158
|
+
return `\u60A8\u4E0A\u4F20\u7684 "${sameNames}" \u5B58\u5728\u91CD\u540D\u6587\u4EF6, \u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6`;
|
|
2159
|
+
};
|
|
2160
|
+
const useSelectFiles = () => {
|
|
2161
|
+
const BEYOND_MAXIMAL_FILE_SIZE_MSG = ref("");
|
|
2162
|
+
const simulateClickEvent = (input) => {
|
|
2163
|
+
const evt = document.createEvent("MouseEvents");
|
|
2164
|
+
evt.initMouseEvent("click", true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
|
|
2165
|
+
input.dispatchEvent(evt);
|
|
2166
|
+
};
|
|
2167
|
+
const selectFiles = ({ multiple, accept, webkitdirectory }) => {
|
|
2168
|
+
return new Promise((resolve) => {
|
|
2169
|
+
const tempNode = document.getElementById("d-upload-temp");
|
|
2170
|
+
if (tempNode) {
|
|
2171
|
+
document.body.removeChild(tempNode);
|
|
2172
|
+
}
|
|
2173
|
+
const input = document.createElement("input");
|
|
2174
|
+
input.style.position = "fixed";
|
|
2175
|
+
input.style.left = "-2000px";
|
|
2176
|
+
input.style.top = "-2000px";
|
|
2177
|
+
input.setAttribute("id", "d-upload-temp");
|
|
2178
|
+
input.setAttribute("type", "file");
|
|
2179
|
+
if (multiple) {
|
|
2180
|
+
input.setAttribute("multiple", "");
|
|
2181
|
+
}
|
|
2182
|
+
if (accept) {
|
|
2183
|
+
input.setAttribute("accept", accept);
|
|
2184
|
+
}
|
|
2185
|
+
if (webkitdirectory) {
|
|
2186
|
+
input.setAttribute("webkitdirectory", "");
|
|
2187
|
+
}
|
|
2188
|
+
input.addEventListener("change", (event) => {
|
|
2189
|
+
resolve(Array.prototype.slice.call(event.target.files));
|
|
2190
|
+
});
|
|
2191
|
+
document.body.appendChild(input);
|
|
2192
|
+
simulateClickEvent(input);
|
|
2193
|
+
});
|
|
2194
|
+
};
|
|
2195
|
+
const isAllowedFileType = (accept, file) => {
|
|
2196
|
+
if (accept) {
|
|
2197
|
+
const acceptArr = accept.split(",");
|
|
2198
|
+
const baseMimeType = file.type.replace(/\/.*$/, "");
|
|
2199
|
+
return acceptArr.some((type) => {
|
|
2200
|
+
const validType = type.trim();
|
|
2201
|
+
if (validType.startsWith(".")) {
|
|
2202
|
+
return file.name.toLowerCase().indexOf(validType.toLowerCase(), file.name.toLowerCase().length - validType.toLowerCase().length) > -1;
|
|
2203
|
+
} else if (/\/\*$/.test(validType)) {
|
|
2204
|
+
return baseMimeType === validType.replace(/\/.*$/, "");
|
|
2205
|
+
}
|
|
2206
|
+
return file.type === validType;
|
|
2207
|
+
});
|
|
2208
|
+
}
|
|
2209
|
+
return true;
|
|
2210
|
+
};
|
|
2211
|
+
const beyondMaximalSize = (fileSize, maximumSize) => {
|
|
2212
|
+
if (maximumSize) {
|
|
2213
|
+
return fileSize > 1024 * 1024 * maximumSize;
|
|
2214
|
+
}
|
|
2215
|
+
return false;
|
|
2216
|
+
};
|
|
2217
|
+
const _validateFiles = (file, accept, uploadOptions) => {
|
|
2218
|
+
if (!isAllowedFileType(accept, file)) {
|
|
2219
|
+
return {
|
|
2220
|
+
checkError: true,
|
|
2221
|
+
errorMsg: getNotAllowedFileTypeMsg(file.name, accept)
|
|
2222
|
+
};
|
|
2223
|
+
}
|
|
2224
|
+
if (uploadOptions && beyondMaximalSize(file.size, uploadOptions.maximumSize)) {
|
|
2225
|
+
return {
|
|
2226
|
+
checkError: true,
|
|
2227
|
+
errorMsg: getBeyondMaximalFileSizeMsg(file.name, uploadOptions.maximumSize)
|
|
2228
|
+
};
|
|
2229
|
+
}
|
|
2230
|
+
return { checkError: false, errorMsg: void 0 };
|
|
2231
|
+
};
|
|
2232
|
+
const triggerSelectFiles = (fileOptions) => {
|
|
2233
|
+
const { multiple, accept, webkitdirectory } = fileOptions;
|
|
2234
|
+
return selectFiles({ multiple, accept, webkitdirectory });
|
|
2235
|
+
};
|
|
2236
|
+
const triggerDropFiles = (files) => {
|
|
2237
|
+
return Promise.resolve(files);
|
|
2238
|
+
};
|
|
2239
|
+
const checkAllFilesSize = (fileSize, maximumSize) => {
|
|
2240
|
+
if (beyondMaximalSize(fileSize, maximumSize)) {
|
|
2241
|
+
BEYOND_MAXIMAL_FILE_SIZE_MSG.value = getAllFilesBeyondMaximalFileSizeMsg(maximumSize);
|
|
2242
|
+
return { checkError: true, errorMsg: BEYOND_MAXIMAL_FILE_SIZE_MSG.value };
|
|
2243
|
+
}
|
|
2244
|
+
};
|
|
2245
|
+
return {
|
|
2246
|
+
triggerSelectFiles,
|
|
2247
|
+
_validateFiles,
|
|
2248
|
+
triggerDropFiles,
|
|
2249
|
+
checkAllFilesSize
|
|
2250
|
+
};
|
|
2251
|
+
};
|
|
2213
2252
|
class FileUploader {
|
|
2214
2253
|
constructor(file, uploadOptions) {
|
|
2215
2254
|
__publicField(this, "xhr");
|
|
@@ -2411,402 +2450,17 @@ const useUpload = () => {
|
|
|
2411
2450
|
_oneTimeUpload
|
|
2412
2451
|
};
|
|
2413
2452
|
};
|
|
2414
|
-
const i18nText = {
|
|
2415
|
-
warning: "\u63D0\u9192",
|
|
2416
|
-
upload: "\u4E0A\u4F20",
|
|
2417
|
-
chooseFile: "\u9009\u62E9\u6587\u4EF6",
|
|
2418
|
-
chooseFiles: "\u9009\u62E9\u591A\u4E2A\u6587\u4EF6",
|
|
2419
|
-
preload: "\u9884\u52A0\u8F7D",
|
|
2420
|
-
uploading: "\u4E0A\u4F20\u4E2D...",
|
|
2421
|
-
uploaded: "\u5DF2\u4E0A\u4F20",
|
|
2422
|
-
uploadFailed: "\u4E0A\u4F20\u5931\u8D25",
|
|
2423
|
-
uploadSuccess: "\u4E0A\u4F20\u6210\u529F!",
|
|
2424
|
-
delete: "\u5220\u9664",
|
|
2425
|
-
reUpload: "\u91CD\u65B0\u4E0A\u4F20",
|
|
2426
|
-
cancelUpload: "\u53D6\u6D88\u4E0A\u4F20"
|
|
2427
|
-
};
|
|
2428
|
-
const getFailedFilesCount = (failedCount) => `${failedCount}\u4E2A\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25\uFF01`;
|
|
2429
|
-
const getUploadingFilesCount = (uploadingCount, filesCount) => `${uploadingCount}/${filesCount}\u6B63\u5728\u4E0A\u4F20`;
|
|
2430
|
-
const getSelectedFilesCount = (filesCount) => `\u5DF2\u6DFB\u52A0${filesCount}\u4E2A\u6587\u4EF6`;
|
|
2431
|
-
const getAllFilesBeyondMaximalFileSizeMsg = (maximalSize) => `\u6700\u5927\u652F\u6301\u4E0A\u4F20${maximalSize}MB\u7684\u6587\u4EF6, \u60A8\u672C\u6B21\u4E0A\u4F20\u7684\u6240\u6709\u6587\u4EF6\u8D85\u8FC7\u53EF\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F`;
|
|
2432
|
-
const getBeyondMaximalFileSizeMsg = (filename, maximalSize) => {
|
|
2433
|
-
return `\u6700\u5927\u652F\u6301\u4E0A\u4F20${maximalSize}MB\u7684\u6587\u4EF6, \u60A8\u4E0A\u4F20\u7684\u6587\u4EF6"${filename}"\u8D85\u8FC7\u53EF\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F`;
|
|
2434
|
-
};
|
|
2435
|
-
const getNotAllowedFileTypeMsg = (filename, scope) => {
|
|
2436
|
-
return `\u652F\u6301\u7684\u6587\u4EF6\u7C7B\u578B: "${scope}", \u60A8\u4E0A\u4F20\u7684\u6587\u4EF6"${filename}"\u4E0D\u5728\u5141\u8BB8\u8303\u56F4\u5185\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6`;
|
|
2437
|
-
};
|
|
2438
|
-
const getExistSameNameFilesMsg = (sameNames) => {
|
|
2439
|
-
return `\u60A8\u4E0A\u4F20\u7684 "${sameNames}" \u5B58\u5728\u91CD\u540D\u6587\u4EF6, \u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6`;
|
|
2440
|
-
};
|
|
2441
|
-
const useSelectFiles = () => {
|
|
2442
|
-
const BEYOND_MAXIMAL_FILE_SIZE_MSG = ref("");
|
|
2443
|
-
const simulateClickEvent = (input) => {
|
|
2444
|
-
const evt = document.createEvent("MouseEvents");
|
|
2445
|
-
evt.initMouseEvent("click", true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
|
|
2446
|
-
input.dispatchEvent(evt);
|
|
2447
|
-
};
|
|
2448
|
-
const selectFiles = ({
|
|
2449
|
-
multiple,
|
|
2450
|
-
accept,
|
|
2451
|
-
webkitdirectory
|
|
2452
|
-
}) => {
|
|
2453
|
-
return new Promise((resolve) => {
|
|
2454
|
-
const tempNode = document.getElementById("d-upload-temp");
|
|
2455
|
-
if (tempNode) {
|
|
2456
|
-
document.body.removeChild(tempNode);
|
|
2457
|
-
}
|
|
2458
|
-
const input = document.createElement("input");
|
|
2459
|
-
input.style.position = "fixed";
|
|
2460
|
-
input.style.left = "-2000px";
|
|
2461
|
-
input.style.top = "-2000px";
|
|
2462
|
-
input.setAttribute("id", "d-upload-temp");
|
|
2463
|
-
input.setAttribute("type", "file");
|
|
2464
|
-
if (multiple) {
|
|
2465
|
-
input.setAttribute("multiple", "");
|
|
2466
|
-
}
|
|
2467
|
-
if (accept) {
|
|
2468
|
-
input.setAttribute("accept", accept);
|
|
2469
|
-
}
|
|
2470
|
-
if (webkitdirectory) {
|
|
2471
|
-
input.setAttribute("webkitdirectory", "");
|
|
2472
|
-
}
|
|
2473
|
-
input.addEventListener("change", (event) => {
|
|
2474
|
-
resolve(Array.prototype.slice.call(event.target.files));
|
|
2475
|
-
});
|
|
2476
|
-
document.body.appendChild(input);
|
|
2477
|
-
simulateClickEvent(input);
|
|
2478
|
-
});
|
|
2479
|
-
};
|
|
2480
|
-
const isAllowedFileType = (accept, file) => {
|
|
2481
|
-
if (accept) {
|
|
2482
|
-
const acceptArr = accept.split(",");
|
|
2483
|
-
const baseMimeType = file.type.replace(/\/.*$/, "");
|
|
2484
|
-
return acceptArr.some((type) => {
|
|
2485
|
-
const validType = type.trim();
|
|
2486
|
-
if (validType.startsWith(".")) {
|
|
2487
|
-
return file.name.toLowerCase().indexOf(validType.toLowerCase(), file.name.toLowerCase().length - validType.toLowerCase().length) > -1;
|
|
2488
|
-
} else if (/\/\*$/.test(validType)) {
|
|
2489
|
-
return baseMimeType === validType.replace(/\/.*$/, "");
|
|
2490
|
-
}
|
|
2491
|
-
return file.type === validType;
|
|
2492
|
-
});
|
|
2493
|
-
}
|
|
2494
|
-
return true;
|
|
2495
|
-
};
|
|
2496
|
-
const beyondMaximalSize = (fileSize, maximumSize) => {
|
|
2497
|
-
if (maximumSize) {
|
|
2498
|
-
return fileSize > 1024 * 1024 * maximumSize;
|
|
2499
|
-
}
|
|
2500
|
-
return false;
|
|
2501
|
-
};
|
|
2502
|
-
const _validateFiles = (file, accept, uploadOptions) => {
|
|
2503
|
-
if (!isAllowedFileType(accept, file)) {
|
|
2504
|
-
return {
|
|
2505
|
-
checkError: true,
|
|
2506
|
-
errorMsg: getNotAllowedFileTypeMsg(file.name, accept)
|
|
2507
|
-
};
|
|
2508
|
-
}
|
|
2509
|
-
if (uploadOptions && beyondMaximalSize(file.size, uploadOptions.maximumSize)) {
|
|
2510
|
-
return {
|
|
2511
|
-
checkError: true,
|
|
2512
|
-
errorMsg: getBeyondMaximalFileSizeMsg(file.name, uploadOptions.maximumSize)
|
|
2513
|
-
};
|
|
2514
|
-
}
|
|
2515
|
-
return { checkError: false, errorMsg: void 0 };
|
|
2516
|
-
};
|
|
2517
|
-
const triggerSelectFiles = (fileOptions) => {
|
|
2518
|
-
const { multiple, accept, webkitdirectory } = fileOptions;
|
|
2519
|
-
return selectFiles({ multiple, accept, webkitdirectory });
|
|
2520
|
-
};
|
|
2521
|
-
const triggerDropFiles = (files) => {
|
|
2522
|
-
return Promise.resolve(files);
|
|
2523
|
-
};
|
|
2524
|
-
const checkAllFilesSize = (fileSize, maximumSize) => {
|
|
2525
|
-
if (beyondMaximalSize(fileSize, maximumSize)) {
|
|
2526
|
-
BEYOND_MAXIMAL_FILE_SIZE_MSG.value = getAllFilesBeyondMaximalFileSizeMsg(maximumSize);
|
|
2527
|
-
return { checkError: true, errorMsg: BEYOND_MAXIMAL_FILE_SIZE_MSG.value };
|
|
2528
|
-
}
|
|
2529
|
-
};
|
|
2530
|
-
return {
|
|
2531
|
-
triggerSelectFiles,
|
|
2532
|
-
_validateFiles,
|
|
2533
|
-
triggerDropFiles,
|
|
2534
|
-
checkAllFilesSize
|
|
2535
|
-
};
|
|
2536
|
-
};
|
|
2537
2453
|
var upload = "";
|
|
2538
|
-
var Upload = defineComponent({
|
|
2539
|
-
name: "DSingleUpload",
|
|
2540
|
-
props: uploadProps,
|
|
2541
|
-
emits: ["fileDrop", "fileOver", "fileSelect", "successEvent", "errorEvent", "deleteUploadedFileEvent", "update:uploadedFiles"],
|
|
2542
|
-
setup(props, ctx) {
|
|
2543
|
-
const {
|
|
2544
|
-
uploadOptions,
|
|
2545
|
-
fileOptions,
|
|
2546
|
-
placeholderText,
|
|
2547
|
-
autoUpload,
|
|
2548
|
-
withoutBtn,
|
|
2549
|
-
uploadText,
|
|
2550
|
-
disabled,
|
|
2551
|
-
beforeUpload,
|
|
2552
|
-
enableDrop,
|
|
2553
|
-
showTip,
|
|
2554
|
-
uploadedFiles
|
|
2555
|
-
} = toRefs(props);
|
|
2556
|
-
const isDropOVer = ref(false);
|
|
2557
|
-
const {
|
|
2558
|
-
getFiles,
|
|
2559
|
-
fileUploaders,
|
|
2560
|
-
addFile,
|
|
2561
|
-
getFullFiles,
|
|
2562
|
-
deleteFile,
|
|
2563
|
-
upload: upload2,
|
|
2564
|
-
removeFiles
|
|
2565
|
-
} = useUpload();
|
|
2566
|
-
const {
|
|
2567
|
-
triggerSelectFiles,
|
|
2568
|
-
_validateFiles,
|
|
2569
|
-
triggerDropFiles
|
|
2570
|
-
} = useSelectFiles();
|
|
2571
|
-
const filename = computed(() => (getFiles()[0] || {}).name || "");
|
|
2572
|
-
const alertMsg = (errorMsg) => {
|
|
2573
|
-
ToastService.open({
|
|
2574
|
-
value: [{
|
|
2575
|
-
severity: "warn",
|
|
2576
|
-
content: errorMsg
|
|
2577
|
-
}]
|
|
2578
|
-
});
|
|
2579
|
-
};
|
|
2580
|
-
const canUpload = () => {
|
|
2581
|
-
let uploadResult = Promise.resolve(true);
|
|
2582
|
-
if (beforeUpload.value) {
|
|
2583
|
-
const result = beforeUpload.value(getFullFiles()[0] || {});
|
|
2584
|
-
if (typeof result !== "undefined") {
|
|
2585
|
-
if (result.then) {
|
|
2586
|
-
uploadResult = result;
|
|
2587
|
-
} else {
|
|
2588
|
-
uploadResult = Promise.resolve(result);
|
|
2589
|
-
}
|
|
2590
|
-
}
|
|
2591
|
-
}
|
|
2592
|
-
return uploadResult;
|
|
2593
|
-
};
|
|
2594
|
-
const fileUpload = () => {
|
|
2595
|
-
canUpload().then((canUpload2) => {
|
|
2596
|
-
if (!canUpload2) {
|
|
2597
|
-
return;
|
|
2598
|
-
}
|
|
2599
|
-
upload2().then((results) => {
|
|
2600
|
-
ctx.emit("successEvent", results);
|
|
2601
|
-
const newFiles = results.map((result) => result.file);
|
|
2602
|
-
const newUploadedFiles = [...newFiles, ...uploadedFiles.value];
|
|
2603
|
-
ctx.emit("update:uploadedFiles", newUploadedFiles);
|
|
2604
|
-
}).catch((error) => {
|
|
2605
|
-
console.error(error);
|
|
2606
|
-
if (fileUploaders.value[0]) {
|
|
2607
|
-
fileUploaders.value[0].percentage = 0;
|
|
2608
|
-
}
|
|
2609
|
-
ctx.emit("errorEvent", error);
|
|
2610
|
-
});
|
|
2611
|
-
});
|
|
2612
|
-
};
|
|
2613
|
-
const checkValid = () => {
|
|
2614
|
-
fileUploaders.value.forEach((fileUploader) => {
|
|
2615
|
-
const checkResult = _validateFiles(fileUploader.file, fileOptions.value.accept, fileUploader.uploadOptions);
|
|
2616
|
-
if (checkResult.checkError) {
|
|
2617
|
-
deleteFile(fileUploader.file);
|
|
2618
|
-
alertMsg(checkResult.errorMsg);
|
|
2619
|
-
}
|
|
2620
|
-
});
|
|
2621
|
-
};
|
|
2622
|
-
const _dealFiles = (promise) => {
|
|
2623
|
-
promise.then((files) => {
|
|
2624
|
-
var _a;
|
|
2625
|
-
files.forEach((file2) => {
|
|
2626
|
-
removeFiles();
|
|
2627
|
-
addFile(file2, uploadOptions.value);
|
|
2628
|
-
});
|
|
2629
|
-
checkValid();
|
|
2630
|
-
const file = (_a = fileUploaders.value[0]) == null ? void 0 : _a.file;
|
|
2631
|
-
if (props.onChange) {
|
|
2632
|
-
props.onChange(file);
|
|
2633
|
-
}
|
|
2634
|
-
if (file) {
|
|
2635
|
-
ctx.emit("fileSelect", file);
|
|
2636
|
-
}
|
|
2637
|
-
if (autoUpload.value) {
|
|
2638
|
-
fileUpload();
|
|
2639
|
-
}
|
|
2640
|
-
}).catch((error) => {
|
|
2641
|
-
alertMsg(error.message);
|
|
2642
|
-
});
|
|
2643
|
-
};
|
|
2644
|
-
const handleClick = () => {
|
|
2645
|
-
var _a;
|
|
2646
|
-
if (disabled.value || fileUploaders.value[0] && ((_a = fileUploaders.value[0]) == null ? void 0 : _a.status) === UploadStatus.uploading) {
|
|
2647
|
-
return;
|
|
2648
|
-
}
|
|
2649
|
-
_dealFiles(triggerSelectFiles(fileOptions.value));
|
|
2650
|
-
};
|
|
2651
|
-
const onDeleteFile = (event) => {
|
|
2652
|
-
event.stopPropagation();
|
|
2653
|
-
const files = getFiles();
|
|
2654
|
-
deleteFile(files[0]);
|
|
2655
|
-
};
|
|
2656
|
-
const deleteUploadedFile = (file) => {
|
|
2657
|
-
const newUploadedFiles = uploadedFiles.value.filter((uploadedFile) => {
|
|
2658
|
-
return uploadedFile.name !== file.name;
|
|
2659
|
-
});
|
|
2660
|
-
ctx.emit("deleteUploadedFileEvent", file);
|
|
2661
|
-
ctx.emit("update:uploadedFiles", newUploadedFiles);
|
|
2662
|
-
};
|
|
2663
|
-
const onFileDrop = (files) => {
|
|
2664
|
-
isDropOVer.value = false;
|
|
2665
|
-
_dealFiles(triggerDropFiles(files));
|
|
2666
|
-
ctx.emit("fileDrop", files[0]);
|
|
2667
|
-
};
|
|
2668
|
-
const onFileOver = (event) => {
|
|
2669
|
-
isDropOVer.value = event;
|
|
2670
|
-
ctx.emit("fileOver", event);
|
|
2671
|
-
};
|
|
2672
|
-
return {
|
|
2673
|
-
placeholderText,
|
|
2674
|
-
filename,
|
|
2675
|
-
autoUpload,
|
|
2676
|
-
withoutBtn,
|
|
2677
|
-
fileUploaders,
|
|
2678
|
-
uploadText,
|
|
2679
|
-
handleClick,
|
|
2680
|
-
onDeleteFile,
|
|
2681
|
-
fileUpload,
|
|
2682
|
-
enableDrop,
|
|
2683
|
-
onFileDrop,
|
|
2684
|
-
onFileOver,
|
|
2685
|
-
isDropOVer,
|
|
2686
|
-
showTip,
|
|
2687
|
-
uploadedFiles,
|
|
2688
|
-
deleteUploadedFile
|
|
2689
|
-
};
|
|
2690
|
-
},
|
|
2691
|
-
render() {
|
|
2692
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
2693
|
-
const {
|
|
2694
|
-
placeholderText,
|
|
2695
|
-
filename,
|
|
2696
|
-
autoUpload,
|
|
2697
|
-
withoutBtn,
|
|
2698
|
-
fileUploaders,
|
|
2699
|
-
uploadText,
|
|
2700
|
-
handleClick,
|
|
2701
|
-
onDeleteFile,
|
|
2702
|
-
fileUpload,
|
|
2703
|
-
enableDrop,
|
|
2704
|
-
onFileDrop,
|
|
2705
|
-
onFileOver,
|
|
2706
|
-
isDropOVer,
|
|
2707
|
-
disabled,
|
|
2708
|
-
showTip,
|
|
2709
|
-
uploadedFiles,
|
|
2710
|
-
deleteUploadedFile
|
|
2711
|
-
} = this;
|
|
2712
|
-
return createVNode("div", null, [withDirectives(createVNode("div", {
|
|
2713
|
-
"class": "devui-upload",
|
|
2714
|
-
"style": `border: ${isDropOVer ? "1px solid #15bf15" : "0"}`
|
|
2715
|
-
}, [((_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a)) ? createVNode("div", {
|
|
2716
|
-
"onClick": handleClick
|
|
2717
|
-
}, [this.$slots.default()]) : createVNode("div", {
|
|
2718
|
-
"class": `devui-input-group ${disabled || ((_c = fileUploaders[0]) == null ? void 0 : _c.status) === UploadStatus.uploading ? "disabled" : ""}`,
|
|
2719
|
-
"onClick": handleClick
|
|
2720
|
-
}, [createVNode("div", {
|
|
2721
|
-
"class": "devui-form-control devui-files-list"
|
|
2722
|
-
}, [!filename && createVNode("div", {
|
|
2723
|
-
"class": "devui-file-item devui-upload-placeholder"
|
|
2724
|
-
}, [placeholderText]), !!filename && createVNode("div", {
|
|
2725
|
-
"class": "devui-file-tag devui-file-item",
|
|
2726
|
-
"title": filename,
|
|
2727
|
-
"style": "display: inline-block; margin: 0 2px 2px 0"
|
|
2728
|
-
}, [createVNode("span", {
|
|
2729
|
-
"class": `devui-filename ${((_d = fileUploaders[0]) == null ? void 0 : _d.status) === UploadStatus.failed ? "devui-failed-color" : ""}`
|
|
2730
|
-
}, [filename]), createVNode(resolveComponent("d-icon"), {
|
|
2731
|
-
"name": "close",
|
|
2732
|
-
"class": `${((_e = fileUploaders[0]) == null ? void 0 : _e.status) === UploadStatus.failed ? "devui-upload-delete-file-button" : ""} ${((_f = fileUploaders[0]) == null ? void 0 : _f.status) === UploadStatus.uploading || ((_g = fileUploaders[0]) == null ? void 0 : _g.status) === UploadStatus.uploaded ? "devui-uploading-delete" : ""}`,
|
|
2733
|
-
"onClick": (event) => onDeleteFile(event)
|
|
2734
|
-
}, null), ((_h = fileUploaders[0]) == null ? void 0 : _h.status) === UploadStatus.uploading && createVNode("div", {
|
|
2735
|
-
"class": "icon devui-upload-progress"
|
|
2736
|
-
}, [createVNode(resolveComponent("d-progress"), {
|
|
2737
|
-
"isCircle": true,
|
|
2738
|
-
"percentage": fileUploaders[0].percentage,
|
|
2739
|
-
"barbgcolor": "#50D4AB",
|
|
2740
|
-
"strokeWidth": 8,
|
|
2741
|
-
"showContent": false
|
|
2742
|
-
}, null)]), fileUploaders[0].status === UploadStatus.failed && createVNode(resolveComponent("d-icon"), {
|
|
2743
|
-
"name": "running",
|
|
2744
|
-
"onClick": fileUpload
|
|
2745
|
-
}, null), fileUploaders[0].status === UploadStatus.uploaded && createVNode(resolveComponent("d-icon"), {
|
|
2746
|
-
"name": "right",
|
|
2747
|
-
"color": "#50d4ab"
|
|
2748
|
-
}, null)])]), createVNode("span", {
|
|
2749
|
-
"class": "devui-input-group-addon"
|
|
2750
|
-
}, [createVNode(resolveComponent("d-icon"), {
|
|
2751
|
-
"name": "more-operate",
|
|
2752
|
-
"color": "#252b3a"
|
|
2753
|
-
}, null)])]), !autoUpload && !withoutBtn && createVNode(resolveComponent("d-button"), {
|
|
2754
|
-
"style": "marginLeft: 8px",
|
|
2755
|
-
"bsStyle": "common",
|
|
2756
|
-
"onClick": fileUpload,
|
|
2757
|
-
"disabled": disabled || ((_i = fileUploaders[0]) == null ? void 0 : _i.status) === UploadStatus.uploading
|
|
2758
|
-
}, {
|
|
2759
|
-
default: () => {
|
|
2760
|
-
var _a2, _b2, _c2, _d2;
|
|
2761
|
-
return [(!fileUploaders[0] || !((_a2 = fileUploaders[0]) == null ? void 0 : _a2.status)) && createVNode("span", null, [uploadText]), ((_b2 = fileUploaders[0]) == null ? void 0 : _b2.status) === UploadStatus.uploading && createVNode("span", null, [createTextVNode("\u4E0A\u4F20\u4E2D...")]), ((_c2 = fileUploaders[0]) == null ? void 0 : _c2.status) === UploadStatus.uploaded && createVNode("span", null, [createTextVNode("\u5DF2\u4E0A\u4F20")]), ((_d2 = fileUploaders[0]) == null ? void 0 : _d2.status) === UploadStatus.failed && createVNode("span", null, [createTextVNode("\u4E0A\u4F20\u5931\u8D25")])];
|
|
2762
|
-
}
|
|
2763
|
-
})]), [[resolveDirective("file-drop"), {
|
|
2764
|
-
enableDrop,
|
|
2765
|
-
isSingle: true,
|
|
2766
|
-
onFileDrop,
|
|
2767
|
-
onFileOver
|
|
2768
|
-
}]]), showTip && createVNode("div", {
|
|
2769
|
-
"class": "devui-upload-tip"
|
|
2770
|
-
}, [((_j = fileUploaders[0]) == null ? void 0 : _j.status) === UploadStatus.uploading && createVNode("span", {
|
|
2771
|
-
"class": "devui-loading"
|
|
2772
|
-
}, [i18nText.uploading]), ((_k = fileUploaders[0]) == null ? void 0 : _k.status) === UploadStatus.uploaded && createVNode("div", {
|
|
2773
|
-
"class": "devui-loaded"
|
|
2774
|
-
}, [createVNode(resolveComponent("d-icon"), {
|
|
2775
|
-
"name": "right-o",
|
|
2776
|
-
"color": "#50d4ab"
|
|
2777
|
-
}, null), createVNode("span", {
|
|
2778
|
-
"style": "vertical-align: middle"
|
|
2779
|
-
}, [i18nText.uploadSuccess])]), ((_l = fileUploaders[0]) == null ? void 0 : _l.status) === UploadStatus.failed && createVNode("div", {
|
|
2780
|
-
"class": "devui-upload-failed"
|
|
2781
|
-
}, [createVNode(resolveComponent("d-icon"), {
|
|
2782
|
-
"name": "info-o",
|
|
2783
|
-
"color": "#f66f6a"
|
|
2784
|
-
}, null), createVNode("span", {
|
|
2785
|
-
"style": "vertical-align: middle"
|
|
2786
|
-
}, [createVNode("span", {
|
|
2787
|
-
"style": "margin-right: 8px"
|
|
2788
|
-
}, [i18nText.uploadFailed]), createVNode("a", {
|
|
2789
|
-
"onClick": fileUpload
|
|
2790
|
-
}, [i18nText.reUpload])])])]), createVNode("div", null, [(_n = (_m = this.$slots).preloadFiles) == null ? void 0 : _n.call(_m, {
|
|
2791
|
-
fileUploaders,
|
|
2792
|
-
deleteFile: onDeleteFile
|
|
2793
|
-
})]), createVNode("div", null, [(_p = (_o = this.$slots).uploadedFiles) == null ? void 0 : _p.call(_o, {
|
|
2794
|
-
uploadedFiles,
|
|
2795
|
-
deleteFile: deleteUploadedFile
|
|
2796
|
-
})])]);
|
|
2797
|
-
}
|
|
2798
|
-
});
|
|
2799
2454
|
function _isSlot(s) {
|
|
2800
2455
|
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
2801
2456
|
}
|
|
2802
|
-
var
|
|
2803
|
-
name: "
|
|
2804
|
-
props:
|
|
2805
|
-
emits: ["fileDrop", "fileOver", "fileSelect", "
|
|
2457
|
+
var Upload = defineComponent({
|
|
2458
|
+
name: "DUpload",
|
|
2459
|
+
props: uploadProps,
|
|
2460
|
+
emits: ["fileDrop", "fileOver", "fileSelect", "deleteUploadedFile", "update:uploadedFiles"],
|
|
2806
2461
|
setup(props, ctx) {
|
|
2807
2462
|
const {
|
|
2808
2463
|
uploadOptions,
|
|
2809
|
-
fileOptions,
|
|
2810
2464
|
placeholderText,
|
|
2811
2465
|
autoUpload,
|
|
2812
2466
|
withoutBtn,
|
|
@@ -2815,8 +2469,10 @@ var MultiUpload = defineComponent({
|
|
|
2815
2469
|
beforeUpload,
|
|
2816
2470
|
enableDrop,
|
|
2817
2471
|
oneTimeUpload,
|
|
2818
|
-
|
|
2819
|
-
|
|
2472
|
+
uploadedFiles,
|
|
2473
|
+
multiple,
|
|
2474
|
+
accept,
|
|
2475
|
+
webkitdirectory
|
|
2820
2476
|
} = toRefs(props);
|
|
2821
2477
|
const {
|
|
2822
2478
|
triggerSelectFiles,
|
|
@@ -2825,7 +2481,6 @@ var MultiUpload = defineComponent({
|
|
|
2825
2481
|
checkAllFilesSize
|
|
2826
2482
|
} = useSelectFiles();
|
|
2827
2483
|
const {
|
|
2828
|
-
getFiles,
|
|
2829
2484
|
fileUploaders,
|
|
2830
2485
|
addFile,
|
|
2831
2486
|
getFullFiles,
|
|
@@ -2850,7 +2505,7 @@ var MultiUpload = defineComponent({
|
|
|
2850
2505
|
let totalFileSize = 0;
|
|
2851
2506
|
fileUploaders.value.forEach((fileUploader) => {
|
|
2852
2507
|
totalFileSize += fileUploader.file.size;
|
|
2853
|
-
const checkResult = _validateFiles(fileUploader.file,
|
|
2508
|
+
const checkResult = _validateFiles(fileUploader.file, accept.value, fileUploader.uploadOptions);
|
|
2854
2509
|
if (checkResult && checkResult.checkError) {
|
|
2855
2510
|
deleteFile(fileUploader.file);
|
|
2856
2511
|
alertMsg(checkResult.errorMsg);
|
|
@@ -2869,6 +2524,9 @@ var MultiUpload = defineComponent({
|
|
|
2869
2524
|
resetSameNameFiles();
|
|
2870
2525
|
promise.then((files) => {
|
|
2871
2526
|
files.forEach((file) => {
|
|
2527
|
+
if (!multiple.value) {
|
|
2528
|
+
removeFiles();
|
|
2529
|
+
}
|
|
2872
2530
|
addFile(file, uploadOptions.value);
|
|
2873
2531
|
});
|
|
2874
2532
|
checkValid();
|
|
@@ -2879,7 +2537,7 @@ var MultiUpload = defineComponent({
|
|
|
2879
2537
|
const selectedFiles = fileUploaders.value.filter((fileUploader) => fileUploader.status === UploadStatus.preLoad).map((fileUploader) => fileUploader.file);
|
|
2880
2538
|
ctx.emit("fileSelect", selectedFiles);
|
|
2881
2539
|
if (autoUpload.value) {
|
|
2882
|
-
|
|
2540
|
+
fileUpload();
|
|
2883
2541
|
}
|
|
2884
2542
|
}).catch((error) => {
|
|
2885
2543
|
alertMsg(error.message);
|
|
@@ -2889,7 +2547,11 @@ var MultiUpload = defineComponent({
|
|
|
2889
2547
|
if (disabled.value) {
|
|
2890
2548
|
return;
|
|
2891
2549
|
}
|
|
2892
|
-
_dealFiles(triggerSelectFiles(
|
|
2550
|
+
_dealFiles(triggerSelectFiles({
|
|
2551
|
+
accept: accept.value,
|
|
2552
|
+
multiple: multiple.value,
|
|
2553
|
+
webkitdirectory: webkitdirectory.value
|
|
2554
|
+
}));
|
|
2893
2555
|
};
|
|
2894
2556
|
const onFileDrop = (files) => {
|
|
2895
2557
|
isDropOVer.value = false;
|
|
@@ -2900,17 +2562,20 @@ var MultiUpload = defineComponent({
|
|
|
2900
2562
|
isDropOVer.value = event;
|
|
2901
2563
|
ctx.emit("fileOver", event);
|
|
2902
2564
|
};
|
|
2903
|
-
const onDeleteFile = (event, file) => {
|
|
2904
|
-
event.stopPropagation();
|
|
2905
|
-
deleteFile(file);
|
|
2906
|
-
};
|
|
2907
2565
|
const deleteUploadedFile = (file) => {
|
|
2908
2566
|
const newUploadedFiles = uploadedFiles.value.filter((uploadedFile) => {
|
|
2909
2567
|
return uploadedFile.name !== file.name;
|
|
2910
2568
|
});
|
|
2911
|
-
ctx.emit("
|
|
2569
|
+
ctx.emit("deleteUploadedFile", file);
|
|
2912
2570
|
ctx.emit("update:uploadedFiles", newUploadedFiles);
|
|
2913
2571
|
};
|
|
2572
|
+
const onDeleteFile = (event, file, status) => {
|
|
2573
|
+
event.stopPropagation();
|
|
2574
|
+
if (status === UploadStatus.uploaded) {
|
|
2575
|
+
deleteUploadedFile(file);
|
|
2576
|
+
}
|
|
2577
|
+
deleteFile(file);
|
|
2578
|
+
};
|
|
2914
2579
|
const canUpload = () => {
|
|
2915
2580
|
let uploadResult = Promise.resolve(true);
|
|
2916
2581
|
if (beforeUpload.value) {
|
|
@@ -2936,12 +2601,12 @@ var MultiUpload = defineComponent({
|
|
|
2936
2601
|
}
|
|
2937
2602
|
const uploadObservable = oneTimeUpload.value ? _oneTimeUpload() : upload2(fileUploader);
|
|
2938
2603
|
uploadObservable.then((results) => {
|
|
2939
|
-
|
|
2604
|
+
props["on-success"] && props["on-success"](results);
|
|
2940
2605
|
const newFiles = results.map((result) => result.file);
|
|
2941
2606
|
const newUploadedFiles = [...newFiles, ...uploadedFiles.value];
|
|
2942
2607
|
ctx.emit("update:uploadedFiles", newUploadedFiles);
|
|
2943
2608
|
}).catch((error) => {
|
|
2944
|
-
|
|
2609
|
+
props["on-error"] && props["on-error"](error);
|
|
2945
2610
|
});
|
|
2946
2611
|
});
|
|
2947
2612
|
};
|
|
@@ -2986,7 +2651,6 @@ var MultiUpload = defineComponent({
|
|
|
2986
2651
|
};
|
|
2987
2652
|
return {
|
|
2988
2653
|
uploadOptions,
|
|
2989
|
-
fileOptions,
|
|
2990
2654
|
placeholderText,
|
|
2991
2655
|
autoUpload,
|
|
2992
2656
|
withoutBtn,
|
|
@@ -3001,11 +2665,11 @@ var MultiUpload = defineComponent({
|
|
|
3001
2665
|
fileUploaders,
|
|
3002
2666
|
onDeleteFile,
|
|
3003
2667
|
fileUpload,
|
|
3004
|
-
showTip,
|
|
3005
2668
|
getStatus,
|
|
3006
2669
|
uploadTips,
|
|
3007
2670
|
cancelUpload,
|
|
3008
|
-
deleteUploadedFile
|
|
2671
|
+
deleteUploadedFile,
|
|
2672
|
+
multiple
|
|
3009
2673
|
};
|
|
3010
2674
|
},
|
|
3011
2675
|
render() {
|
|
@@ -3016,7 +2680,6 @@ var MultiUpload = defineComponent({
|
|
|
3016
2680
|
withoutBtn,
|
|
3017
2681
|
uploadText,
|
|
3018
2682
|
disabled,
|
|
3019
|
-
beforeUpload,
|
|
3020
2683
|
enableDrop,
|
|
3021
2684
|
isDropOVer,
|
|
3022
2685
|
onFileDrop,
|
|
@@ -3025,14 +2688,11 @@ var MultiUpload = defineComponent({
|
|
|
3025
2688
|
fileUploaders,
|
|
3026
2689
|
onDeleteFile,
|
|
3027
2690
|
fileUpload,
|
|
3028
|
-
showTip,
|
|
3029
|
-
getStatus,
|
|
3030
|
-
uploadTips,
|
|
3031
|
-
cancelUpload,
|
|
3032
2691
|
uploadedFiles,
|
|
3033
|
-
deleteUploadedFile
|
|
2692
|
+
deleteUploadedFile,
|
|
2693
|
+
multiple
|
|
3034
2694
|
} = this;
|
|
3035
|
-
return createVNode(
|
|
2695
|
+
return createVNode("div", null, [withDirectives(createVNode("div", {
|
|
3036
2696
|
"class": "devui-upload",
|
|
3037
2697
|
"style": `border: ${isDropOVer ? "1px solid #15bf15" : "0"}`
|
|
3038
2698
|
}, [((_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a)) ? createVNode("div", {
|
|
@@ -3054,7 +2714,7 @@ var MultiUpload = defineComponent({
|
|
|
3054
2714
|
}, [fileUploader.file.name]), createVNode(resolveComponent("d-icon"), {
|
|
3055
2715
|
"name": "close",
|
|
3056
2716
|
"class": `${(fileUploader == null ? void 0 : fileUploader.status) === UploadStatus.failed ? "devui-upload-delete-file-button" : ""} ${(fileUploader == null ? void 0 : fileUploader.status) === UploadStatus.uploading || (fileUploader == null ? void 0 : fileUploader.status) === UploadStatus.uploaded ? "devui-uploading-delete" : ""}`,
|
|
3057
|
-
"onClick": (event) => onDeleteFile(event, fileUploader.file)
|
|
2717
|
+
"onClick": (event) => onDeleteFile(event, fileUploader.file, fileUploader.status)
|
|
3058
2718
|
}, null), fileUploader.status === UploadStatus.uploading && createVNode("div", {
|
|
3059
2719
|
"class": "icon devui-upload-progress"
|
|
3060
2720
|
}, [createVNode(resolveComponent("d-progress"), {
|
|
@@ -3076,14 +2736,14 @@ var MultiUpload = defineComponent({
|
|
|
3076
2736
|
"color": "#252b3a"
|
|
3077
2737
|
}, null)])]), !autoUpload && !withoutBtn && createVNode(resolveComponent("d-button"), {
|
|
3078
2738
|
"style": "marginLeft: 8px",
|
|
3079
|
-
"
|
|
2739
|
+
"variant": "common",
|
|
3080
2740
|
"disabled": disabled,
|
|
3081
2741
|
"onClick": fileUpload
|
|
3082
2742
|
}, _isSlot(uploadText) ? uploadText : {
|
|
3083
2743
|
default: () => [uploadText]
|
|
3084
2744
|
})]), [[resolveDirective("file-drop"), {
|
|
3085
2745
|
enableDrop,
|
|
3086
|
-
isSingle:
|
|
2746
|
+
isSingle: !multiple,
|
|
3087
2747
|
onFileDrop,
|
|
3088
2748
|
onFileOver
|
|
3089
2749
|
}]]), createVNode("div", null, [(_d = (_c = this.$slots).preloadFiles) == null ? void 0 : _d.call(_c, {
|
|
@@ -3147,7 +2807,7 @@ const onDrop = (el, binding) => {
|
|
|
3147
2807
|
if (isSingle) {
|
|
3148
2808
|
onFileDrop && onFileDrop([transfer.files[0]]);
|
|
3149
2809
|
} else {
|
|
3150
|
-
onFileDrop && onFileDrop(transfer.files);
|
|
2810
|
+
onFileDrop && onFileDrop(Array.from(transfer.files));
|
|
3151
2811
|
}
|
|
3152
2812
|
});
|
|
3153
2813
|
};
|
|
@@ -3165,14 +2825,13 @@ const fileDropDirective = {
|
|
|
3165
2825
|
Upload.install = function(app) {
|
|
3166
2826
|
app.directive("file-drop", fileDropDirective);
|
|
3167
2827
|
app.component(Upload.name, Upload);
|
|
3168
|
-
app.component(MultiUpload.name, MultiUpload);
|
|
3169
2828
|
};
|
|
3170
2829
|
var index = {
|
|
3171
2830
|
title: "Upload \u4E0A\u4F20",
|
|
3172
2831
|
category: "\u6570\u636E\u5F55\u5165",
|
|
3173
|
-
status: "
|
|
2832
|
+
status: "100%",
|
|
3174
2833
|
install(app) {
|
|
3175
2834
|
app.use(Upload);
|
|
3176
2835
|
}
|
|
3177
2836
|
};
|
|
3178
|
-
export {
|
|
2837
|
+
export { Upload, index as default };
|