@skyfox2000/webui 1.4.10 → 1.4.11

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.
@@ -1,420 +0,0 @@
1
- import { defineComponent as se, ref as L, computed as D, watch as A, resolveDirective as ie, createElementBlock as d, openBlock as u, normalizeClass as P, unref as n, createElementVNode as f, withDirectives as w, createBlock as ae, mergeProps as re, withCtx as C, createVNode as p, createTextVNode as z, toDisplayString as B, Fragment as le, renderList as ce, createCommentVNode as _ } from "vue";
2
- import { _ as ue } from "./index-C6BAsERS.js";
3
- import { a as $, _ as T } from "./toolIcon-DDp0EFRE.js";
4
- import { httpPost as I, ResStatus as K } from "@skyfox2000/fapi";
5
- import { L as Q, u as V, t as pe, _ as de } from "./upload-template-BK8iQQYz.js";
6
- import { p as R, U as a } from "./file-upload-BefTs4CH.js";
7
- import { combineParams as q } from "@skyfox2000/microbase";
8
- import g from "vue-m-message";
9
- import "async-validator";
10
- import "dayjs";
11
- import { Upload as me, Tag as fe, Popconfirm as he, Progress as ve } from "ant-design-vue";
12
- import "vue-draggable-next";
13
- import { _ as xe } from "./_plugin-vue_export-helper-CHgC5LLL.js";
14
- const ye = (l, S) => {
15
- const t = document.createElement("a"), m = URL.createObjectURL(l);
16
- t.href = m, t.download = S, t.style.display = "none", document.body.appendChild(t), t.click(), URL.revokeObjectURL(m), document.body.removeChild(t);
17
- }, we = (l, S, t) => {
18
- try {
19
- t && (l.api || (l.api = t.api), l.authorize === void 0 && (l.authorize = t.authorize));
20
- const m = q(l.params, S);
21
- return I(l, m).then((c) => {
22
- if ((c == null ? void 0 : c.status) === K.SUCCESS && c.data) {
23
- const s = c.data, b = s.Content, E = s.Key.split("/").pop(), k = atob(b), h = [];
24
- for (let F = 0; F < k.length; F++)
25
- h.push(k.charCodeAt(F));
26
- const U = new Blob([new Uint8Array(h)], {
27
- type: s.Type
28
- });
29
- ye(U, E);
30
- } else if ((c == null ? void 0 : c.errno) == Q) {
31
- V().logout(!1);
32
- return;
33
- } else
34
- g.error("下载文件失败!");
35
- });
36
- } catch (m) {
37
- console.error("下载失败:", m), g.error("文件下载失败,请稍后重试");
38
- }
39
- }, Ce = ["xlsx", "xls", "csv", "txt"], _e = (l, S, t) => {
40
- const m = S.split(".").pop();
41
- if (Ce.includes(m))
42
- console.log(l);
43
- else
44
- return g.error("文件类型不支持预览"), !1;
45
- const c = q(l.params, t);
46
- return I(l, c).then((s) => {
47
- if ((s == null ? void 0 : s.status) === K.SUCCESS && s.data) {
48
- const E = s.data.Content, k = atob(E), h = [];
49
- for (let U = 0; U < k.length; U++)
50
- h.push(k.charCodeAt(U));
51
- } else if ((s == null ? void 0 : s.errno) == Q) {
52
- V().logout(!1);
53
- return;
54
- } else
55
- g.error("文件预览失败!");
56
- });
57
- }, ge = { class: "flex items-center justify-between w-full" }, Se = { class: "w-35 mx-3" }, be = { class: "mt-4 px-3" }, ke = { class: "flex items-center justify-between" }, Ue = { class: "flex items-center" }, Fe = { class: "flex items-center" }, Ee = {
58
- key: 0,
59
- class: "mr-2"
60
- }, Oe = {
61
- key: 1,
62
- class: "flex items-center text-blue-500 hover:text-blue-700 mr-1 cursor-pointer"
63
- }, ze = ["onClick"], Le = {
64
- key: 2,
65
- class: "flex items-center text-blue-500 hover:text-blue-700 mr-1 cursor-pointer"
66
- }, Pe = ["onClick"], $e = {
67
- key: 3,
68
- class: "flex items-center text-red-500 hover:text-red-700 cursor-pointer"
69
- }, Ae = ["onClick"], Be = {
70
- key: 0,
71
- class: "text-sm text-nowrap"
72
- }, Te = { key: 0 }, Ie = /* @__PURE__ */ se({
73
- __name: "uploadList",
74
- props: {
75
- autoUpload: { type: Boolean, default: !1 },
76
- uploadUrl: {},
77
- downloadUrl: {},
78
- previewUrl: {},
79
- deleteUrl: {},
80
- fileList: { default: () => [] },
81
- placeholder: { default: "" },
82
- fileExt: {},
83
- maxFileSize: { default: 20 },
84
- maxCount: { default: 5 },
85
- maxCountTip: { type: Boolean, default: !1 },
86
- maxFileSizeTip: { type: Boolean, default: !0 },
87
- fileExtTip: { type: Boolean, default: !0 },
88
- parentPath: {},
89
- showActionText: { type: Boolean, default: !0 },
90
- showOnlineSwitch: { type: Boolean, default: !1 },
91
- showDelete: { type: Boolean, default: !0 }
92
- },
93
- emits: ["update:file-list"],
94
- setup(l, { emit: S }) {
95
- const t = l, m = pe(), { errInfo: c } = m, s = L(t.fileList), b = L([]), E = L(), k = S, h = L(!1), U = D(() => {
96
- var e;
97
- return (e = t.fileExt) != null && e.length ? t.fileExt.map((o) => `.${o}`).join(",") : "";
98
- }), F = (e) => {
99
- var o;
100
- if (t.fileExt && t.fileExt.length > 0) {
101
- const r = ((o = e.name.split(".").pop()) == null ? void 0 : o.toLowerCase()) || "";
102
- if (!t.fileExt.includes(r))
103
- return g.error("文件类型不支持"), !1;
104
- }
105
- return e.size / 1024 / 1024 > t.maxFileSize ? (g.error(`文件大小超过 ${t.maxFileSize}MB 限制`), !1) : !0;
106
- }, G = () => t.maxCount > 1 && s.value.length >= t.maxCount, H = (e) => {
107
- const o = e;
108
- return o.params || (o.params = {}), o.params.FileKey = o.name, t.parentPath && (o.params.FileKey = R.join("/", t.parentPath, o.name)), o.status = a.Pending, o;
109
- }, J = (e) => F(e) && t.autoUpload, W = (e) => {
110
- if (e.length === 0) return;
111
- const o = [...s.value];
112
- let r = !1;
113
- for (const O of e) {
114
- if (!F(O)) {
115
- r = !0;
116
- continue;
117
- }
118
- const y = H(O);
119
- if (t.maxCount === 1) {
120
- o.length = 0, o.push(y);
121
- break;
122
- }
123
- if (G()) {
124
- g.error(`最多上传 ${t.maxCount} 个文件`), r = !0;
125
- break;
126
- }
127
- console.log("checking file", y), console.log("existing file", o);
128
- const i = o.findIndex(
129
- (v) => v.name === y.name
130
- );
131
- i > -1 ? o[i] = y : o.push(y);
132
- }
133
- (!r || o.length > 0) && (s.value = o), b.value = [];
134
- }, X = (e) => {
135
- b.value = e, W(e);
136
- }, Y = D(() => ({
137
- accept: U.value,
138
- multiple: t.maxCount !== 1,
139
- fileList: b.value,
140
- "onUpdate:fileList": X,
141
- beforeUpload: J,
142
- listType: "text",
143
- showUploadList: !1
144
- }));
145
- A(
146
- () => t.fileList,
147
- (e) => {
148
- s.value = e;
149
- },
150
- { deep: !0, immediate: !0 }
151
- ), A(
152
- () => s.value,
153
- (e) => {
154
- k("update:file-list", e);
155
- },
156
- { deep: !0 }
157
- ), A(
158
- () => t.parentPath,
159
- (e) => {
160
- e && s.value.forEach((o) => {
161
- o.params.FileKey = R.join("/", e, o.fileName);
162
- });
163
- }
164
- );
165
- const j = (e) => {
166
- const o = s.value[e].minioFile, r = {
167
- api: t.downloadUrl.api,
168
- authorize: t.downloadUrl.authorize,
169
- url: t.downloadUrl.url,
170
- params: {
171
- Query: {
172
- FileKey: o.Key
173
- }
174
- }
175
- };
176
- we(r);
177
- }, Z = (e) => {
178
- e.minioFile && (e.minioFile.Status = e.status);
179
- }, M = (e) => {
180
- const o = s.value[e].minioFile, r = {
181
- api: t.previewUrl.api,
182
- authorize: t.previewUrl.authorize,
183
- url: t.previewUrl.url,
184
- params: {
185
- Query: {
186
- FileKey: o.Key
187
- }
188
- }
189
- };
190
- _e(r, o.FileName);
191
- }, N = (e) => {
192
- const o = s.value[e];
193
- t.deleteUrl && o.minioFile && o.minioFile.Key ? I(t.deleteUrl, {
194
- Query: {
195
- FileKey: o.minioFile.Key
196
- }
197
- }).then((r) => {
198
- r && r.status === K.SUCCESS && (g.success("删除文件成功!"), s.value.splice(e, 1));
199
- }) : s.value.splice(e, 1), h.value = !1;
200
- }, ee = (e, o) => {
201
- if (o === a.Pending) {
202
- N(e);
203
- return;
204
- }
205
- h.value = !0;
206
- }, te = () => {
207
- const e = t.fileExt && t.fileExt.length && t.fileExtTip ? `文件必须为 ${t.fileExt.join("/")}` : "", o = t.maxFileSize !== 0 && t.maxFileSizeTip ? `单文件最大 ${t.maxFileSize}MB` : "", r = t.maxCount !== 0 && t.maxCountTip ? `最多 ${t.maxCount} 个文件` : "";
208
- return [o, e, r].filter(Boolean).join(",");
209
- }, oe = (e) => {
210
- switch (e) {
211
- case a.Uploading:
212
- return "blue";
213
- case a.Success:
214
- return "green";
215
- case a.Error:
216
- return "red";
217
- case a.Online:
218
- return "green";
219
- case a.Offline:
220
- return "pink";
221
- default:
222
- return "cyan";
223
- }
224
- }, ne = (e) => {
225
- switch (e) {
226
- case a.Uploading:
227
- return "上传中";
228
- case a.Success:
229
- return "上传完成";
230
- case a.Error:
231
- return "上传失败";
232
- case a.Online:
233
- return "在线";
234
- case a.Offline:
235
- return "已下线";
236
- default:
237
- return "待上传";
238
- }
239
- };
240
- return (e, o) => {
241
- var O, y;
242
- const r = ie("auth");
243
- return u(), d("div", {
244
- class: P(["w-full border border-solid border-gray-100 mt-1 rounded-md py-5", [(O = n(c)) == null ? void 0 : O.errClass]])
245
- }, [
246
- f("div", ge, [
247
- f("div", Se, [
248
- w((u(), ae(n(me), re({
249
- ref_key: "fileUploader",
250
- ref: E
251
- }, Y.value), {
252
- default: C(() => {
253
- var i;
254
- return [
255
- p(n(ue), {
256
- class: P([((i = n(c)) == null ? void 0 : i.errClass) + "-text"])
257
- }, {
258
- default: C(() => o[1] || (o[1] = [
259
- z("选择文件")
260
- ])),
261
- _: 1,
262
- __: [1]
263
- }, 8, ["class"])
264
- ];
265
- }),
266
- _: 1
267
- }, 16)), [
268
- [r, { role: ["Super", "Admin"], permit: ":uploadlist:upload" }]
269
- ])
270
- ]),
271
- f("div", {
272
- class: P(["flex-1 text-sm text-gray-500", [((y = n(c)) == null ? void 0 : y.errClass) + "-text"]])
273
- }, B(te()), 3)
274
- ]),
275
- f("div", be, [
276
- (u(!0), d(le, null, ce(s.value, (i, v) => (u(), d("div", {
277
- key: v,
278
- class: "mb-2 pb-1"
279
- }, [
280
- f("div", ke, [
281
- f("div", Ue, [
282
- f("span", {
283
- class: P(["text-gray-700 mr-2", [i.status == n(a).Offline ? "line-through" : ""]])
284
- }, B(i.fileName ?? i.name), 3),
285
- f("span", null, [
286
- p(n(fe), {
287
- color: oe(i.status)
288
- }, {
289
- default: C(() => [
290
- z(B(ne(i.status)), 1)
291
- ]),
292
- _: 2
293
- }, 1032, ["color"])
294
- ])
295
- ]),
296
- f("div", Fe, [
297
- e.showOnlineSwitch && (i.status == n(a).Online || i.status == n(a).Offline) ? (u(), d("div", Ee, [
298
- p(n($), { title: "上线或下线" }, {
299
- default: C(() => [
300
- w(p(n(de), {
301
- checked: i.status,
302
- "onUpdate:checked": (x) => i.status = x,
303
- data: [
304
- { label: "上线", value: n(a).Online },
305
- { label: "下线", value: n(a).Offline }
306
- ],
307
- onChange: (x) => Z(i)
308
- }, null, 8, ["checked", "onUpdate:checked", "data", "onChange"]), [
309
- [r, { role: ["Super", "Admin"], permit: ":uploadlist:online" }]
310
- ])
311
- ]),
312
- _: 2
313
- }, 1024)
314
- ])) : _("", !0),
315
- e.downloadUrl && (i.status == n(a).Online || i.status == n(a).Offline) ? (u(), d("div", Oe, [
316
- p(n($), { title: "下载" }, {
317
- default: C(() => [
318
- w(p(n(T), {
319
- icon: "icon-download",
320
- clickable: "",
321
- onClick: (x) => j(v)
322
- }, null, 8, ["onClick"]), [
323
- [r, { role: ["Super", "Admin"], permit: ":uploadlist:download" }]
324
- ]),
325
- e.showActionText ? w((u(), d("span", {
326
- key: 0,
327
- class: "mr-2 text-sm text-nowrap",
328
- onClick: (x) => j(v)
329
- }, o[2] || (o[2] = [
330
- z("下载")
331
- ]), 8, ze)), [
332
- [r, { role: ["Super", "Admin"], permit: ":uploadlist:download" }]
333
- ]) : _("", !0)
334
- ]),
335
- _: 2
336
- }, 1024)
337
- ])) : _("", !0),
338
- e.previewUrl && (i.status == n(a).Online || i.status == n(a).Offline) ? (u(), d("div", Le, [
339
- p(n($), { title: "预览" }, {
340
- default: C(() => [
341
- w(p(n(T), {
342
- icon: "icon-eye",
343
- clickable: "",
344
- onClick: (x) => M(v)
345
- }, null, 8, ["onClick"]), [
346
- [r, { role: ["Super", "Admin"], permit: ":uploadlist:preview" }]
347
- ]),
348
- e.showActionText ? w((u(), d("span", {
349
- key: 0,
350
- class: "mr-2 text-sm text-nowrap",
351
- onClick: (x) => M(v)
352
- }, o[3] || (o[3] = [
353
- z("预览")
354
- ]), 8, Pe)), [
355
- [r, { role: ["Super", "Admin"], permit: ":uploadlist:preview" }]
356
- ]) : _("", !0)
357
- ]),
358
- _: 2
359
- }, 1024)
360
- ])) : _("", !0),
361
- e.showDelete !== !1 ? (u(), d("div", $e, [
362
- p(n(he), {
363
- open: h.value,
364
- cancelText: "否",
365
- okText: "是",
366
- title: "确定删除该文件吗?",
367
- okButtonProps: { size: "small" },
368
- cancelButtonProps: { size: "small" },
369
- onConfirm: (x) => N(v),
370
- onCancel: o[0] || (o[0] = (x) => h.value = !1)
371
- }, {
372
- default: C(() => [
373
- p(n($), { title: "删除" }, {
374
- default: C(() => [
375
- f("div", {
376
- onClick: (x) => ee(v, i.status)
377
- }, [
378
- w(p(n(T), {
379
- icon: "icon-new",
380
- angle: 45,
381
- clickable: ""
382
- }, null, 512), [
383
- [r, { role: ["Super", "Admin"], permit: ":uploadlist:delete" }]
384
- ]),
385
- e.showActionText ? w((u(), d("span", Be, o[4] || (o[4] = [
386
- z("删除")
387
- ]))), [
388
- [r, { role: ["Super", "Admin"], permit: ":uploadlist:delete" }]
389
- ]) : _("", !0)
390
- ], 8, Ae)
391
- ]),
392
- _: 2
393
- }, 1024)
394
- ]),
395
- _: 2
396
- }, 1032, ["open", "onConfirm"])
397
- ])) : _("", !0)
398
- ])
399
- ]),
400
- i.status !== n(a).Online && i.status !== n(a).Offline && i.status !== n(a).Success ? (u(), d("div", Te, [
401
- p(n(ve), {
402
- percent: i.percent,
403
- "stroke-width": 2,
404
- "show-info": !1,
405
- style: { height: "2px" }
406
- }, null, 8, ["percent"])
407
- ])) : _("", !0)
408
- ]))), 128))
409
- ])
410
- ], 2);
411
- };
412
- }
413
- }), Xe = /* @__PURE__ */ xe(Ie, [["__scopeId", "data-v-b9252ae9"]]);
414
- export {
415
- Ce as C,
416
- Xe as U,
417
- we as a,
418
- ye as d,
419
- _e as p
420
- };