@qynpm/ui 1.1.0 → 1.2.0

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,857 +0,0 @@
1
- import { ElUpload as dt, ElIcon as ct, ElPopover as ft, ElInput as pt, ElImageViewer as mt, ElDialog as vt } from "element-plus/es";
2
- import { openBlock as b, createElementBlock as _, normalizeStyle as gt, normalizeClass as me, createElementVNode as h, createVNode as k, createSlots as yt, withCtx as S, withModifiers as y, Fragment as Y, toDisplayString as K, createCommentVNode as x, renderSlot as ht, createBlock as xt, createTextVNode as Z, ref as p, onMounted as Ae, computed as U, watch as $, toRaw as ve, nextTick as Oe, onBeforeUnmount as Me } from "vue";
3
- import { InfoFilled as wt, Plus as bt } from "@element-plus/icons-vue";
4
- import { useFormDisabled as Ne, genFileId as ge, ElLoading as Ke, ElMessage as w } from "element-plus";
5
- import { a as Ut } from "./js.cookie-BA-dL3zT.mjs";
6
- import { _ as _t } from "./_plugin-vue_export-helper-CHgC5LLL.mjs";
7
- const Vt = "Admin-Token";
8
- function We(j = Vt) {
9
- return Ut.get(j);
10
- }
11
- const Ft = /* @__PURE__ */ Object.assign({
12
- name: "QyUpload"
13
- }, {
14
- __name: "index",
15
- props: {
16
- /**
17
- * 受控值。valueFormat 为 object 时结构为 { files, text },
18
- * array 时为 string[],string 时为逗号分隔 URL。
19
- */
20
- modelValue: { type: [Object, Array, String], default: void 0 },
21
- /** 已选择的浏览器本地文件,不与上传完成后的远程值混用。 */
22
- selectedFiles: { type: Array, default: () => [] },
23
- /** 是否在选择后立即上传;false 时只维护 selectedFiles。 */
24
- autoUpload: { type: Boolean, default: !0 },
25
- /** Qy 展示模式:media-card | file-list。 */
26
- variant: { type: String, default: "media-card" },
27
- /**
28
- * 初始值,结构为 { files: '逗号分隔的URL', text: '文字内容' }
29
- * 非受控模式,仅初始化时读取一次
30
- */
31
- defaultValue: { type: Object, default: () => ({ files: "", text: "" }) },
32
- /** v-model 输出格式:object | array | string */
33
- valueFormat: { type: String, default: "object" },
34
- /** 是否显示底部文字备注区 */
35
- showText: { type: Boolean, default: !0 },
36
- /** 是否显示纯粘贴输入条,不保存文字,仅用于承接 Ctrl+V 图片 */
37
- showPasteInput: { type: Boolean, default: !1 },
38
- /** 文字区占位文案,也用于凭证上传的粘贴提示 */
39
- pastePlaceholder: { type: String, default: "输入文字" },
40
- /** 是否多选 */
41
- multiple: { type: Boolean, default: !0 },
42
- /** 是否禁用 */
43
- disabled: { type: Boolean, default: void 0 },
44
- /** 允许的文件类型后缀(如 ['jpg', 'mp4']) */
45
- fileType: { type: Array, default: () => [] },
46
- /** 单个文件大小限制(MB) */
47
- fileSize: { type: Number, default: 10 },
48
- /** 文件数量限制 */
49
- limit: { type: Number, default: 9 },
50
- /** 是否显示格式/大小提示 */
51
- isShowTip: { type: Boolean, default: !1 },
52
- /** 接口路径 */
53
- api: { type: String, default: "/permission-api/common/uploads" },
54
- /** FormData 中文件字段名 */
55
- name: { type: String, default: "file" },
56
- /** token 读取 key,对应 utils/auth 中的存储字段 */
57
- tokenKey: { type: String, default: "Admin-Token" },
58
- /** 是否支持视频模式(强制 limit=1) */
59
- supportVideo: { type: Boolean, default: !1 },
60
- /**
61
- * 卡片尺寸
62
- * 预设:'large'(160px) | 'default'(140px) | 'small'(80px)
63
- * 自定义:任意 CSS 单位,如 '60px'、'8vw'
64
- */
65
- size: { type: String, default: "default" },
66
- /** 禁用拖拽(默认在触发区开启) */
67
- disableDrag: { type: Boolean, default: !1 },
68
- /** 成功回调(用于复杂业务联动) */
69
- callBack: { type: Function, default: null },
70
- /** 上传时附加的额外 FormData 字段 */
71
- extraData: { type: Object, default: () => ({}) },
72
- /** 自定义上传请求,用于接入宿主项目 request / 鉴权 / baseURL。 */
73
- uploadRequest: { type: Function, default: null }
74
- },
75
- emits: [
76
- "update:modelValue",
77
- "update:selectedFiles",
78
- "selectedFilesChange",
79
- "change",
80
- "success",
81
- "error",
82
- "remove",
83
- "invalid"
84
- ],
85
- setup(j, { expose: o, emit: c }) {
86
- const t = j, f = c, ye = p(null), I = p(null), W = p(null), r = p([]), X = p(null), ee = p(null), D = /* @__PURE__ */ new Map(), R = /* @__PURE__ */ new WeakMap();
87
- let m = Date.now(), z = !1;
88
- const te = p(!1), le = p([]), he = p(0), xe = p(!1), we = p(""), be = p(""), A = /* @__PURE__ */ new Set(), L = /* @__PURE__ */ new Map();
89
- function O(e) {
90
- A.delete(e) && URL.revokeObjectURL(e);
91
- }
92
- function ne() {
93
- for (const e of A) O(e);
94
- }
95
- function M(e) {
96
- const l = L.get(e);
97
- l && (L.delete(e), l.close());
98
- }
99
- function ae() {
100
- for (const e of L.keys()) M(e);
101
- }
102
- function ie(e) {
103
- var l;
104
- (l = D.get(e)) == null || l();
105
- }
106
- function oe() {
107
- for (const e of D.values()) e();
108
- }
109
- const E = p(!1), T = p(""), Xe = p(!1);
110
- Ae(() => {
111
- t.modelValue !== void 0 || !t.autoUpload || se(t.defaultValue);
112
- });
113
- const Ee = U(() => ({ large: "160px", default: "140px", small: "80px" })[t.size] ?? t.size), V = Ne(), He = U(
114
- () => r.value.some((e) => e.status === "uploading")
115
- ), Je = U(
116
- () => t.variant === "file-list" || t.supportVideo ? "text" : "picture-card"
117
- ), Ue = U(() => t.supportVideo ? 1 : !t.autoUpload && !t.multiple ? 2 : t.limit), Qe = U(
118
- () => {
119
- var e;
120
- return t.isShowTip && (t.fileSize || ((e = C.value) == null ? void 0 : e.length));
121
- }
122
- ), C = U(() => {
123
- var e;
124
- return (e = t.fileType) != null && e.length ? t.fileType.map((l) => String(l).trim().replace(/^\./, "").toLowerCase()).filter(Boolean) : t.variant === "file-list" ? [] : t.supportVideo ? ["mp4", "mov", "avi"] : ["jpg", "jpeg", "png", "gif", "webp"];
125
- }), H = U(() => {
126
- if (!t.autoUpload && !t.multiple) return !1;
127
- const e = t.supportVideo ? 1 : t.limit;
128
- return r.value.length >= e;
129
- }), Ge = U(
130
- () => C.value.map((e) => `.${e}`).join(",")
131
- ), Ye = U(() => ({
132
- "qy-upload--reached-limit": H.value,
133
- "qy-upload--disabled": V.value,
134
- "qy-upload--video": t.supportVideo,
135
- "qy-upload--without-text": !t.showText && !t.showPasteInput
136
- }));
137
- $(T, () => {
138
- z || q();
139
- }), $(
140
- () => t.modelValue,
141
- (e) => {
142
- t.autoUpload && e !== void 0 && se(e);
143
- },
144
- { immediate: !0, deep: !0 }
145
- ), $(
146
- () => [t.autoUpload, t.selectedFiles],
147
- ([e, l]) => {
148
- e || (r.value = P(l));
149
- },
150
- { immediate: !0, deep: !0 }
151
- );
152
- function re(e) {
153
- return Array.isArray(e) ? e.filter(Boolean) : e ? String(e).split(",").filter(Boolean) : [];
154
- }
155
- function _e(e) {
156
- return Array.isArray(e) ? { files: e, text: "" } : typeof e == "string" ? { files: re(e), text: "" } : e && typeof e == "object" ? {
157
- files: re(e.files),
158
- text: e.text ?? ""
159
- } : { files: [], text: "" };
160
- }
161
- function Ve(e = []) {
162
- return e.map((l, n) => ({
163
- name: String(l).split("/").pop() || `file-${n}`,
164
- url: l,
165
- status: "success",
166
- uid: ge()
167
- }));
168
- }
169
- function P(e = []) {
170
- return e.filter(Boolean).map((l, n) => {
171
- const a = ve(l);
172
- return {
173
- name: a.name,
174
- raw: a,
175
- status: "ready",
176
- uid: Fe(a, n)
177
- };
178
- });
179
- }
180
- function Fe(e, l) {
181
- if (e.uid != null) return e.uid;
182
- const n = R.get(e);
183
- return n ?? (m += l + 1, R.set(e, m), m);
184
- }
185
- function J(e = r.value) {
186
- return e.map((l) => {
187
- const n = l.raw ?? (l instanceof File ? l : null);
188
- return n ? ve(n) : null;
189
- }).filter(Boolean);
190
- }
191
- function N(e) {
192
- f("update:selectedFiles", e), f("selectedFilesChange", e);
193
- }
194
- function Ze(e, l) {
195
- if (t.autoUpload) return;
196
- const n = e == null ? void 0 : e.raw;
197
- if (n && !Q(n)) {
198
- r.value = P(t.selectedFiles);
199
- return;
200
- }
201
- const a = J(l);
202
- n && !a.includes(n) && a.push(n);
203
- const i = t.multiple ? a : a.slice(-1);
204
- r.value = P(i), N(i);
205
- }
206
- function ke(e) {
207
- const l = new Set(e.map((a) => a.url)), n = r.value.filter(
208
- (a) => (a.status === "ready" || a.status === "uploading") && !l.has(a.url)
209
- );
210
- return [...e, ...n];
211
- }
212
- function se(e) {
213
- const l = _e(e);
214
- z = !0, T.value = l.text, r.value = ke(Ve(l.files)), Oe(() => {
215
- z = !1;
216
- });
217
- }
218
- function ue(e) {
219
- return t.valueFormat === "array" ? e.files : t.valueFormat === "string" ? e.files.join(",") : e;
220
- }
221
- function $e() {
222
- var e;
223
- (e = X.value) == null || e.focus();
224
- }
225
- function et(e) {
226
- e.target.value = "";
227
- }
228
- function q(e) {
229
- const a = { files: (e ?? r.value).filter((i) => i.status === "success" && i.url).map((i) => i.url), text: T.value };
230
- f("update:modelValue", ue(a)), f("change", a), t.callBack && t.callBack(a);
231
- }
232
- function tt(e, l) {
233
- if (M(e.uid), ie(e.uid), O(e.url), !t.autoUpload) {
234
- const n = J(l);
235
- r.value = P(n), N(n), f("remove", e, l);
236
- return;
237
- }
238
- q(l), f("remove", e, l);
239
- }
240
- function de(e) {
241
- var n;
242
- const l = (e == null ? void 0 : e.name) || "";
243
- return l.includes(".") && ((n = l.split(".").pop()) == null ? void 0 : n.toLowerCase()) || "";
244
- }
245
- function ce(e) {
246
- var i, u, s;
247
- const l = ((u = (i = e == null ? void 0 : e.type) == null ? void 0 : i.toLowerCase) == null ? void 0 : u.call(i)) || "", n = {
248
- "image/jpeg": ["jpg", "jpeg"],
249
- "image/png": ["png"],
250
- "image/gif": ["gif"],
251
- "image/bmp": ["bmp"],
252
- "image/webp": ["webp"],
253
- "video/mp4": ["mp4"],
254
- "video/quicktime": ["mov"],
255
- "video/x-msvideo": ["avi"],
256
- "video/webm": ["webm"]
257
- };
258
- if (n[l]) return n[l];
259
- const a = (s = l.split("/")[1]) == null ? void 0 : s.split("+")[0];
260
- return a ? [a] : [];
261
- }
262
- function De(e) {
263
- if (!C.value.length) return !0;
264
- const l = de(e), n = ce(e);
265
- return [l, ...n].some(
266
- (a) => C.value.includes(a)
267
- );
268
- }
269
- function Q(e) {
270
- if (t.fileSize > 0 && e.size > t.fileSize * 1024 * 1024) {
271
- const n = {
272
- code: "size",
273
- file: e,
274
- message: `文件大小不能超过${t.fileSize}M`
275
- };
276
- return w.warning(n.message), f("invalid", n), !1;
277
- }
278
- if (!De(e)) {
279
- const n = {
280
- code: "extension",
281
- file: e,
282
- message: `格式不支持,仅允许: ${C.value.join("/")}`
283
- };
284
- return w.warning(n.message), f("invalid", n), !1;
285
- }
286
- return !0;
287
- }
288
- async function Te(e, l, n, a, i) {
289
- const u = fe(e), s = { close: () => a.close() };
290
- L.set(i, s);
291
- const g = () => L.get(i) === s;
292
- try {
293
- const d = await t.uploadRequest({
294
- file: e,
295
- formData: u,
296
- api: t.api,
297
- name: t.name,
298
- tokenKey: t.tokenKey,
299
- extraData: t.extraData
300
- });
301
- if (!g()) return;
302
- const B = Ce(d);
303
- if (!B) {
304
- const F = new Error("上传失败,未返回文件地址");
305
- w.error(F.message), f("error", F), n == null || n(F);
306
- return;
307
- }
308
- w.success("上传成功"), l == null || l({ ...typeof d == "object" && d ? d : {}, url: B });
309
- } catch (d) {
310
- if (!g()) return;
311
- w.error("上传失败"), f("error", d), n == null || n(d);
312
- } finally {
313
- g() && M(i);
314
- }
315
- }
316
- function fe(e) {
317
- const l = new FormData();
318
- return l.append(t.name, e), t.extraData && Object.entries(t.extraData).forEach(([n, a]) => l.append(n, a)), l;
319
- }
320
- function Ce(e) {
321
- var a, i;
322
- if (typeof e == "string") return e;
323
- const l = e || {}, n = l.urls ?? l.url ?? ((a = l.data) == null ? void 0 : a.urls) ?? ((i = l.data) == null ? void 0 : i.url) ?? "";
324
- return Array.isArray(n) ? n[0] || "" : n || "";
325
- }
326
- function pe(e, l, n, a, i = e.uid) {
327
- const u = Ke.service({
328
- target: I.value,
329
- text: "上传中",
330
- background: "rgba(255,255,255,0.7)"
331
- });
332
- if (t.uploadRequest) {
333
- Te(e, n, a, u, i);
334
- return;
335
- }
336
- const s = t.api.startsWith("http") ? t.api : window.location.origin + t.api.replace(/^([^/])/, "/$1"), g = fe(e), d = new XMLHttpRequest();
337
- let B = !1;
338
- const F = () => B ? !1 : (B = !0, D.delete(i), u.close(), !0);
339
- D.set(i, () => {
340
- F() && d.abort();
341
- }), d.onabort = F, d.open("POST", s);
342
- const ze = We(t.tokenKey);
343
- ze && d.setRequestHeader("Authorization", `Bearer ${ze}`), d.upload.onprogress = (v) => {
344
- !B && v.total > 0 && (l == null || l({ percent: v.loaded / v.total * 100 }));
345
- }, d.onload = () => {
346
- if (F()) {
347
- if (d.status < 200 || d.status >= 300) {
348
- const v = `上传失败 (HTTP ${d.status})`;
349
- w.error(v), f("error", { msg: v, status: d.status }), a == null || a(new Error(v));
350
- return;
351
- }
352
- try {
353
- const v = JSON.parse(d.responseText);
354
- v.code === 200 && v.urls ? (w.success("上传成功"), n == null || n({ ...v, url: v.urls })) : (w.error(v.msg || "上传失败"), f("error", v), a == null || a(v));
355
- } catch {
356
- w.error("上传失败,响应格式错误"), f("error", new Error("Response parse error")), a == null || a(new Error("Response parse error"));
357
- }
358
- }
359
- }, d.onerror = () => {
360
- F() && (w.error("上传失败,网络异常"), f("error", new Error("Network error")), a == null || a(new Error("Network error")));
361
- }, d.send(g);
362
- }
363
- function Se(e) {
364
- return V.value ? !1 : Q(e);
365
- }
366
- function Re(e, l) {
367
- const n = r.value.find(
368
- (a) => {
369
- var i;
370
- return a.uid === (e == null ? void 0 : e.uid) || ((i = a.raw) == null ? void 0 : i.uid) === (e == null ? void 0 : e.uid);
371
- }
372
- );
373
- n && (n.url = l, n.status = "success");
374
- }
375
- function lt(e) {
376
- pe(
377
- e.file,
378
- e.onProgress,
379
- (l) => {
380
- Re(e.file, l.url), e.onSuccess(l), q(), f("success", l);
381
- },
382
- (l) => e.onError(l)
383
- );
384
- }
385
- function nt(e) {
386
- var a;
387
- if (!e.url) return;
388
- const l = ((a = e.url.split(".").pop()) == null ? void 0 : a.toLowerCase()) || "";
389
- if (["mp4", "mov", "avi", "webm"].includes(l)) {
390
- we.value = e.url, be.value = e.name || "视频预览", xe.value = !0;
391
- return;
392
- }
393
- const n = r.value.filter(
394
- (i) => {
395
- var u;
396
- return i.status === "success" && i.url && !["mp4", "mov", "avi", "webm"].includes(
397
- (u = i.url.split(".").pop()) == null ? void 0 : u.toLowerCase()
398
- );
399
- }
400
- );
401
- le.value = n.map((i) => i.url), he.value = n.findIndex((i) => i.uid === e.uid) || 0, te.value = !0;
402
- }
403
- function at() {
404
- te.value = !1, le.value = [];
405
- }
406
- function Le(e, l) {
407
- if (e.name && de(e)) return e;
408
- const n = ce(e).find(
409
- (a) => C.value.includes(a)
410
- );
411
- return n ? new File([e], `paste-${Date.now() + l}.${n}`, {
412
- type: e.type,
413
- lastModified: e.lastModified
414
- }) : e;
415
- }
416
- function G(e) {
417
- if (!t.autoUpload) {
418
- const l = J(), n = e.filter((i) => Q(i));
419
- if (!n.length) return;
420
- const a = t.multiple ? [...l, ...n].slice(0, t.limit) : n.slice(-1);
421
- r.value = P(a), N(a);
422
- return;
423
- }
424
- for (let l = 0; l < e.length && !(r.value.length >= Ue.value); l++) {
425
- const n = Le(e[l], l);
426
- if (!Se(n)) continue;
427
- const a = ge(), i = URL.createObjectURL(n);
428
- A.add(i), r.value.push({
429
- uid: a,
430
- name: n.name || `file-${a}`,
431
- status: "uploading",
432
- percentage: 0,
433
- url: i
434
- }), pe(
435
- n,
436
- (u) => {
437
- const s = r.value.find((g) => g.uid === a);
438
- s && (s.percentage = u.percent);
439
- },
440
- (u) => {
441
- const s = r.value.find((g) => g.uid === a);
442
- s && (s.url !== u.url && O(s.url), s.status = "success", s.url = u.url, q(), f("success", u));
443
- },
444
- () => qe(a),
445
- a
446
- );
447
- }
448
- }
449
- function it(e) {
450
- const l = e.target, n = Array.from(l.files || []);
451
- if (l.value = "", V.value || !n.length) return;
452
- const a = t.supportVideo || !t.multiple ? n.slice(0, 1) : n;
453
- G(a);
454
- }
455
- function Pe(e) {
456
- const l = Array.from((e == null ? void 0 : e.files) || []).filter(
457
- (u) => {
458
- var s;
459
- return (s = u.type) == null ? void 0 : s.startsWith("image/");
460
- }
461
- );
462
- if (l.length) return l;
463
- const n = e == null ? void 0 : e.items;
464
- if (!n) return [];
465
- const a = [], i = /* @__PURE__ */ new Set();
466
- for (let u = 0; u < n.length; u++) {
467
- const s = n[u];
468
- if (s.kind === "file" && s.type.startsWith("image/")) {
469
- const g = s.getAsFile();
470
- g && !i.has(g) && (i.add(g), a.push(g));
471
- }
472
- }
473
- return a;
474
- }
475
- function ot(e) {
476
- if (V.value) return;
477
- const l = Pe(e.clipboardData);
478
- l.length && (e.preventDefault(), G(l));
479
- }
480
- function rt() {
481
- V.value || t.disableDrag || (E.value = !0);
482
- }
483
- function st() {
484
- E.value = !1;
485
- }
486
- function ut(e) {
487
- var n;
488
- if (E.value = !1, V.value || t.disableDrag || H.value) return;
489
- const l = Array.from(((n = e.dataTransfer) == null ? void 0 : n.files) || []);
490
- l.length && G(l);
491
- }
492
- function qe(e) {
493
- M(e), ie(e);
494
- const l = r.value.findIndex((n) => n.uid === e);
495
- l !== -1 && (O(r.value[l].url), r.value.splice(l, 1));
496
- }
497
- Me(() => {
498
- ae(), oe(), ne();
499
- });
500
- function Be() {
501
- var e;
502
- V.value || H.value || (e = W.value) == null || e.click();
503
- }
504
- function je() {
505
- var e;
506
- ae(), oe();
507
- for (const l of r.value)
508
- (e = l.url) != null && e.startsWith("blob:") && A.add(l.url);
509
- ne(), r.value = [], T.value = "", N([]), t.autoUpload && q();
510
- }
511
- o({
512
- /** 主动打开文件选择框,供表单或快捷操作调用 */
513
- openFileDialog: Be,
514
- /** 获取已上传成功的文件 URL 列表 */
515
- getPathList: () => r.value.filter((e) => e.status === "success").map((e) => e.url),
516
- /** 清空文件和文字,并同步 change 事件 */
517
- clearFiles: je,
518
- /** 获取完整值,结构与 change 事件保持一致 */
519
- getValue: () => ({
520
- files: r.value.filter((e) => e.status === "success" && e.url).map((e) => e.url),
521
- text: T.value
522
- }),
523
- /** 获取按 valueFormat 输出的值,便于外部不走 v-model 时读取 */
524
- getModelValue: () => ue({
525
- files: r.value.filter((e) => e.status === "success" && e.url).map((e) => e.url),
526
- text: T.value
527
- })
528
- });
529
- const Ie = { props: t, emit: f, uploadRef: ye, rootRef: I, nativeInputRef: W, fileList: r, inputRef: X, pasteInputRef: ee, pendingXhrs: D, selectedFileUids: R, get selectedFileUid() {
530
- return m;
531
- }, set selectedFileUid(e) {
532
- m = e;
533
- }, get syncingFromValue() {
534
- return z;
535
- }, set syncingFromValue(e) {
536
- z = e;
537
- }, viewerVisible: te, viewerUrlList: le, viewerIndex: he, videoVisible: xe, videoUrl: we, videoTitle: be, objectUrls: A, pendingCustomUploads: L, releaseObjectUrl: O, releaseObjectUrls: ne, cancelCustomUpload: M, cancelCustomUploads: ae, cancelXhr: ie, cancelXhrs: oe, isDragOver: E, localText: T, textExpanded: Xe, sizeValue: Ee, isUploadDisabled: V, isUploading: He, uploadListType: Je, effectiveLimit: Ue, shouldShowTip: Qe, allowedExtensions: C, isReachedLimit: H, acceptAttr: Ge, uploadClasses: Ye, normalizeFilesInput: re, parseValue: _e, createFileList: Ve, createSelectedFileList: P, getSelectedFileUid: Fe, getSelectedRawFiles: J, emitSelectedFiles: N, handleFileChange: Ze, mergePendingFileList: ke, syncValueToState: se, formatModelValue: ue, focusTextarea: $e, clearPasteInput: et, handleSyncValue: q, handleRemove: tt, getFileNameExtension: de, getMimeExtensions: ce, isAllowedFileType: De, validateFile: Q, uploadViaCustomRequest: Te, createUploadFormData: fe, resolveUploadUrl: Ce, uploadViaXhr: pe, handleBeforeUpload: Se, applyUploadResultToFile: Re, handleCustomUpload: lt, handlePreview: nt, closeViewer: at, createNamedPasteFile: Le, uploadFiles: G, handleNativeInputChange: it, collectImageFilesFromClipboard: Pe, handlePaste: ot, handleDragOver: rt, handleDragLeave: st, handleDrop: ut, handleRemoveByUid: qe, openFileDialog: Be, clearFiles: je, ref: p, computed: U, watch: $, onMounted: Ae, onBeforeUnmount: Me, nextTick: Oe, toRaw: ve, get Plus() {
538
- return bt;
539
- }, get InfoFilled() {
540
- return wt;
541
- }, get ElMessage() {
542
- return w;
543
- }, get ElLoading() {
544
- return Ke;
545
- }, get genFileId() {
546
- return ge;
547
- }, get useFormDisabled() {
548
- return Ne;
549
- }, get getToken() {
550
- return We;
551
- } };
552
- return Object.defineProperty(Ie, "__isScriptSetup", { enumerable: !1, value: !0 }), Ie;
553
- }
554
- }), kt = ["accept", "multiple", "disabled"], Dt = ["disabled"], Tt = { class: "qy-upload__hint" }, Ct = ["placeholder", "disabled"], St = ["src"], Rt = {
555
- key: 1,
556
- class: "qy-upload__tip"
557
- }, Lt = { class: "error" }, Pt = { class: "error" };
558
- function qt(j, o, c, t, f, ye) {
559
- var R;
560
- const I = ct, W = pt, r = ft, X = dt, ee = mt, D = vt;
561
- return b(), _(
562
- "div",
563
- {
564
- ref: "rootRef",
565
- class: me(["qy-upload", t.uploadClasses]),
566
- style: gt({ "--qy-upload-size": t.sizeValue })
567
- },
568
- [
569
- h("input", {
570
- ref: "nativeInputRef",
571
- class: "qy-upload__native-input",
572
- type: "file",
573
- accept: t.acceptAttr,
574
- multiple: c.supportVideo ? !1 : c.multiple,
575
- disabled: t.isUploadDisabled,
576
- onChange: t.handleNativeInputChange
577
- }, null, 40, kt),
578
- k(X, {
579
- ref: "uploadRef",
580
- "file-list": t.fileList,
581
- "onUpdate:fileList": o[7] || (o[7] = (m) => t.fileList = m),
582
- action: "#",
583
- multiple: c.supportVideo ? !1 : c.multiple,
584
- limit: t.effectiveLimit,
585
- "auto-upload": c.autoUpload,
586
- "list-type": t.uploadListType,
587
- accept: t.acceptAttr,
588
- disabled: t.isUploadDisabled,
589
- "http-request": t.handleCustomUpload,
590
- "before-upload": t.handleBeforeUpload,
591
- "on-change": t.handleFileChange,
592
- "on-preview": t.handlePreview,
593
- "on-remove": t.handleRemove
594
- }, yt({
595
- default: S(() => [
596
- c.variant !== "file-list" && !t.isReachedLimit ? (b(), _(
597
- "div",
598
- {
599
- key: 0,
600
- class: me(["qy-upload__trigger", { "is-dragover": t.isDragOver }]),
601
- onPaste: t.handlePaste,
602
- onDragover: y(t.handleDragOver, ["prevent"]),
603
- onDragleave: y(t.handleDragLeave, ["prevent"]),
604
- onDrop: y(t.handleDrop, ["prevent"])
605
- },
606
- [
607
- k(I, { class: "qy-upload__icon" }, {
608
- default: S(() => [
609
- k(t.Plus)
610
- ]),
611
- _: 1
612
- /* STABLE */
613
- }),
614
- c.supportVideo ? (b(), _(
615
- Y,
616
- { key: 0 },
617
- [
618
- o[10] || (o[10] = h(
619
- "span",
620
- { class: "qy-upload__label" },
621
- "点击上传视频",
622
- -1
623
- /* CACHED */
624
- )),
625
- h(
626
- "span",
627
- Tt,
628
- "支持 " + K(t.allowedExtensions.join(" / ")) + ",不超过 " + K(c.fileSize) + "MB",
629
- 1
630
- /* TEXT */
631
- )
632
- ],
633
- 64
634
- /* STABLE_FRAGMENT */
635
- )) : x("v-if", !0),
636
- x(" 文字输入框:可通过 showText 关闭,凭证上传这类纯图片场景不需要展示 "),
637
- c.showText ? (b(), _(
638
- "div",
639
- {
640
- key: 1,
641
- class: "qy-upload__text",
642
- onClick: o[4] || (o[4] = y(() => {
643
- }, ["stop"])),
644
- onPaste: y(t.handlePaste, ["stop"])
645
- },
646
- [
647
- k(r, {
648
- visible: t.textExpanded,
649
- "onUpdate:visible": o[3] || (o[3] = (m) => t.textExpanded = m),
650
- placement: "bottom-start",
651
- width: 220,
652
- trigger: "click",
653
- "popper-class": "qy-upload__text-popover",
654
- onAfterEnter: t.focusTextarea
655
- }, {
656
- reference: S(() => [
657
- h(
658
- "div",
659
- {
660
- class: me(["qy-upload__text-preview", { "is-placeholder": !t.localText }])
661
- },
662
- K(t.localText || c.pastePlaceholder),
663
- 3
664
- /* TEXT, CLASS */
665
- )
666
- ]),
667
- default: S(() => [
668
- k(W, {
669
- ref: "inputRef",
670
- modelValue: t.localText,
671
- "onUpdate:modelValue": o[1] || (o[1] = (m) => t.localText = m),
672
- type: "textarea",
673
- autosize: { minRows: 2, maxRows: 5 },
674
- placeholder: c.pastePlaceholder,
675
- disabled: t.isUploadDisabled,
676
- onBlur: o[2] || (o[2] = (m) => t.textExpanded = !1),
677
- onPaste: y(t.handlePaste, ["stop"])
678
- }, null, 8, ["modelValue", "placeholder", "disabled"])
679
- ]),
680
- _: 1
681
- /* STABLE */
682
- }, 8, ["visible"])
683
- ],
684
- 32
685
- /* NEED_HYDRATION */
686
- )) : c.showPasteInput ? (b(), _(
687
- Y,
688
- { key: 2 },
689
- [
690
- x(" 纯粘贴入口:不保存文字,只提供一个可聚焦区域承接 Ctrl+V 图片 "),
691
- h(
692
- "div",
693
- {
694
- class: "qy-upload__text",
695
- onClick: o[6] || (o[6] = y(() => {
696
- }, ["stop"])),
697
- onPaste: y(t.handlePaste, ["stop"])
698
- },
699
- [
700
- h("input", {
701
- ref: "pasteInputRef",
702
- class: "qy-upload__paste-input",
703
- placeholder: c.pastePlaceholder,
704
- disabled: t.isUploadDisabled,
705
- onPaste: y(t.handlePaste, ["stop"]),
706
- onInput: t.clearPasteInput,
707
- onClick: o[5] || (o[5] = y(() => {
708
- }, ["stop"]))
709
- }, null, 40, Ct)
710
- ],
711
- 32
712
- /* NEED_HYDRATION */
713
- )
714
- ],
715
- 2112
716
- /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
717
- )) : x("v-if", !0)
718
- ],
719
- 34
720
- /* CLASS, NEED_HYDRATION */
721
- )) : x("v-if", !0)
722
- ]),
723
- _: 2
724
- /* DYNAMIC */
725
- }, [
726
- c.variant === "file-list" ? {
727
- name: "trigger",
728
- fn: S(() => [
729
- h(
730
- "div",
731
- {
732
- class: "qy-upload__file-trigger",
733
- onClick: o[0] || (o[0] = y(() => {
734
- }, ["stop"])),
735
- onDragover: y(t.handleDragOver, ["prevent"]),
736
- onDragleave: y(t.handleDragLeave, ["prevent"]),
737
- onDrop: y(t.handleDrop, ["prevent"])
738
- },
739
- [
740
- ht(j.$slots, "trigger", {
741
- open: t.openFileDialog,
742
- disabled: t.isUploadDisabled,
743
- uploading: t.isUploading
744
- }, () => [
745
- h("button", {
746
- class: "qy-upload__file-button",
747
- type: "button",
748
- disabled: t.isUploadDisabled,
749
- onClick: t.openFileDialog
750
- }, " 选择文件 ", 8, Dt)
751
- ], !0)
752
- ],
753
- 32
754
- /* NEED_HYDRATION */
755
- )
756
- ]),
757
- key: "0"
758
- } : void 0
759
- ]), 1032, ["file-list", "multiple", "limit", "auto-upload", "list-type", "accept", "disabled"]),
760
- t.viewerVisible ? (b(), xt(ee, {
761
- key: 0,
762
- "url-list": t.viewerUrlList,
763
- "initial-index": t.viewerIndex,
764
- onClose: t.closeViewer
765
- }, null, 8, ["url-list", "initial-index"])) : x("v-if", !0),
766
- x(" 视频预览弹窗 "),
767
- k(D, {
768
- modelValue: t.videoVisible,
769
- "onUpdate:modelValue": o[8] || (o[8] = (m) => t.videoVisible = m),
770
- title: t.videoTitle,
771
- width: "640px",
772
- "append-to-body": "",
773
- "destroy-on-close": "",
774
- onClose: o[9] || (o[9] = (m) => t.videoVisible = !1)
775
- }, {
776
- default: S(() => [
777
- t.videoVisible ? (b(), _("video", {
778
- key: 0,
779
- src: t.videoUrl,
780
- controls: "",
781
- autoplay: "",
782
- style: { width: "100%", "max-height": "400px", "border-radius": "4px" }
783
- }, null, 8, St)) : x("v-if", !0)
784
- ]),
785
- _: 1
786
- /* STABLE */
787
- }, 8, ["modelValue", "title"]),
788
- t.shouldShowTip ? (b(), _("div", Rt, [
789
- k(I, null, {
790
- default: S(() => [
791
- k(t.InfoFilled)
792
- ]),
793
- _: 1
794
- /* STABLE */
795
- }),
796
- h("span", null, [
797
- o[13] || (o[13] = Z(
798
- " 请上传 ",
799
- -1
800
- /* CACHED */
801
- )),
802
- c.fileSize ? (b(), _(
803
- Y,
804
- { key: 0 },
805
- [
806
- o[11] || (o[11] = Z(
807
- "大小不超过 ",
808
- -1
809
- /* CACHED */
810
- )),
811
- h(
812
- "b",
813
- Lt,
814
- K(c.fileSize) + "MB",
815
- 1
816
- /* TEXT */
817
- )
818
- ],
819
- 64
820
- /* STABLE_FRAGMENT */
821
- )) : x("v-if", !0),
822
- (R = t.allowedExtensions) != null && R.length ? (b(), _(
823
- Y,
824
- { key: 1 },
825
- [
826
- o[12] || (o[12] = Z(
827
- ",格式为 ",
828
- -1
829
- /* CACHED */
830
- )),
831
- h(
832
- "b",
833
- Pt,
834
- K(t.allowedExtensions.join("/")),
835
- 1
836
- /* TEXT */
837
- )
838
- ],
839
- 64
840
- /* STABLE_FRAGMENT */
841
- )) : x("v-if", !0),
842
- o[14] || (o[14] = Z(
843
- " 的文件。 ",
844
- -1
845
- /* CACHED */
846
- ))
847
- ])
848
- ])) : x("v-if", !0)
849
- ],
850
- 6
851
- /* CLASS, STYLE */
852
- );
853
- }
854
- const Mt = /* @__PURE__ */ _t(Ft, [["render", qt], ["__scopeId", "data-v-61da1df2"], ["__file", "/home/runner/work/qy-component/qy-component/packages/ui/lib/upload/index.vue"]]);
855
- export {
856
- Mt as U
857
- };