@vunk/form 1.1.11 → 1.1.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/components/form/index.js +112 -21
- package/components/form/src/ctx.d.ts +27 -1
- package/components/form/src/ctx.js +12 -0
- package/components/form/src/index.vue.d.ts +30 -0
- package/components/form/src/types.d.ts +12 -2
- package/components/form/src/utils.d.ts +15 -0
- package/components/form/src/utils.js +55 -0
- package/components/geoinput/src/ctx.d.ts +1 -1
- package/components/geoinput/src/index.vue.d.ts +3 -3
- package/components/geoinput-read/index.js +10 -4
- package/components/geoinput-read/src/core.vue.d.ts +15 -15
- package/components/geoinput-read/src/ctx.d.ts +3 -3
- package/components/geoinput-read/src/ctx.js +6 -2
- package/components/geoinput-read/src/index.vue.d.ts +17 -17
- package/components/upload-plus/index.css +85 -0
- package/components/upload-plus/index.d.ts +6 -0
- package/components/upload-plus/index.js +485 -0
- package/components/upload-plus/src/api.d.ts +31 -0
- package/components/upload-plus/src/api.js +65 -0
- package/components/upload-plus/src/const.d.ts +7 -0
- package/components/upload-plus/src/const.js +10 -0
- package/components/upload-plus/src/ctx.d.ts +59 -0
- package/components/upload-plus/src/ctx.js +34 -0
- package/components/upload-plus/src/index.vue.d.ts +163 -0
- package/components/upload-plus/src/types.d.ts +24 -0
- package/components/upload-plus/src/types.js +1 -0
- package/index.css +86 -0
- package/package.json +1 -1
- package/shared/types/form/checkbox.d.ts +1 -1
- package/shared/types/source/index.d.ts +6 -0
- package/shared/upload/index.d.ts +7 -0
- package/shared/upload/index.js +767 -0
|
@@ -2,6 +2,7 @@ import { _VkfInputCtx } from '@vunk/form/components/input';
|
|
|
2
2
|
import { EMPTY_FEATURE_COLLECTION } from '@vumap/core/shared/static';
|
|
3
3
|
import { _VmGeojsonLayerCtx } from '@vumap/core/components/geojson-layer';
|
|
4
4
|
import { bindPropsFactory, onEmitsFactory } from '@vunk/core/shared/utils-vue';
|
|
5
|
+
import { pickObject } from '@vunk/core/shared/utils-object';
|
|
5
6
|
|
|
6
7
|
var __defProp = Object.defineProperty;
|
|
7
8
|
var __defProps = Object.defineProperties;
|
|
@@ -53,9 +54,12 @@ const props = __spreadProps(__spreadValues(__spreadValues({}, _VkfInputCtx.props
|
|
|
53
54
|
}
|
|
54
55
|
});
|
|
55
56
|
const createBindProps = bindPropsFactory(props);
|
|
56
|
-
const emits = __spreadProps(__spreadValues(__spreadValues({}, _VmGeojsonLayerCtx.emits
|
|
57
|
+
const emits = __spreadProps(__spreadValues(__spreadValues({}, pickObject(_VmGeojsonLayerCtx.emits, {
|
|
58
|
+
excludes: ["click"]
|
|
59
|
+
})), _VkfInputCtx.emits), {
|
|
57
60
|
"layerChange": (layer) => layer,
|
|
58
|
-
"update:modelValue": (e) => e
|
|
61
|
+
"update:modelValue": (e) => e,
|
|
62
|
+
"layerClick": (e) => e
|
|
59
63
|
});
|
|
60
64
|
const createOnEmits = onEmitsFactory(emits);
|
|
61
65
|
|
|
@@ -240,25 +240,26 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
240
240
|
showMap: boolean;
|
|
241
241
|
}>;
|
|
242
242
|
coreOnEmits: {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
243
|
+
"update:modelValue": (e: import("@vumap/core/components/geojson-layer-set/src/types").ClickEvent) => void;
|
|
244
|
+
input: (e: import("@vumap/core/components/geojson-layer-set/src/types").ClickEvent) => void;
|
|
245
|
+
change: (e: import("@vumap/core/components/geojson-layer-set/src/types").ClickEvent) => void;
|
|
246
|
+
focus: (e: import("@vumap/core/components/geojson-layer-set/src/types").ClickEvent) => void;
|
|
247
|
+
blur: (e: import("@vumap/core/components/geojson-layer-set/src/types").ClickEvent) => void;
|
|
248
|
+
clear: (e: import("@vumap/core/components/geojson-layer-set/src/types").ClickEvent) => void;
|
|
249
|
+
mouseleave: (e: import("@vumap/core/components/geojson-layer-set/src/types").ClickEvent) => void;
|
|
250
|
+
mouseenter: (e: import("@vumap/core/components/geojson-layer-set/src/types").ClickEvent) => void;
|
|
251
|
+
keydown: (e: import("@vumap/core/components/geojson-layer-set/src/types").ClickEvent) => void;
|
|
252
|
+
compositionstart: (e: import("@vumap/core/components/geojson-layer-set/src/types").ClickEvent) => void;
|
|
253
|
+
compositionupdate: (e: import("@vumap/core/components/geojson-layer-set/src/types").ClickEvent) => void;
|
|
254
|
+
compositionend: (e: import("@vumap/core/components/geojson-layer-set/src/types").ClickEvent) => void;
|
|
255
|
+
load: (e: import("@vumap/core/components/geojson-layer-set/src/types").ClickEvent) => void;
|
|
256
|
+
layerChange: (e: import("@vumap/core/components/geojson-layer-set/src/types").ClickEvent) => void;
|
|
257
|
+
layerClick: (e: import("@vumap/core/components/geojson-layer-set/src/types").ClickEvent) => void;
|
|
258
258
|
};
|
|
259
259
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
260
260
|
layerChange: (layer: import("@vumap/core/components/geojson-add-layer/src/types").LoadEvent) => import("@vumap/core/components/geojson-add-layer/src/types").LoadEvent;
|
|
261
261
|
'update:modelValue': (e: import("geojson").FeatureCollection<import("geojson").Geometry, import("geojson").GeoJsonProperties>) => import("geojson").FeatureCollection<import("geojson").Geometry, import("geojson").GeoJsonProperties>;
|
|
262
|
+
layerClick: (e: import("@vumap/core/components/geojson-layer-set/src/types").ClickEvent) => import("@vumap/core/components/geojson-layer-set/src/types").ClickEvent;
|
|
262
263
|
input: (value: string) => boolean;
|
|
263
264
|
change: (value: string) => boolean;
|
|
264
265
|
focus: (evt: FocusEvent) => boolean;
|
|
@@ -270,7 +271,6 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
270
271
|
compositionstart: (evt: CompositionEvent) => boolean;
|
|
271
272
|
compositionupdate: (evt: CompositionEvent) => boolean;
|
|
272
273
|
compositionend: (evt: CompositionEvent) => boolean;
|
|
273
|
-
click: (e: import("@vumap/core/components/geojson-layer-set/src/types").ClickEvent) => import("@vumap/core/components/geojson-layer-set/src/types").ClickEvent;
|
|
274
274
|
load: (e: import("@vumap/core/components/geojson-add-layer/src/types").LoadEvent) => import("@vumap/core/components/geojson-add-layer/src/types").LoadEvent;
|
|
275
275
|
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
276
276
|
modelValue: {
|
|
@@ -436,7 +436,6 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
436
436
|
validateEvent: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, true, boolean>;
|
|
437
437
|
inputStyle: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => import("vue").StyleValue & {}) | (() => import("vue").StyleValue) | ((new (...args: any[]) => import("vue").StyleValue & {}) | (() => import("vue").StyleValue))[], unknown, unknown, () => import("element-plus/es/utils").Mutable<{}>, boolean>;
|
|
438
438
|
}>> & {
|
|
439
|
-
onClick?: ((e: import("@vumap/core/components/geojson-layer-set/src/types").ClickEvent) => any) | undefined;
|
|
440
439
|
onChange?: ((value: string) => any) | undefined;
|
|
441
440
|
"onUpdate:modelValue"?: ((e: import("geojson").FeatureCollection<import("geojson").Geometry, import("geojson").GeoJsonProperties>) => any) | undefined;
|
|
442
441
|
onInput?: ((value: string) => any) | undefined;
|
|
@@ -451,6 +450,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
451
450
|
onCompositionend?: ((evt: CompositionEvent) => any) | undefined;
|
|
452
451
|
onLoad?: ((e: import("@vumap/core/components/geojson-add-layer/src/types").LoadEvent) => any) | undefined;
|
|
453
452
|
onLayerChange?: ((layer: import("@vumap/core/components/geojson-add-layer/src/types").LoadEvent) => any) | undefined;
|
|
453
|
+
onLayerClick?: ((e: import("@vumap/core/components/geojson-layer-set/src/types").ClickEvent) => any) | undefined;
|
|
454
454
|
}, {
|
|
455
455
|
required: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown>;
|
|
456
456
|
type: string;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
|
|
2
|
+
@keyframes hide {
|
|
3
|
+
0% {
|
|
4
|
+
opacity: 1; /* 初始状态为完全显示 */
|
|
5
|
+
}
|
|
6
|
+
100% {
|
|
7
|
+
opacity: 0; /* 最终状态为完全隐藏 */
|
|
8
|
+
display: none; /* 同时隐藏元素 */
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.vkf-upload-plus{
|
|
13
|
+
--vkf-upload-plus-height: 34px;
|
|
14
|
+
}
|
|
15
|
+
.vkf-upload-plus-label{
|
|
16
|
+
position: relative;
|
|
17
|
+
}
|
|
18
|
+
.vkf-upload-plus-cube-x,
|
|
19
|
+
.vkf-upload-plus-msg-x
|
|
20
|
+
{
|
|
21
|
+
position: absolute;
|
|
22
|
+
top: 0;
|
|
23
|
+
left: 0;
|
|
24
|
+
bottom: 0;
|
|
25
|
+
right: 0;
|
|
26
|
+
}
|
|
27
|
+
.vkf-upload-plus-msg-x{
|
|
28
|
+
display: flex;
|
|
29
|
+
align-items: center;
|
|
30
|
+
justify-content: center;
|
|
31
|
+
color: var(--el-color-success);
|
|
32
|
+
background: var(--el-bg-color);
|
|
33
|
+
animation-name: hide; /* 指定使用hide关键帧动画 */
|
|
34
|
+
animation-duration: 1s; /* 动画持续时间为2秒 */
|
|
35
|
+
animation-delay: 1s; /* 延迟2秒后开始动画 */
|
|
36
|
+
animation-fill-mode: forwards; /* 动画结束后保持最后一帧的状态 */
|
|
37
|
+
}
|
|
38
|
+
.vkf-upload-plus-msg{
|
|
39
|
+
margin-left: 2px;
|
|
40
|
+
}
|
|
41
|
+
.vkf-upload-plus-cube {
|
|
42
|
+
float: left;
|
|
43
|
+
height: 100%;
|
|
44
|
+
}
|
|
45
|
+
.vkf-upload-plus-cube.error {
|
|
46
|
+
background: var(--el-color-danger);
|
|
47
|
+
}
|
|
48
|
+
.vkf-upload-plus-cube .success{
|
|
49
|
+
background: var(--el-color-success);
|
|
50
|
+
}
|
|
51
|
+
.vkf-upload-plus-cube .uploading{
|
|
52
|
+
background: var(--el-color-primary);
|
|
53
|
+
}
|
|
54
|
+
.vkf-upload-plus-cube .error{
|
|
55
|
+
background: var(--el-color-danger);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.vkf-upload-plus-btng >.el-button:first-child{
|
|
59
|
+
border-radius: 0;
|
|
60
|
+
}
|
|
61
|
+
.vkf-upload-plus-btng >.el-button{
|
|
62
|
+
height: var(--vkf-upload-plus-height);
|
|
63
|
+
}
|
|
64
|
+
.vkf-upload-plus-main{
|
|
65
|
+
display: flex;
|
|
66
|
+
align-items: center;
|
|
67
|
+
border: var(--el-border);
|
|
68
|
+
border-radius: var(--el-border-radius-base);
|
|
69
|
+
}
|
|
70
|
+
.vkf-upload-plus-label{
|
|
71
|
+
cursor: pointer;
|
|
72
|
+
}
|
|
73
|
+
.vkf-upload-plus-label .el-input{
|
|
74
|
+
pointer-events: none;
|
|
75
|
+
--el-input-border-color: transparent;
|
|
76
|
+
}
|
|
77
|
+
.vkf-upload-plus-label .el-input.is-success .el-icon{
|
|
78
|
+
color: var(--el-color-success);
|
|
79
|
+
}
|
|
80
|
+
.vkf-upload-plus-label .el-input.is-error .el-icon{
|
|
81
|
+
color: var(--el-color-danger);
|
|
82
|
+
}
|
|
83
|
+
.vkf-upload-plus-input{
|
|
84
|
+
display: none;
|
|
85
|
+
}
|
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
import { _VkfFormItemCtx, VkfFormItem } from '@vunk/form/components/form-item';
|
|
2
|
+
import { openBlock, createElementBlock, createElementVNode, defineComponent, reactive, ref, computed, resolveComponent, createBlock, mergeProps, withCtx, createVNode, normalizeClass, createCommentVNode, Fragment, renderList, normalizeStyle, createTextVNode } from 'vue';
|
|
3
|
+
import { ElInput, ElButtonGroup, ElButton, ElIcon } from 'element-plus';
|
|
4
|
+
import { createFileChunk, calculateFileHashSample } from '@vunk/form/shared/upload';
|
|
5
|
+
import { RestFetch } from '@vunk/core/shared/utils-fetch';
|
|
6
|
+
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __defProps = Object.defineProperties;
|
|
9
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
10
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
13
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
14
|
+
var __spreadValues = (a, b) => {
|
|
15
|
+
for (var prop in b || (b = {}))
|
|
16
|
+
if (__hasOwnProp.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
if (__getOwnPropSymbols)
|
|
19
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
20
|
+
if (__propIsEnum.call(b, prop))
|
|
21
|
+
__defNormalProp(a, prop, b[prop]);
|
|
22
|
+
}
|
|
23
|
+
return a;
|
|
24
|
+
};
|
|
25
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
26
|
+
const props = __spreadProps(__spreadValues({}, _VkfFormItemCtx.props), {
|
|
27
|
+
size: {
|
|
28
|
+
type: Number,
|
|
29
|
+
default: 1024 / (16 * 16) * 1024 * 1024
|
|
30
|
+
},
|
|
31
|
+
dictId: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: ""
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
const emits = {};
|
|
37
|
+
|
|
38
|
+
var Status = /* @__PURE__ */ ((Status2) => {
|
|
39
|
+
Status2["wait"] = "wait";
|
|
40
|
+
Status2["pause"] = "pause";
|
|
41
|
+
Status2["uploading"] = "uploading";
|
|
42
|
+
Status2["error"] = "error";
|
|
43
|
+
Status2["done"] = "done";
|
|
44
|
+
return Status2;
|
|
45
|
+
})(Status || {});
|
|
46
|
+
|
|
47
|
+
var _const = /*#__PURE__*/Object.freeze({
|
|
48
|
+
__proto__: null,
|
|
49
|
+
Status: Status
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const restFetch = new RestFetch({
|
|
53
|
+
baseURL: "http://192.168.110.209:36800"
|
|
54
|
+
});
|
|
55
|
+
const verify = async (params) => {
|
|
56
|
+
return restFetch.request({
|
|
57
|
+
method: "GET",
|
|
58
|
+
url: "/dict/hdfs/getChunkList",
|
|
59
|
+
params
|
|
60
|
+
}).then((res) => {
|
|
61
|
+
return res.data.map((item) => item.identifier);
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
const upload = async (data, init) => {
|
|
65
|
+
return new Promise((resolve, reject) => {
|
|
66
|
+
var _a;
|
|
67
|
+
const xhr = new XMLHttpRequest();
|
|
68
|
+
xhr.upload.onprogress = (init == null ? void 0 : init.onprogress) || null;
|
|
69
|
+
xhr.open("post", restFetch.baseURL + "/dict/hdfs/chunk/upload");
|
|
70
|
+
const form = new FormData();
|
|
71
|
+
form.append("file", data.chunk);
|
|
72
|
+
form.append("identifier", data.fileHash);
|
|
73
|
+
form.append("filename", data.fileName);
|
|
74
|
+
form.append("chunkNumber", data.index + 1 + "");
|
|
75
|
+
form.append("chunkIdentifier", data.hash + "");
|
|
76
|
+
form.append("totalChunk", data.chunksLength + "");
|
|
77
|
+
form.append("chunkSize", data.sliceSize + "");
|
|
78
|
+
form.append("currentChunkSize", data.chunk.size + "");
|
|
79
|
+
form.append("totalSize", data.fileSize + "");
|
|
80
|
+
xhr.send(form);
|
|
81
|
+
xhr.onreadystatechange = (e) => {
|
|
82
|
+
const target = e.target;
|
|
83
|
+
if (xhr.readyState === 4) {
|
|
84
|
+
if (xhr.status === 200) {
|
|
85
|
+
if (init == null ? void 0 : init.xhrs) {
|
|
86
|
+
const i = init.xhrs.findIndex((req) => req === xhr);
|
|
87
|
+
init.xhrs.splice(i, 1);
|
|
88
|
+
}
|
|
89
|
+
resolve({
|
|
90
|
+
data: target.response
|
|
91
|
+
});
|
|
92
|
+
} else if (xhr.status === 500) {
|
|
93
|
+
reject(target.response);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
xhr.timeout = 5 * 1e3;
|
|
98
|
+
xhr.ontimeout = (e) => {
|
|
99
|
+
reject(e);
|
|
100
|
+
};
|
|
101
|
+
(_a = init == null ? void 0 : init.xhrs) == null ? void 0 : _a.push(xhr);
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
const merge = async (data) => {
|
|
105
|
+
return restFetch.request({
|
|
106
|
+
method: "POST",
|
|
107
|
+
url: "/dict/hdfs/chunk/merge",
|
|
108
|
+
data
|
|
109
|
+
}).then((res) => {
|
|
110
|
+
return res.datas;
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
var api = /*#__PURE__*/Object.freeze({
|
|
115
|
+
__proto__: null,
|
|
116
|
+
restFetch: restFetch,
|
|
117
|
+
verify: verify,
|
|
118
|
+
upload: upload,
|
|
119
|
+
merge: merge
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
/*! Element Plus Icons Vue v2.1.0 */
|
|
123
|
+
|
|
124
|
+
// unplugin-vue:/plugin-vue/export-helper
|
|
125
|
+
var export_helper_default = (sfc, props) => {
|
|
126
|
+
let target = sfc.__vccOpts || sfc;
|
|
127
|
+
for (let [key, val] of props)
|
|
128
|
+
target[key] = val;
|
|
129
|
+
return target;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
// unplugin-vue:/home/runner/work/element-plus-icons/element-plus-icons/packages/vue/src/components/circle-close-filled.vue?vue&type=script&lang.ts
|
|
133
|
+
var circle_close_filled_vue_vue_type_script_lang_default = {
|
|
134
|
+
name: "CircleCloseFilled"
|
|
135
|
+
};
|
|
136
|
+
var _hoisted_150 = {
|
|
137
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
138
|
+
viewBox: "0 0 1024 1024"
|
|
139
|
+
}, _hoisted_250 = /* @__PURE__ */ createElementVNode(
|
|
140
|
+
"path",
|
|
141
|
+
{
|
|
142
|
+
fill: "currentColor",
|
|
143
|
+
d: "M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm0 393.664L407.936 353.6a38.4 38.4 0 1 0-54.336 54.336L457.664 512 353.6 616.064a38.4 38.4 0 1 0 54.336 54.336L512 566.336 616.064 670.4a38.4 38.4 0 1 0 54.336-54.336L566.336 512 670.4 407.936a38.4 38.4 0 1 0-54.336-54.336L512 457.664z"
|
|
144
|
+
},
|
|
145
|
+
null,
|
|
146
|
+
-1
|
|
147
|
+
/* HOISTED */
|
|
148
|
+
), _hoisted_349 = [
|
|
149
|
+
_hoisted_250
|
|
150
|
+
];
|
|
151
|
+
function _sfc_render50(_ctx, _cache, $props, $setup, $data, $options) {
|
|
152
|
+
return openBlock(), createElementBlock("svg", _hoisted_150, _hoisted_349);
|
|
153
|
+
}
|
|
154
|
+
var circle_close_filled_default = /* @__PURE__ */ export_helper_default(circle_close_filled_vue_vue_type_script_lang_default, [["render", _sfc_render50], ["__file", "circle-close-filled.vue"]]);
|
|
155
|
+
|
|
156
|
+
// unplugin-vue:/home/runner/work/element-plus-icons/element-plus-icons/packages/vue/src/components/success-filled.vue?vue&type=script&lang.ts
|
|
157
|
+
var success_filled_vue_vue_type_script_lang_default = {
|
|
158
|
+
name: "SuccessFilled"
|
|
159
|
+
};
|
|
160
|
+
var _hoisted_1249 = {
|
|
161
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
162
|
+
viewBox: "0 0 1024 1024"
|
|
163
|
+
}, _hoisted_2249 = /* @__PURE__ */ createElementVNode(
|
|
164
|
+
"path",
|
|
165
|
+
{
|
|
166
|
+
fill: "currentColor",
|
|
167
|
+
d: "M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm-55.808 536.384-99.52-99.584a38.4 38.4 0 1 0-54.336 54.336l126.72 126.72a38.272 38.272 0 0 0 54.336 0l262.4-262.464a38.4 38.4 0 1 0-54.272-54.336L456.192 600.384z"
|
|
168
|
+
},
|
|
169
|
+
null,
|
|
170
|
+
-1
|
|
171
|
+
/* HOISTED */
|
|
172
|
+
), _hoisted_3248 = [
|
|
173
|
+
_hoisted_2249
|
|
174
|
+
];
|
|
175
|
+
function _sfc_render249(_ctx, _cache, $props, $setup, $data, $options) {
|
|
176
|
+
return openBlock(), createElementBlock("svg", _hoisted_1249, _hoisted_3248);
|
|
177
|
+
}
|
|
178
|
+
var success_filled_default = /* @__PURE__ */ export_helper_default(success_filled_vue_vue_type_script_lang_default, [["render", _sfc_render249], ["__file", "success-filled.vue"]]);
|
|
179
|
+
|
|
180
|
+
// unplugin-vue:/home/runner/work/element-plus-icons/element-plus-icons/packages/vue/src/components/upload-filled.vue?vue&type=script&lang.ts
|
|
181
|
+
var upload_filled_vue_vue_type_script_lang_default = {
|
|
182
|
+
name: "UploadFilled"
|
|
183
|
+
};
|
|
184
|
+
var _hoisted_1274 = {
|
|
185
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
186
|
+
viewBox: "0 0 1024 1024"
|
|
187
|
+
}, _hoisted_2274 = /* @__PURE__ */ createElementVNode(
|
|
188
|
+
"path",
|
|
189
|
+
{
|
|
190
|
+
fill: "currentColor",
|
|
191
|
+
d: "M544 864V672h128L512 480 352 672h128v192H320v-1.6c-5.376.32-10.496 1.6-16 1.6A240 240 0 0 1 64 624c0-123.136 93.12-223.488 212.608-237.248A239.808 239.808 0 0 1 512 192a239.872 239.872 0 0 1 235.456 194.752c119.488 13.76 212.48 114.112 212.48 237.248a240 240 0 0 1-240 240c-5.376 0-10.56-1.28-16-1.6v1.6H544z"
|
|
192
|
+
},
|
|
193
|
+
null,
|
|
194
|
+
-1
|
|
195
|
+
/* HOISTED */
|
|
196
|
+
), _hoisted_3273 = [
|
|
197
|
+
_hoisted_2274
|
|
198
|
+
];
|
|
199
|
+
function _sfc_render274(_ctx, _cache, $props, $setup, $data, $options) {
|
|
200
|
+
return openBlock(), createElementBlock("svg", _hoisted_1274, _hoisted_3273);
|
|
201
|
+
}
|
|
202
|
+
var upload_filled_default = /* @__PURE__ */ export_helper_default(upload_filled_vue_vue_type_script_lang_default, [["render", _sfc_render274], ["__file", "upload-filled.vue"]]);
|
|
203
|
+
|
|
204
|
+
var _export_sfc = (sfc, props) => {
|
|
205
|
+
const target = sfc.__vccOpts || sfc;
|
|
206
|
+
for (const [key, val] of props) {
|
|
207
|
+
target[key] = val;
|
|
208
|
+
}
|
|
209
|
+
return target;
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
const _sfc_main = defineComponent({
|
|
213
|
+
name: "VkfUploadPlus",
|
|
214
|
+
components: {
|
|
215
|
+
VkfFormItem,
|
|
216
|
+
ElInput,
|
|
217
|
+
ElButtonGroup,
|
|
218
|
+
ElButton,
|
|
219
|
+
ElIcon,
|
|
220
|
+
SuccessFilled: success_filled_default
|
|
221
|
+
},
|
|
222
|
+
emits,
|
|
223
|
+
props,
|
|
224
|
+
setup(props2, { emit }) {
|
|
225
|
+
const formItemBindProps = _VkfFormItemCtx.createBindProps(props2);
|
|
226
|
+
const uuid = Math.random().toString(36).slice(-8);
|
|
227
|
+
const container = reactive({});
|
|
228
|
+
const fileStatus = ref(Status.wait);
|
|
229
|
+
const chunks = ref([]);
|
|
230
|
+
const uploadingXhrs = ref([]);
|
|
231
|
+
const filePrefixIcon = computed(() => {
|
|
232
|
+
if (fileStatus.value === Status.done) {
|
|
233
|
+
return success_filled_default;
|
|
234
|
+
}
|
|
235
|
+
if (fileStatus.value === Status.error) {
|
|
236
|
+
return circle_close_filled_default;
|
|
237
|
+
}
|
|
238
|
+
return upload_filled_default;
|
|
239
|
+
});
|
|
240
|
+
const handleFileChange = (e) => {
|
|
241
|
+
const target = e.target;
|
|
242
|
+
const file = target.files?.[0];
|
|
243
|
+
if (file) {
|
|
244
|
+
container.file = file;
|
|
245
|
+
fileStatus.value = Status.wait;
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
const handleUpload = async () => {
|
|
249
|
+
if (!container.file)
|
|
250
|
+
return;
|
|
251
|
+
fileStatus.value = Status.uploading;
|
|
252
|
+
const chunkFiles = createFileChunk(container.file, props2.size);
|
|
253
|
+
const hash = await calculateFileHashSample(container.file);
|
|
254
|
+
container.hash = hash;
|
|
255
|
+
const uploadedList = await verify({
|
|
256
|
+
identifier: hash
|
|
257
|
+
});
|
|
258
|
+
const sliceSize = chunkFiles[0].size;
|
|
259
|
+
chunks.value = chunkFiles.map((chunk, index) => {
|
|
260
|
+
const _container = container;
|
|
261
|
+
const chunkHash = _container.hash + "-" + index;
|
|
262
|
+
return {
|
|
263
|
+
fileName: _container.file.name,
|
|
264
|
+
fileHash: _container.hash,
|
|
265
|
+
fileSize: _container.file.size,
|
|
266
|
+
chunk,
|
|
267
|
+
hash: chunkHash,
|
|
268
|
+
index,
|
|
269
|
+
progress: uploadedList.indexOf(chunkHash) > -1 ? 100 : 0,
|
|
270
|
+
chunksLength: chunkFiles.length,
|
|
271
|
+
sliceSize,
|
|
272
|
+
status: Status.wait
|
|
273
|
+
};
|
|
274
|
+
});
|
|
275
|
+
const needUpload = chunks.value.filter((v) => uploadedList.indexOf(v.hash) === -1);
|
|
276
|
+
cUploadedChunks(
|
|
277
|
+
needUpload
|
|
278
|
+
).then(() => {
|
|
279
|
+
return cFile();
|
|
280
|
+
}).then(() => {
|
|
281
|
+
fileStatus.value = Status.done;
|
|
282
|
+
}).catch(() => {
|
|
283
|
+
fileStatus.value = Status.error;
|
|
284
|
+
});
|
|
285
|
+
};
|
|
286
|
+
const handlePause = () => {
|
|
287
|
+
uploadingXhrs.value.forEach((xhr) => {
|
|
288
|
+
xhr.abort();
|
|
289
|
+
});
|
|
290
|
+
uploadingXhrs.value = [];
|
|
291
|
+
fileStatus.value = Status.pause;
|
|
292
|
+
};
|
|
293
|
+
async function cUploadedChunks(urls, max = 4, retrys = 3) {
|
|
294
|
+
return new Promise((resolve, reject) => {
|
|
295
|
+
const len = urls.length;
|
|
296
|
+
let counter = 0;
|
|
297
|
+
const retryArr = [];
|
|
298
|
+
const start = async () => {
|
|
299
|
+
while (counter < len && max > 0) {
|
|
300
|
+
max--;
|
|
301
|
+
const i = urls.findIndex((v) => v.status === Status.wait || v.status === Status.error);
|
|
302
|
+
const currentChunk = urls[i];
|
|
303
|
+
if (currentChunk) {
|
|
304
|
+
currentChunk.status = Status.uploading;
|
|
305
|
+
upload(currentChunk, {
|
|
306
|
+
onprogress(ev) {
|
|
307
|
+
chunks.value[currentChunk.index].progress = parseInt(ev.loaded / ev.total * 100 + "");
|
|
308
|
+
},
|
|
309
|
+
xhrs: uploadingXhrs.value
|
|
310
|
+
}).then(() => {
|
|
311
|
+
urls[i].status = Status.done;
|
|
312
|
+
max++;
|
|
313
|
+
counter++;
|
|
314
|
+
}).then(() => {
|
|
315
|
+
if (counter === len) {
|
|
316
|
+
resolve(void 0);
|
|
317
|
+
} else {
|
|
318
|
+
start();
|
|
319
|
+
}
|
|
320
|
+
}).catch(() => {
|
|
321
|
+
const index = urls[i].index;
|
|
322
|
+
urls[i].status = Status.error;
|
|
323
|
+
if (typeof retryArr[index] !== "number") {
|
|
324
|
+
retryArr[index] = 0;
|
|
325
|
+
}
|
|
326
|
+
retryArr[index]++;
|
|
327
|
+
console.warn(
|
|
328
|
+
index,
|
|
329
|
+
urls[i],
|
|
330
|
+
retryArr[index],
|
|
331
|
+
"\u6B21\u62A5\u9519"
|
|
332
|
+
);
|
|
333
|
+
chunks.value[index].progress = -1;
|
|
334
|
+
if (retryArr[index] >= retrys) {
|
|
335
|
+
return reject();
|
|
336
|
+
}
|
|
337
|
+
max++;
|
|
338
|
+
start();
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
start();
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
function cFile() {
|
|
347
|
+
if (!container.file)
|
|
348
|
+
return;
|
|
349
|
+
if (!container.hash)
|
|
350
|
+
return;
|
|
351
|
+
return merge({
|
|
352
|
+
filename: container.file.name,
|
|
353
|
+
identifier: container.hash,
|
|
354
|
+
dictId: props2.dictId
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
return {
|
|
358
|
+
formItemBindProps,
|
|
359
|
+
handleFileChange,
|
|
360
|
+
uuid,
|
|
361
|
+
container,
|
|
362
|
+
handleUpload,
|
|
363
|
+
fileStatus,
|
|
364
|
+
chunks,
|
|
365
|
+
Status,
|
|
366
|
+
filePrefixIcon,
|
|
367
|
+
handlePause
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
const _hoisted_1 = { class: "vkf-upload-plus-main" };
|
|
372
|
+
const _hoisted_2 = ["for"];
|
|
373
|
+
const _hoisted_3 = {
|
|
374
|
+
key: 0,
|
|
375
|
+
class: "vkf-upload-plus-msg-x"
|
|
376
|
+
};
|
|
377
|
+
const _hoisted_4 = /* @__PURE__ */ createElementVNode("span", { class: "vkf-upload-plus-msg" }, " \u4E0A\u4F20\u6210\u529F ", -1);
|
|
378
|
+
const _hoisted_5 = {
|
|
379
|
+
key: 1,
|
|
380
|
+
class: "vkf-upload-plus-cube-x"
|
|
381
|
+
};
|
|
382
|
+
const _hoisted_6 = ["id"];
|
|
383
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
384
|
+
const _component_ElInput = resolveComponent("ElInput");
|
|
385
|
+
const _component_SuccessFilled = resolveComponent("SuccessFilled");
|
|
386
|
+
const _component_ElIcon = resolveComponent("ElIcon");
|
|
387
|
+
const _component_ElButton = resolveComponent("ElButton");
|
|
388
|
+
const _component_el_button = resolveComponent("el-button");
|
|
389
|
+
const _component_el_button_group = resolveComponent("el-button-group");
|
|
390
|
+
const _component_VkfFormItem = resolveComponent("VkfFormItem");
|
|
391
|
+
return openBlock(), createBlock(_component_VkfFormItem, mergeProps(_ctx.formItemBindProps, { class: "vkf-upload-plus" }), {
|
|
392
|
+
default: withCtx(() => [
|
|
393
|
+
createElementVNode("div", _hoisted_1, [
|
|
394
|
+
createElementVNode("label", {
|
|
395
|
+
for: _ctx.uuid,
|
|
396
|
+
class: "vkf-upload-plus-label"
|
|
397
|
+
}, [
|
|
398
|
+
createVNode(_component_ElInput, {
|
|
399
|
+
class: normalizeClass({
|
|
400
|
+
"is-success": _ctx.fileStatus === _ctx.Status.done,
|
|
401
|
+
"is-error": _ctx.fileStatus === _ctx.Status.error
|
|
402
|
+
}),
|
|
403
|
+
modelValue: _ctx.container.file?.name,
|
|
404
|
+
prefixIcon: _ctx.filePrefixIcon,
|
|
405
|
+
placeholder: "\u8BF7\u9009\u62E9\u6587\u4EF6"
|
|
406
|
+
}, null, 8, ["class", "modelValue", "prefixIcon"]),
|
|
407
|
+
_ctx.fileStatus === _ctx.Status.done ? (openBlock(), createElementBlock("div", _hoisted_3, [
|
|
408
|
+
createVNode(_component_ElIcon, null, {
|
|
409
|
+
default: withCtx(() => [
|
|
410
|
+
createVNode(_component_SuccessFilled)
|
|
411
|
+
]),
|
|
412
|
+
_: 1
|
|
413
|
+
}),
|
|
414
|
+
_hoisted_4
|
|
415
|
+
])) : createCommentVNode("v-if", true),
|
|
416
|
+
_ctx.fileStatus === _ctx.Status.uploading || _ctx.fileStatus === _ctx.Status.pause ? (openBlock(), createElementBlock("div", _hoisted_5, [
|
|
417
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.chunks, (chunk) => {
|
|
418
|
+
return openBlock(), createElementBlock("div", {
|
|
419
|
+
class: normalizeClass(["vkf-upload-plus-cube", {
|
|
420
|
+
"error": chunk.status == _ctx.Status.error
|
|
421
|
+
}]),
|
|
422
|
+
key: chunk.hash,
|
|
423
|
+
style: normalizeStyle({
|
|
424
|
+
width: 100 / chunk.chunksLength + "%"
|
|
425
|
+
})
|
|
426
|
+
}, [
|
|
427
|
+
createElementVNode("div", {
|
|
428
|
+
class: normalizeClass({
|
|
429
|
+
"uploading": chunk.progress > 0 && chunk.progress < 100,
|
|
430
|
+
"success": chunk.progress == 100
|
|
431
|
+
}),
|
|
432
|
+
style: normalizeStyle({
|
|
433
|
+
height: chunk.progress + "%"
|
|
434
|
+
})
|
|
435
|
+
}, null, 6)
|
|
436
|
+
], 6);
|
|
437
|
+
}), 128))
|
|
438
|
+
])) : createCommentVNode("v-if", true)
|
|
439
|
+
], 8, _hoisted_2),
|
|
440
|
+
createElementVNode("input", {
|
|
441
|
+
type: "file",
|
|
442
|
+
id: _ctx.uuid,
|
|
443
|
+
class: "vkf-upload-plus-input",
|
|
444
|
+
onChange: _cache[0] || (_cache[0] = (...args) => _ctx.handleFileChange && _ctx.handleFileChange(...args))
|
|
445
|
+
}, null, 40, _hoisted_6),
|
|
446
|
+
createVNode(_component_el_button_group, { class: "vkf-upload-plus-btng" }, {
|
|
447
|
+
default: withCtx(() => [
|
|
448
|
+
_ctx.fileStatus === _ctx.Status.uploading ? (openBlock(), createBlock(_component_ElButton, {
|
|
449
|
+
key: 0,
|
|
450
|
+
type: "danger",
|
|
451
|
+
onClick: _ctx.handlePause
|
|
452
|
+
}, {
|
|
453
|
+
default: withCtx(() => [
|
|
454
|
+
createTextVNode(" \u6682\u505C ")
|
|
455
|
+
]),
|
|
456
|
+
_: 1
|
|
457
|
+
}, 8, ["onClick"])) : (openBlock(), createBlock(_component_el_button, {
|
|
458
|
+
key: 1,
|
|
459
|
+
type: "primary",
|
|
460
|
+
onClick: _ctx.handleUpload
|
|
461
|
+
}, {
|
|
462
|
+
default: withCtx(() => [
|
|
463
|
+
createTextVNode("\u4E0A\u4F20")
|
|
464
|
+
]),
|
|
465
|
+
_: 1
|
|
466
|
+
}, 8, ["onClick"]))
|
|
467
|
+
]),
|
|
468
|
+
_: 1
|
|
469
|
+
})
|
|
470
|
+
])
|
|
471
|
+
]),
|
|
472
|
+
_: 1
|
|
473
|
+
}, 16);
|
|
474
|
+
}
|
|
475
|
+
var VkfUploadPlus = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "index.vue"]]);
|
|
476
|
+
|
|
477
|
+
var types = /*#__PURE__*/Object.freeze({
|
|
478
|
+
__proto__: null
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
VkfUploadPlus.install = (app) => {
|
|
482
|
+
app.component(VkfUploadPlus.name, VkfUploadPlus);
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
export { VkfUploadPlus, api as _VkfUploadPlusApi, _const as _VkfUploadPlusConst, types as __VkfUploadPlus, VkfUploadPlus as default };
|