@vunk/form 1.1.84 → 1.1.85
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/_plugin-vue_export-helper.cjs +11 -0
- package/components/button/index.cjs +112 -0
- package/components/cascader/index.cjs +130 -0
- package/components/checkbox/index.cjs +153 -0
- package/components/color-picker/index.cjs +80 -0
- package/components/date-picker/index.cjs +120 -0
- package/components/date-picker-range/index.cjs +170 -0
- package/components/download-plus/index.cjs +445 -0
- package/components/esri-input-geojson/index.cjs +1120 -0
- package/components/form/index.cjs +220 -0
- package/components/form-item/index.cjs +162 -0
- package/components/form-item-renderer/index.cjs +103 -0
- package/components/form-item-renderer-template/index.cjs +47 -0
- package/components/geoinput/index.cjs +95 -0
- package/components/geoinput-read/index.cjs +304 -0
- package/components/geoinput-update/index.cjs +406 -0
- package/components/index.cjs +13 -0
- package/components/index2.cjs +323 -0
- package/components/index3.cjs +486 -0
- package/components/input/index.cjs +119 -0
- package/components/input-link/index.cjs +157 -0
- package/components/input-number/index.cjs +100 -0
- package/components/radio/index.cjs +142 -0
- package/components/select/index.cjs +165 -0
- package/components/slider/index.cjs +89 -0
- package/components/switch/index.cjs +92 -0
- package/components/templates-default/index.cjs +308 -0
- package/components/templates-element-plus/index.cjs +112 -0
- package/components/templates-esri/index.cjs +65 -0
- package/components/templates-layout/index.cjs +137 -0
- package/components/templates-mapbox/index.cjs +65 -0
- package/components/templates-variant/index.cjs +70 -0
- package/components/upload/index.cjs +508 -0
- package/components/upload-plus/index.cjs +18658 -0
- package/components/van-cascader/index.cjs +128 -0
- package/components/var-datetime-picker/index.cjs +330 -0
- package/components/vditor/index.cjs +451 -0
- package/package.json +69 -35
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var datePicker = require('@vunk/form/components/date-picker');
|
|
6
|
+
var utilsObject = require('@vunk/core/shared/utils-object');
|
|
7
|
+
var vue = require('vue');
|
|
8
|
+
var _pluginVue_exportHelper = require('../_plugin-vue_export-helper.cjs');
|
|
9
|
+
|
|
10
|
+
const props = {
|
|
11
|
+
...utilsObject.pickObject(
|
|
12
|
+
datePicker._VkfDatePickerCtx.props,
|
|
13
|
+
{
|
|
14
|
+
excludes: [
|
|
15
|
+
"modelValue",
|
|
16
|
+
"prop"
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
),
|
|
20
|
+
type: {
|
|
21
|
+
type: String,
|
|
22
|
+
default: "daterange"
|
|
23
|
+
},
|
|
24
|
+
endPlaceholder: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: "\u7ED3\u675F\u65F6\u95F4"
|
|
27
|
+
},
|
|
28
|
+
startPlaceholder: {
|
|
29
|
+
type: String,
|
|
30
|
+
default: "\u5F00\u59CB\u65F6\u95F4"
|
|
31
|
+
},
|
|
32
|
+
startValue: {
|
|
33
|
+
type: String,
|
|
34
|
+
default: ""
|
|
35
|
+
},
|
|
36
|
+
endValue: {
|
|
37
|
+
type: String,
|
|
38
|
+
default: ""
|
|
39
|
+
},
|
|
40
|
+
startProp: {
|
|
41
|
+
type: String
|
|
42
|
+
},
|
|
43
|
+
endProp: {
|
|
44
|
+
type: String
|
|
45
|
+
},
|
|
46
|
+
valueFormat: {
|
|
47
|
+
type: String,
|
|
48
|
+
default: "YYYY-MM-DD"
|
|
49
|
+
},
|
|
50
|
+
selectOptions: {
|
|
51
|
+
type: Array,
|
|
52
|
+
default: () => []
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const emits = {
|
|
56
|
+
...utilsObject.pickObject(
|
|
57
|
+
datePicker._VkfDatePickerCtx.emits,
|
|
58
|
+
{
|
|
59
|
+
excludes: ["update:modelValue"]
|
|
60
|
+
}
|
|
61
|
+
),
|
|
62
|
+
"update:startValue": null,
|
|
63
|
+
"update:endValue": null
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
var _sfc_main = vue.defineComponent({
|
|
67
|
+
name: "VkfDatePickerRange",
|
|
68
|
+
components: {
|
|
69
|
+
VkfDatePicker: datePicker.VkfDatePicker
|
|
70
|
+
},
|
|
71
|
+
props,
|
|
72
|
+
emits,
|
|
73
|
+
setup(props2, { emit }) {
|
|
74
|
+
const coreProps = datePicker._VkfDatePickerCtx.createBindProps(props2);
|
|
75
|
+
const coreEmits = datePicker._VkfDatePickerCtx.createOnEmits(emit, ["update:modelValue"]);
|
|
76
|
+
const modelValue = vue.computed({
|
|
77
|
+
get: () => [props2.startValue, props2.endValue],
|
|
78
|
+
set: (val) => {
|
|
79
|
+
emit("update:startValue", val?.[0]);
|
|
80
|
+
emit("update:endValue", val?.[1]);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
const prop = vue.computed(() => {
|
|
84
|
+
const pArr = [];
|
|
85
|
+
props2.startProp && pArr.push(props2.startProp);
|
|
86
|
+
props2.endProp && pArr.push(props2.endProp);
|
|
87
|
+
return pArr.join(",");
|
|
88
|
+
});
|
|
89
|
+
const rulesProp = vue.computed(() => {
|
|
90
|
+
const rules = props2.rules ? Array.isArray(props2.rules) ? props2.rules : [props2.rules] : [];
|
|
91
|
+
if (!rules.length && props2.required) {
|
|
92
|
+
rules.push({ required: true });
|
|
93
|
+
}
|
|
94
|
+
rules.forEach((rule) => {
|
|
95
|
+
if (rule.required) {
|
|
96
|
+
rule.validator = () => {
|
|
97
|
+
if (props2.startValue && props2.endValue) {
|
|
98
|
+
return true;
|
|
99
|
+
} else {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
return rules;
|
|
106
|
+
});
|
|
107
|
+
return {
|
|
108
|
+
coreProps,
|
|
109
|
+
coreEmits,
|
|
110
|
+
modelValue,
|
|
111
|
+
rulesProp,
|
|
112
|
+
prop
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
const _hoisted_1 = { class: "vkf-date-picker-range-select" };
|
|
118
|
+
const _hoisted_2 = ["onClick"];
|
|
119
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
120
|
+
const _component_VkfDatePicker = vue.resolveComponent("VkfDatePicker");
|
|
121
|
+
return vue.openBlock(), vue.createElementBlock(
|
|
122
|
+
vue.Fragment,
|
|
123
|
+
null,
|
|
124
|
+
[
|
|
125
|
+
vue.withDirectives(vue.createElementVNode(
|
|
126
|
+
"div",
|
|
127
|
+
_hoisted_1,
|
|
128
|
+
[
|
|
129
|
+
(vue.openBlock(true), vue.createElementBlock(
|
|
130
|
+
vue.Fragment,
|
|
131
|
+
null,
|
|
132
|
+
vue.renderList(_ctx.selectOptions, (item) => {
|
|
133
|
+
return vue.openBlock(), vue.createElementBlock("div", {
|
|
134
|
+
key: item.label,
|
|
135
|
+
class: "vkf-date-picker-range-select-item",
|
|
136
|
+
onClick: ($event) => _ctx.modelValue = item.value
|
|
137
|
+
}, vue.toDisplayString(item.label), 9, _hoisted_2);
|
|
138
|
+
}),
|
|
139
|
+
128
|
|
140
|
+
/* KEYED_FRAGMENT */
|
|
141
|
+
))
|
|
142
|
+
],
|
|
143
|
+
512
|
|
144
|
+
/* NEED_PATCH */
|
|
145
|
+
), [
|
|
146
|
+
[vue.vShow, _ctx.selectOptions.length]
|
|
147
|
+
]),
|
|
148
|
+
vue.createVNode(_component_VkfDatePicker, vue.mergeProps({
|
|
149
|
+
modelValue: _ctx.modelValue,
|
|
150
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.modelValue = $event),
|
|
151
|
+
prop: _ctx.prop
|
|
152
|
+
}, _ctx.coreProps, { rules: _ctx.rulesProp }, vue.toHandlers(_ctx.coreEmits)), null, 16, ["modelValue", "prop", "rules"])
|
|
153
|
+
],
|
|
154
|
+
64
|
|
155
|
+
/* STABLE_FRAGMENT */
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
var VkfDatePickerRange = /* @__PURE__ */ _pluginVue_exportHelper._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/private-vunk-form/private-vunk-form/packages/components/date-picker-range/src/index.vue"]]);
|
|
159
|
+
|
|
160
|
+
var types = /*#__PURE__*/Object.freeze({
|
|
161
|
+
__proto__: null
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
VkfDatePickerRange.install = (app) => {
|
|
165
|
+
app.component(VkfDatePickerRange.name || "VkfDatePickerRange", VkfDatePickerRange);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
exports.VkfDatePickerRange = VkfDatePickerRange;
|
|
169
|
+
exports.__VkfDatePickerRange = types;
|
|
170
|
+
exports.default = VkfDatePickerRange;
|
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var formItem = require('@vunk/form/components/form-item');
|
|
6
|
+
var vue = require('vue');
|
|
7
|
+
var basic = require('@skzz/platform/api/basic');
|
|
8
|
+
var platform = require('@skzz/platform/shared/fetch/platform');
|
|
9
|
+
var elementPlus = require('element-plus');
|
|
10
|
+
var utilsFetch = require('@vunk/core/shared/utils-fetch');
|
|
11
|
+
var index = require('../index.cjs');
|
|
12
|
+
var composables = require('@vunk/core/composables');
|
|
13
|
+
var index$1 = require('../index2.cjs');
|
|
14
|
+
var utilsClass = require('@vunk/core/shared/utils-class');
|
|
15
|
+
var _pluginVue_exportHelper = require('../_plugin-vue_export-helper.cjs');
|
|
16
|
+
|
|
17
|
+
const props = {
|
|
18
|
+
...formItem._VkfFormItemCtx.props,
|
|
19
|
+
fileId: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: ""
|
|
22
|
+
},
|
|
23
|
+
url: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: void 0
|
|
26
|
+
},
|
|
27
|
+
/**
|
|
28
|
+
* @description 分片大小
|
|
29
|
+
*/
|
|
30
|
+
chunkSize: {
|
|
31
|
+
type: Number,
|
|
32
|
+
default: 1024 * 1024 * 10
|
|
33
|
+
},
|
|
34
|
+
fileServiceType: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: void 0
|
|
37
|
+
},
|
|
38
|
+
/**
|
|
39
|
+
* @description
|
|
40
|
+
* v-model:fileStatus 当前文件状态: wait, doPause, pause, doDownload, downloading, error, done
|
|
41
|
+
*/
|
|
42
|
+
fileStatus: {
|
|
43
|
+
type: String,
|
|
44
|
+
default: void 0
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const emits = {
|
|
48
|
+
"update:fileStatus": null
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
var Status = /* @__PURE__ */ ((Status2) => {
|
|
52
|
+
Status2["wait"] = "wait";
|
|
53
|
+
Status2["doPause"] = "doPause";
|
|
54
|
+
Status2["pause"] = "pause";
|
|
55
|
+
Status2["doDownload"] = "doDownload";
|
|
56
|
+
Status2["downloading"] = "downloading";
|
|
57
|
+
Status2["error"] = "error";
|
|
58
|
+
Status2["done"] = "done";
|
|
59
|
+
return Status2;
|
|
60
|
+
})(Status || {});
|
|
61
|
+
|
|
62
|
+
const restFetch = new utilsFetch.RestFetch({
|
|
63
|
+
baseURL: platform.restFetch.baseURL,
|
|
64
|
+
presetRequestInit: (config) => {
|
|
65
|
+
const header = config.headers;
|
|
66
|
+
const token = index.getToken();
|
|
67
|
+
if (token) {
|
|
68
|
+
header.set("Token", token);
|
|
69
|
+
}
|
|
70
|
+
return config;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
const downChunk = (params, init) => {
|
|
74
|
+
return new Promise((resolve, reject) => {
|
|
75
|
+
const xhr = new XMLHttpRequest();
|
|
76
|
+
let url = `${restFetch.baseURL}/file/downloadByRange?fileId=${params.fileId}`;
|
|
77
|
+
if (params.fileServiceType) {
|
|
78
|
+
url += `&fileServiceType=${params.fileServiceType}`;
|
|
79
|
+
xhr.setRequestHeader("fileServiceType", params.fileServiceType);
|
|
80
|
+
}
|
|
81
|
+
if (init?.onprogress) {
|
|
82
|
+
xhr.onprogress = init?.onprogress;
|
|
83
|
+
}
|
|
84
|
+
xhr.open("GET", url, true);
|
|
85
|
+
xhr.responseType = "blob";
|
|
86
|
+
xhr.setRequestHeader("Token", index.getToken());
|
|
87
|
+
xhr.setRequestHeader("tenant", "default");
|
|
88
|
+
xhr.setRequestHeader("application", "platform");
|
|
89
|
+
xhr.setRequestHeader("Content-Range", `bytes=${params.start}-${params.end}`);
|
|
90
|
+
xhr.setRequestHeader("Accept-Ranges", "bytes");
|
|
91
|
+
xhr.onreadystatechange = (e) => {
|
|
92
|
+
const target = e.target;
|
|
93
|
+
if (xhr.readyState === 4) {
|
|
94
|
+
if (xhr.status === 200 || xhr.status === 206) {
|
|
95
|
+
if (init?.xhrs) {
|
|
96
|
+
const i = init.xhrs.findIndex((req) => req === xhr);
|
|
97
|
+
init.xhrs.splice(i, 1);
|
|
98
|
+
}
|
|
99
|
+
resolve({
|
|
100
|
+
data: target.response
|
|
101
|
+
});
|
|
102
|
+
} else if (xhr.status === 500) {
|
|
103
|
+
reject(target.response);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
xhr.onerror = () => {
|
|
108
|
+
reject(xhr.response);
|
|
109
|
+
};
|
|
110
|
+
try {
|
|
111
|
+
xhr.send();
|
|
112
|
+
} catch (err) {
|
|
113
|
+
reject(err);
|
|
114
|
+
}
|
|
115
|
+
init?.xhrs?.push(xhr);
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
var _sfc_main = vue.defineComponent({
|
|
120
|
+
name: "VkfDownloadPlus",
|
|
121
|
+
components: {
|
|
122
|
+
VkfFormItem: formItem.VkfFormItem,
|
|
123
|
+
ElButtonGroup: elementPlus.ElButtonGroup,
|
|
124
|
+
ElButton: elementPlus.ElButton,
|
|
125
|
+
ElInput: elementPlus.ElInput
|
|
126
|
+
},
|
|
127
|
+
props,
|
|
128
|
+
emits,
|
|
129
|
+
setup(props2, { emit }) {
|
|
130
|
+
const formItemBindProps = formItem._VkfFormItemCtx.createBindProps(props2);
|
|
131
|
+
vue.watchEffect(() => {
|
|
132
|
+
restFetch.baseURL = props2.url || platform.restFetch.baseURL;
|
|
133
|
+
});
|
|
134
|
+
const fileInfo = vue.ref();
|
|
135
|
+
rFileInfo();
|
|
136
|
+
vue.watch(() => props2.fileId, rFileInfo);
|
|
137
|
+
function rFileInfo() {
|
|
138
|
+
if (!props2.fileId) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
basic.rFile({
|
|
142
|
+
fileId: props2.fileId
|
|
143
|
+
}).then((res) => {
|
|
144
|
+
fileInfo.value = res;
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
const filePrefixIcon = vue.computed(() => {
|
|
148
|
+
if (fileStatus.value === Status.error) {
|
|
149
|
+
return index$1.circle_close_filled_default;
|
|
150
|
+
}
|
|
151
|
+
return index$1.download_default;
|
|
152
|
+
});
|
|
153
|
+
const chunks = vue.ref([]);
|
|
154
|
+
const downloadingXhrs = vue.ref([]);
|
|
155
|
+
const fileStatus = composables.useModelComputed({
|
|
156
|
+
default: Status.wait,
|
|
157
|
+
key: "fileStatus"
|
|
158
|
+
}, props2, emit);
|
|
159
|
+
const handleDownload = () => {
|
|
160
|
+
if (!fileInfo.value) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const fileSize = fileInfo.value.size;
|
|
164
|
+
const fileId = fileInfo.value.id;
|
|
165
|
+
const chunksLength = Math.ceil(fileSize / props2.chunkSize);
|
|
166
|
+
chunks.value = Array.from({ length: chunksLength }, (_, i) => {
|
|
167
|
+
const start = i * props2.chunkSize;
|
|
168
|
+
const end = Math.min(
|
|
169
|
+
start + props2.chunkSize,
|
|
170
|
+
fileSize
|
|
171
|
+
) - 1;
|
|
172
|
+
let downloadedChunk = {};
|
|
173
|
+
if (chunks.value[i] && chunks.value[i].start === start && chunks.value[i].end === end && chunks.value[i].status === Status.done) {
|
|
174
|
+
downloadedChunk = chunks.value[i];
|
|
175
|
+
}
|
|
176
|
+
return {
|
|
177
|
+
start,
|
|
178
|
+
end,
|
|
179
|
+
index: i,
|
|
180
|
+
status: Status.wait,
|
|
181
|
+
fileId,
|
|
182
|
+
fileServiceType: props2.fileServiceType,
|
|
183
|
+
progress: 0,
|
|
184
|
+
...downloadedChunk
|
|
185
|
+
};
|
|
186
|
+
});
|
|
187
|
+
fileStatus.value = Status.downloading;
|
|
188
|
+
const needDownloadChunks = chunks.value.filter(
|
|
189
|
+
(v) => v.status === Status.wait || v.status === Status.error
|
|
190
|
+
);
|
|
191
|
+
rChunkFiles(needDownloadChunks).then(() => {
|
|
192
|
+
const blobs = chunks.value.map((item) => {
|
|
193
|
+
return item.data;
|
|
194
|
+
});
|
|
195
|
+
return new Blob(
|
|
196
|
+
blobs,
|
|
197
|
+
{ type: "application/octet-stream" }
|
|
198
|
+
);
|
|
199
|
+
}).then((blob) => {
|
|
200
|
+
const url = URL.createObjectURL(blob);
|
|
201
|
+
const a = document.createElement("a");
|
|
202
|
+
a.href = url;
|
|
203
|
+
a.download = fileInfo.value?.realName || "\u672A\u77E5\u6587\u4EF6";
|
|
204
|
+
a.click();
|
|
205
|
+
URL.revokeObjectURL(url);
|
|
206
|
+
}).then(() => {
|
|
207
|
+
fileStatus.value = Status.done;
|
|
208
|
+
}).catch(() => {
|
|
209
|
+
fileStatus.value = Status.error;
|
|
210
|
+
elementPlus.ElMessage.error("\u4E0B\u8F7D\u5931\u8D25");
|
|
211
|
+
});
|
|
212
|
+
};
|
|
213
|
+
vue.watch(() => fileStatus.value, (newVal) => {
|
|
214
|
+
if (newVal === Status.doDownload) {
|
|
215
|
+
handleDownload();
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
function rChunkFiles(chunks2, max = 4, retrys = 10) {
|
|
219
|
+
return new Promise((resolve, reject) => {
|
|
220
|
+
const len = chunks2.length;
|
|
221
|
+
let counter = 0;
|
|
222
|
+
if (len === 0) {
|
|
223
|
+
return resolve(void 0);
|
|
224
|
+
}
|
|
225
|
+
const retryArr = [];
|
|
226
|
+
const start = async () => {
|
|
227
|
+
while (counter < len && max > 0) {
|
|
228
|
+
max--;
|
|
229
|
+
const i = chunks2.findIndex(
|
|
230
|
+
(v) => v.status === Status.wait || v.status === Status.error
|
|
231
|
+
);
|
|
232
|
+
const currentChunk = chunks2[i];
|
|
233
|
+
if (currentChunk) {
|
|
234
|
+
currentChunk.status = Status.downloading;
|
|
235
|
+
downChunk(currentChunk, {
|
|
236
|
+
onprogress(ev) {
|
|
237
|
+
currentChunk.progress = parseInt(ev.loaded / ev.total * 100 + "");
|
|
238
|
+
},
|
|
239
|
+
xhrs: downloadingXhrs.value
|
|
240
|
+
}).then((res) => {
|
|
241
|
+
currentChunk.status = Status.done;
|
|
242
|
+
currentChunk.data = res.data;
|
|
243
|
+
max++;
|
|
244
|
+
counter++;
|
|
245
|
+
}).then(() => {
|
|
246
|
+
if (counter === len) {
|
|
247
|
+
resolve(void 0);
|
|
248
|
+
} else {
|
|
249
|
+
start();
|
|
250
|
+
}
|
|
251
|
+
}).catch(() => {
|
|
252
|
+
currentChunk.status = Status.error;
|
|
253
|
+
const index = currentChunk.index;
|
|
254
|
+
if (typeof retryArr[index] !== "number") {
|
|
255
|
+
retryArr[index] = 0;
|
|
256
|
+
}
|
|
257
|
+
retryArr[index]++;
|
|
258
|
+
console.warn(
|
|
259
|
+
index,
|
|
260
|
+
currentChunk,
|
|
261
|
+
retryArr[index],
|
|
262
|
+
"\u6B21\u62A5\u9519"
|
|
263
|
+
);
|
|
264
|
+
currentChunk.progress = -1;
|
|
265
|
+
if (retryArr[index] >= retrys) {
|
|
266
|
+
return reject();
|
|
267
|
+
}
|
|
268
|
+
max++;
|
|
269
|
+
start();
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
start();
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
const handlePause = () => {
|
|
278
|
+
downloadingXhrs.value.forEach((xhr) => {
|
|
279
|
+
xhr.abort();
|
|
280
|
+
});
|
|
281
|
+
downloadingXhrs.value = [];
|
|
282
|
+
fileStatus.value = Status.pause;
|
|
283
|
+
};
|
|
284
|
+
vue.watch(() => fileStatus.value, (newVal) => {
|
|
285
|
+
if (newVal === Status.doPause) {
|
|
286
|
+
handlePause();
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
vue.onBeforeUnmount(() => {
|
|
290
|
+
handlePause();
|
|
291
|
+
});
|
|
292
|
+
class OnlineToggle extends utilsClass.ToggleHandler {
|
|
293
|
+
constructor(listener) {
|
|
294
|
+
super();
|
|
295
|
+
this.listener = listener;
|
|
296
|
+
}
|
|
297
|
+
add() {
|
|
298
|
+
window.addEventListener("online", this.listener);
|
|
299
|
+
this.removeHandler = () => {
|
|
300
|
+
window.removeEventListener("online", this.listener);
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
const onlineToggle = new OnlineToggle(() => {
|
|
305
|
+
if (fileStatus.value === Status.error) {
|
|
306
|
+
fileStatus.value = Status.doDownload;
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
onlineToggle.add();
|
|
310
|
+
vue.onBeforeUnmount(() => {
|
|
311
|
+
onlineToggle.remove();
|
|
312
|
+
});
|
|
313
|
+
return {
|
|
314
|
+
formItemBindProps,
|
|
315
|
+
fileInfo,
|
|
316
|
+
handleDownload,
|
|
317
|
+
handlePause,
|
|
318
|
+
Status,
|
|
319
|
+
chunks,
|
|
320
|
+
fileStatus,
|
|
321
|
+
filePrefixIcon
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
const _hoisted_1 = { class: "vkf-download-plus-main" };
|
|
327
|
+
const _hoisted_2 = { class: "vkf-download-plus-label" };
|
|
328
|
+
const _hoisted_3 = {
|
|
329
|
+
key: 0,
|
|
330
|
+
class: "vkf-download-plus-cube-x"
|
|
331
|
+
};
|
|
332
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
333
|
+
const _component_ElInput = vue.resolveComponent("ElInput");
|
|
334
|
+
const _component_el_button = vue.resolveComponent("el-button");
|
|
335
|
+
const _component_el_button_group = vue.resolveComponent("el-button-group");
|
|
336
|
+
const _component_VkfFormItem = vue.resolveComponent("VkfFormItem");
|
|
337
|
+
return vue.openBlock(), vue.createBlock(
|
|
338
|
+
_component_VkfFormItem,
|
|
339
|
+
vue.mergeProps(_ctx.formItemBindProps, { class: "vkf-download-plus" }),
|
|
340
|
+
{
|
|
341
|
+
default: vue.withCtx(() => [
|
|
342
|
+
vue.createElementVNode("div", _hoisted_1, [
|
|
343
|
+
vue.createElementVNode("label", _hoisted_2, [
|
|
344
|
+
vue.createVNode(_component_ElInput, {
|
|
345
|
+
class: vue.normalizeClass({
|
|
346
|
+
"is-error": _ctx.fileStatus === _ctx.Status.error
|
|
347
|
+
}),
|
|
348
|
+
"prefix-icon": _ctx.filePrefixIcon,
|
|
349
|
+
"model-value": _ctx.fileInfo?.realName,
|
|
350
|
+
readonly: ""
|
|
351
|
+
}, null, 8, ["class", "prefix-icon", "model-value"]),
|
|
352
|
+
_ctx.fileStatus === _ctx.Status.downloading || _ctx.fileStatus === _ctx.Status.pause ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3, [
|
|
353
|
+
(vue.openBlock(true), vue.createElementBlock(
|
|
354
|
+
vue.Fragment,
|
|
355
|
+
null,
|
|
356
|
+
vue.renderList(_ctx.chunks, (chunk) => {
|
|
357
|
+
return vue.openBlock(), vue.createElementBlock(
|
|
358
|
+
"div",
|
|
359
|
+
{
|
|
360
|
+
key: chunk.fileId + "-" + chunk.index,
|
|
361
|
+
class: vue.normalizeClass(["vkf-download-plus-cube", {
|
|
362
|
+
"error": chunk.status == _ctx.Status.error
|
|
363
|
+
}]),
|
|
364
|
+
style: vue.normalizeStyle({
|
|
365
|
+
width: 100 / _ctx.chunks.length + "%"
|
|
366
|
+
})
|
|
367
|
+
},
|
|
368
|
+
[
|
|
369
|
+
vue.createElementVNode(
|
|
370
|
+
"div",
|
|
371
|
+
{
|
|
372
|
+
class: vue.normalizeClass({
|
|
373
|
+
"uploading": chunk.progress > 0 && chunk.progress < 100,
|
|
374
|
+
"success": chunk.progress == 100
|
|
375
|
+
}),
|
|
376
|
+
style: vue.normalizeStyle({
|
|
377
|
+
height: chunk.progress + "%"
|
|
378
|
+
})
|
|
379
|
+
},
|
|
380
|
+
null,
|
|
381
|
+
6
|
|
382
|
+
/* CLASS, STYLE */
|
|
383
|
+
)
|
|
384
|
+
],
|
|
385
|
+
6
|
|
386
|
+
/* CLASS, STYLE */
|
|
387
|
+
);
|
|
388
|
+
}),
|
|
389
|
+
128
|
|
390
|
+
/* KEYED_FRAGMENT */
|
|
391
|
+
))
|
|
392
|
+
])) : vue.createCommentVNode("v-if", true)
|
|
393
|
+
]),
|
|
394
|
+
vue.createVNode(_component_el_button_group, { class: "vkf-download-plus-btng" }, {
|
|
395
|
+
default: vue.withCtx(() => [
|
|
396
|
+
_ctx.fileStatus === _ctx.Status.downloading ? (vue.openBlock(), vue.createBlock(_component_el_button, {
|
|
397
|
+
key: 0,
|
|
398
|
+
type: "danger",
|
|
399
|
+
onClick: _ctx.handlePause
|
|
400
|
+
}, {
|
|
401
|
+
default: vue.withCtx(() => [
|
|
402
|
+
vue.createTextVNode(" \u6682\u505C ")
|
|
403
|
+
]),
|
|
404
|
+
_: 1
|
|
405
|
+
/* STABLE */
|
|
406
|
+
}, 8, ["onClick"])) : (vue.openBlock(), vue.createBlock(_component_el_button, {
|
|
407
|
+
key: 1,
|
|
408
|
+
type: "primary",
|
|
409
|
+
onClick: _ctx.handleDownload
|
|
410
|
+
}, {
|
|
411
|
+
default: vue.withCtx(() => [
|
|
412
|
+
vue.createTextVNode(" \u4E0B\u8F7D ")
|
|
413
|
+
]),
|
|
414
|
+
_: 1
|
|
415
|
+
/* STABLE */
|
|
416
|
+
}, 8, ["onClick"]))
|
|
417
|
+
]),
|
|
418
|
+
_: 1
|
|
419
|
+
/* STABLE */
|
|
420
|
+
})
|
|
421
|
+
])
|
|
422
|
+
]),
|
|
423
|
+
_: 1
|
|
424
|
+
/* STABLE */
|
|
425
|
+
},
|
|
426
|
+
16
|
|
427
|
+
/* FULL_PROPS */
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
var VkfDownloadPlus = /* @__PURE__ */ _pluginVue_exportHelper._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/private-vunk-form/private-vunk-form/packages/components/download-plus/src/index.vue"]]);
|
|
431
|
+
|
|
432
|
+
var types = /*#__PURE__*/Object.freeze({
|
|
433
|
+
__proto__: null
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
VkfDownloadPlus.install = (app) => {
|
|
437
|
+
app.component(
|
|
438
|
+
VkfDownloadPlus.name || "VkfDownloadPlus",
|
|
439
|
+
VkfDownloadPlus
|
|
440
|
+
);
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
exports.VkfDownloadPlus = VkfDownloadPlus;
|
|
444
|
+
exports.__VkfDownloadPlus = types;
|
|
445
|
+
exports.default = VkfDownloadPlus;
|