mgacn-commonsdk 1.3.4 → 1.3.6
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/dist/FilePreview-Dx4GAw4K.js +1381 -0
- package/dist/mgacn-admin.js +2 -2
- package/dist/mgacn-commonsdk.js +1091 -984
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/FilePreview-BfYgqJbP.js +0 -877
|
@@ -0,0 +1,1381 @@
|
|
|
1
|
+
import Ce from "axios";
|
|
2
|
+
import { ElMessage as B } from "element-plus";
|
|
3
|
+
import * as re from "ali-oss";
|
|
4
|
+
import { ref as ie, computed as j, watch as je, onBeforeUnmount as Re, resolveComponent as se, resolveDirective as Fe, openBlock as N, createElementBlock as v, normalizeStyle as Ye, normalizeClass as Be, createElementVNode as E, toDisplayString as Le, createCommentVNode as L, createVNode as R, withCtx as oe, createTextVNode as Ge, withDirectives as He, unref as G, createBlock as ze, nextTick as Ve } from "vue";
|
|
5
|
+
import qe from "vue-pdf-embed";
|
|
6
|
+
import Xe from "video.js";
|
|
7
|
+
import We from "@vue-office/docx";
|
|
8
|
+
import Qe from "@vue-office/excel";
|
|
9
|
+
const ae = "__MGACN_COMMONSDK_SYSTEM_ID__", fe = "__MGACN_COMMONSDK_USER_ID__";
|
|
10
|
+
function Je(e) {
|
|
11
|
+
globalThis[ae] = e == null ? "" : String(e);
|
|
12
|
+
}
|
|
13
|
+
function z() {
|
|
14
|
+
return globalThis[ae] || "";
|
|
15
|
+
}
|
|
16
|
+
function Ze(e) {
|
|
17
|
+
globalThis[fe] = e == null ? "" : String(e);
|
|
18
|
+
}
|
|
19
|
+
function et() {
|
|
20
|
+
return globalThis[fe] || "";
|
|
21
|
+
}
|
|
22
|
+
function tt(e = {}) {
|
|
23
|
+
const {
|
|
24
|
+
baseURL: t = "",
|
|
25
|
+
timeout: n = 6e4,
|
|
26
|
+
tokenKey: r,
|
|
27
|
+
systemId: i,
|
|
28
|
+
userId: s,
|
|
29
|
+
loginUrl: o = "/login"
|
|
30
|
+
} = e;
|
|
31
|
+
i != null && i !== "" && Je(i), s != null && s !== "" && Ze(s);
|
|
32
|
+
const c = Ce.create({ baseURL: t, timeout: n });
|
|
33
|
+
let a = !1;
|
|
34
|
+
function f() {
|
|
35
|
+
typeof localStorage < "u" && localStorage.clear(), !a && (a = !0, setTimeout(() => {
|
|
36
|
+
typeof window < "u" && window.location.replace(o);
|
|
37
|
+
}, 1500));
|
|
38
|
+
}
|
|
39
|
+
return c.interceptors.request.use(
|
|
40
|
+
(u) => {
|
|
41
|
+
if (u.headers["Content-Type"] = "application/json;charset=UTF-8", typeof localStorage < "u" && r) {
|
|
42
|
+
const g = localStorage.getItem(r);
|
|
43
|
+
g && (u.headers.Authorization = g);
|
|
44
|
+
}
|
|
45
|
+
const l = z();
|
|
46
|
+
return l && (u.headers.systemId = l), u;
|
|
47
|
+
},
|
|
48
|
+
(u) => Promise.reject(u)
|
|
49
|
+
), c.interceptors.response.use(
|
|
50
|
+
(u) => {
|
|
51
|
+
if (u.status !== 200)
|
|
52
|
+
return Promise.reject(new Error(`请求发生错误,状态码 ${u.status}`));
|
|
53
|
+
const { data: l, config: g } = u;
|
|
54
|
+
if (g.responseType === "arraybuffer" || g.responseType === "blob")
|
|
55
|
+
return l;
|
|
56
|
+
if (l && l.code === 0) return l.data;
|
|
57
|
+
const d = Number(l == null ? void 0 : l.code);
|
|
58
|
+
if (d === 401 || d === 403)
|
|
59
|
+
return f(), Promise.reject(new Error("登录失效,请重新登录"));
|
|
60
|
+
const h = ce(l) || "请求失败", S = new Error(h);
|
|
61
|
+
return S.code = d, S.data = l == null ? void 0 : l.data, S.biz = l, Promise.reject(S);
|
|
62
|
+
},
|
|
63
|
+
(u) => {
|
|
64
|
+
var h, S;
|
|
65
|
+
const l = (h = u == null ? void 0 : u.response) == null ? void 0 : h.status;
|
|
66
|
+
if (l === 401 || l === 403)
|
|
67
|
+
return f(), Promise.reject(new Error("登录失效,请重新登录"));
|
|
68
|
+
const g = (S = u == null ? void 0 : u.response) == null ? void 0 : S.data, d = ce(g) || (u == null ? void 0 : u.message) || "请求失败";
|
|
69
|
+
return Promise.reject(new Error(String(d)));
|
|
70
|
+
}
|
|
71
|
+
), c;
|
|
72
|
+
}
|
|
73
|
+
function ce(e) {
|
|
74
|
+
if (e == null) return "";
|
|
75
|
+
if (typeof e == "string") {
|
|
76
|
+
const n = e.trim();
|
|
77
|
+
return n ? /^<!DOCTYPE html>/i.test(n) || /^<html[\s>]/i.test(n) ? "接口地址无效或未配置代理" : n.length > 200 ? `${n.slice(0, 200)}…` : n : "";
|
|
78
|
+
}
|
|
79
|
+
if (typeof e != "object") return String(e);
|
|
80
|
+
const t = [e.message, e.msg, e.data, e.error];
|
|
81
|
+
for (const n of t)
|
|
82
|
+
if (!(n == null || n === "") && (typeof n == "string" || typeof n == "number")) {
|
|
83
|
+
const r = String(n).trim();
|
|
84
|
+
return /^<!DOCTYPE html>/i.test(r) || /^<html[\s>]/i.test(r) ? "接口地址无效或未配置代理" : r.length > 200 ? `${r.slice(0, 200)}…` : r;
|
|
85
|
+
}
|
|
86
|
+
return "";
|
|
87
|
+
}
|
|
88
|
+
function an(e = {}) {
|
|
89
|
+
const t = tt(e);
|
|
90
|
+
return {
|
|
91
|
+
GET(n, r = {}) {
|
|
92
|
+
return t({ method: "get", url: n, ...r });
|
|
93
|
+
},
|
|
94
|
+
POST(n, r, i = {}) {
|
|
95
|
+
return t({ method: "post", url: n, data: r, ...i });
|
|
96
|
+
},
|
|
97
|
+
DELETE(n, r = {}) {
|
|
98
|
+
return t({ method: "delete", url: n, ...r });
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
const de = "__MGACN_COMMONSDK_REQUEST__";
|
|
103
|
+
function fn(e) {
|
|
104
|
+
globalThis[de] = e;
|
|
105
|
+
}
|
|
106
|
+
function nt() {
|
|
107
|
+
const e = globalThis[de];
|
|
108
|
+
if (!e)
|
|
109
|
+
throw new Error("[mgacn-commonsdk] 请先 app.use(MgacnCommonSdk, { tokenKey, baseURL })");
|
|
110
|
+
return e;
|
|
111
|
+
}
|
|
112
|
+
function me(e, t, n = "application/vnd.ms-excel") {
|
|
113
|
+
if (e == null || typeof window > "u") return;
|
|
114
|
+
const r = e instanceof Blob ? e : new Blob([e], { type: n }), i = window.URL.createObjectURL(r), s = document.createElement("a");
|
|
115
|
+
s.href = i, s.download = t || "download", s.style.display = "none", document.body.appendChild(s), s.click(), document.body.removeChild(s), window.URL.revokeObjectURL(i);
|
|
116
|
+
}
|
|
117
|
+
function K(e) {
|
|
118
|
+
return String(e).padStart(2, "0");
|
|
119
|
+
}
|
|
120
|
+
function rt(e = /* @__PURE__ */ new Date()) {
|
|
121
|
+
return `${e.getFullYear()}${K(e.getMonth() + 1)}${K(e.getDate())}${K(e.getHours())}${K(e.getMinutes())}${K(e.getSeconds())}`;
|
|
122
|
+
}
|
|
123
|
+
async function it(e) {
|
|
124
|
+
if (!(e instanceof Blob) || !e.type || !/json/i.test(e.type)) return;
|
|
125
|
+
const t = await e.text();
|
|
126
|
+
let n = "导出失败";
|
|
127
|
+
try {
|
|
128
|
+
const r = JSON.parse(t);
|
|
129
|
+
n = (r == null ? void 0 : r.message) || (r == null ? void 0 : r.msg) || n;
|
|
130
|
+
} catch {
|
|
131
|
+
}
|
|
132
|
+
throw new Error(n);
|
|
133
|
+
}
|
|
134
|
+
async function st(e = {}) {
|
|
135
|
+
const {
|
|
136
|
+
url: t,
|
|
137
|
+
data: n,
|
|
138
|
+
params: r,
|
|
139
|
+
method: i = "POST",
|
|
140
|
+
filename: s,
|
|
141
|
+
ext: o = "xlsx"
|
|
142
|
+
} = e;
|
|
143
|
+
if (!t) throw new Error("导出地址不能为空");
|
|
144
|
+
if (!s) throw new Error("导出文件名不能为空");
|
|
145
|
+
const c = nt(), a = String(i).toUpperCase();
|
|
146
|
+
let f;
|
|
147
|
+
a === "GET" ? f = await c.GET(t, { params: r, responseType: "blob" }) : f = await c.POST(t, n, { responseType: "blob" }), await it(f);
|
|
148
|
+
const l = /\.[a-z0-9]+$/i.test(s) ? s : `${s}_${rt()}.${o}`;
|
|
149
|
+
return me(f, l), l;
|
|
150
|
+
}
|
|
151
|
+
let O = null, D = null;
|
|
152
|
+
function ot(e, t) {
|
|
153
|
+
if (!e || t == null || t === "") return !1;
|
|
154
|
+
if (typeof t == "object")
|
|
155
|
+
return t.id != null && t.id !== "" && String(e.id) === String(t.id) || t.platformName != null && t.platformName !== "" && String(e.platformName || "") === String(t.platformName).trim();
|
|
156
|
+
const n = String(t).trim();
|
|
157
|
+
return e.id != null && String(e.id) === n || String(e.platformName || "") === n;
|
|
158
|
+
}
|
|
159
|
+
function pe(e) {
|
|
160
|
+
O = Array.isArray(e) ? e : [];
|
|
161
|
+
}
|
|
162
|
+
function ct() {
|
|
163
|
+
O = null, D = null;
|
|
164
|
+
}
|
|
165
|
+
function ut(e) {
|
|
166
|
+
if (!Array.isArray(O) || !O.length) return "";
|
|
167
|
+
const t = O.find((n) => ot(n, e));
|
|
168
|
+
return (t == null ? void 0 : t.platformLogo) || "";
|
|
169
|
+
}
|
|
170
|
+
async function lt() {
|
|
171
|
+
return O ?? (D || (D = (async () => {
|
|
172
|
+
try {
|
|
173
|
+
const e = await Y().listPlatformInfoAll();
|
|
174
|
+
return pe(e), O;
|
|
175
|
+
} finally {
|
|
176
|
+
D = null;
|
|
177
|
+
}
|
|
178
|
+
})(), D));
|
|
179
|
+
}
|
|
180
|
+
const at = ["jpg", "jpeg", "png", "gif", "webp", "bmp", "svg", "ico"], ft = ["mp4", "webm", "ogg", "mov", "m4v"], dt = ["pdf"], mt = ["docx"], pt = ["xlsx", "xls", "csv"];
|
|
181
|
+
function k(e = "") {
|
|
182
|
+
const t = String(e || "").trim();
|
|
183
|
+
if (!t) return "";
|
|
184
|
+
const n = t.split("?")[0].split("#")[0], r = n.includes("/") ? n.slice(n.lastIndexOf("/") + 1) : n, i = r.lastIndexOf(".");
|
|
185
|
+
return i < 0 || i === r.length - 1 ? "" : r.slice(i + 1).toLowerCase();
|
|
186
|
+
}
|
|
187
|
+
function ge(e = {}) {
|
|
188
|
+
const t = String(e.fileType || "").trim().toLowerCase();
|
|
189
|
+
if (t === "image" || t === "video" || t === "pdf" || t === "word" || t === "excel" || t === "unsupported")
|
|
190
|
+
return t;
|
|
191
|
+
const n = k(e.name) || k(e.src);
|
|
192
|
+
return at.includes(n) ? "image" : ft.includes(n) ? "video" : dt.includes(n) ? "pdf" : mt.includes(n) ? "word" : pt.includes(n) ? "excel" : "unsupported";
|
|
193
|
+
}
|
|
194
|
+
function ye(e = "", t = "") {
|
|
195
|
+
const n = k(t) || k(e);
|
|
196
|
+
return {
|
|
197
|
+
mp4: "video/mp4",
|
|
198
|
+
m4v: "video/mp4",
|
|
199
|
+
webm: "video/webm",
|
|
200
|
+
ogg: "video/ogg",
|
|
201
|
+
mov: "video/mp4"
|
|
202
|
+
// 多数 .mov 为 H.264,按 mp4 更易被 Chrome 等播放
|
|
203
|
+
}[n] || "video/mp4";
|
|
204
|
+
}
|
|
205
|
+
function Se(e = "", t = "") {
|
|
206
|
+
const n = String(e || "").trim();
|
|
207
|
+
return n ? (k(t) || k(e)) === "mov" ? [
|
|
208
|
+
{ src: n, type: "video/mp4" },
|
|
209
|
+
{ src: n, type: "video/quicktime" }
|
|
210
|
+
] : [{ src: n, type: ye(e, t) }] : [];
|
|
211
|
+
}
|
|
212
|
+
const be = "/hide/mg-file-preview";
|
|
213
|
+
function he(e = {}) {
|
|
214
|
+
const t = String(e.src || "").trim();
|
|
215
|
+
if (!t) return "";
|
|
216
|
+
const n = new URLSearchParams();
|
|
217
|
+
n.set("src", t);
|
|
218
|
+
const r = String(e.name || "").trim(), i = String(e.fileType || "").trim(), s = String(e.title || "").trim();
|
|
219
|
+
r && n.set("name", r), i && n.set("fileType", i), s && n.set("title", s);
|
|
220
|
+
const o = `#${be}?${n.toString()}`;
|
|
221
|
+
if (typeof window > "u") return o;
|
|
222
|
+
const { origin: c, pathname: a, search: f } = window.location;
|
|
223
|
+
return `${c}${a}${f}${o}`;
|
|
224
|
+
}
|
|
225
|
+
function we(e = {}, t = "_blank") {
|
|
226
|
+
const n = he(e);
|
|
227
|
+
return !n || typeof window > "u" ? null : window.open(n, t);
|
|
228
|
+
}
|
|
229
|
+
const gt = re.default ?? re, _e = "__MGACN_COMMONSDK_OSS_URL__";
|
|
230
|
+
function dn(e = "") {
|
|
231
|
+
globalThis[_e] = String(e || "").replace(/\/$/, "");
|
|
232
|
+
}
|
|
233
|
+
function Ne() {
|
|
234
|
+
return globalThis[_e] || "";
|
|
235
|
+
}
|
|
236
|
+
function ue(e) {
|
|
237
|
+
return String(e).padStart(2, "0");
|
|
238
|
+
}
|
|
239
|
+
function yt() {
|
|
240
|
+
const e = /* @__PURE__ */ new Date();
|
|
241
|
+
return `${e.getFullYear()}${ue(e.getMonth() + 1)}${ue(e.getDate())}`;
|
|
242
|
+
}
|
|
243
|
+
function Ae(e = 10) {
|
|
244
|
+
const t = "0123456789abcdefghijklmnopqrstuvwxyz";
|
|
245
|
+
let n = "";
|
|
246
|
+
for (let r = 0; r < e; r++)
|
|
247
|
+
n += t[Math.floor(Math.random() * t.length)];
|
|
248
|
+
return n;
|
|
249
|
+
}
|
|
250
|
+
function Q(e = "portal_cms") {
|
|
251
|
+
return `${e}/${yt()}/`;
|
|
252
|
+
}
|
|
253
|
+
function T(e = "") {
|
|
254
|
+
return /^https?:\/\//i.test(String(e || "").trim());
|
|
255
|
+
}
|
|
256
|
+
function Te(e = "") {
|
|
257
|
+
const t = String(e || "");
|
|
258
|
+
return T(t) ? /[?&](Expires|Signature|OSSAccessKeyId|x-oss-signature)=/i.test(t) : !1;
|
|
259
|
+
}
|
|
260
|
+
function $(e = "") {
|
|
261
|
+
if (T(e))
|
|
262
|
+
try {
|
|
263
|
+
const n = new URL(String(e)).searchParams.get("Expires");
|
|
264
|
+
if (!n || !/^\d+$/.test(n)) return;
|
|
265
|
+
const r = Number(n);
|
|
266
|
+
return r > 1e12 ? Math.floor(r / 1e3) : r;
|
|
267
|
+
} catch {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
function F(e, t = 12e4) {
|
|
272
|
+
return e == null || Number.isNaN(Number(e)) ? !1 : Number(e) * 1e3 - Date.now() <= t;
|
|
273
|
+
}
|
|
274
|
+
function w(e = "", t = "") {
|
|
275
|
+
const n = String(e || "").trim();
|
|
276
|
+
if (!n) return "";
|
|
277
|
+
if (!T(n)) return n.replace(/^\//, "").split("?")[0];
|
|
278
|
+
try {
|
|
279
|
+
const r = new URL(n);
|
|
280
|
+
let i = decodeURIComponent(r.pathname.replace(/^\//, ""));
|
|
281
|
+
if (t) {
|
|
282
|
+
const s = String(t).replace(/\/$/, "");
|
|
283
|
+
n.startsWith(`${s}/`) && (i = decodeURIComponent(n.slice(s.length + 1).split("?")[0]));
|
|
284
|
+
}
|
|
285
|
+
return i.split("?")[0];
|
|
286
|
+
} catch {
|
|
287
|
+
return "";
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
function J(e = {}) {
|
|
291
|
+
if (!e) return null;
|
|
292
|
+
if (typeof e == "string") {
|
|
293
|
+
const i = e.trim();
|
|
294
|
+
if (!i) return null;
|
|
295
|
+
const s = w(i);
|
|
296
|
+
return s ? {
|
|
297
|
+
fileName: s.split("/").pop() || "file",
|
|
298
|
+
fileKey: s,
|
|
299
|
+
fileUrl: T(i) ? i : "",
|
|
300
|
+
expireAt: void 0
|
|
301
|
+
} : null;
|
|
302
|
+
}
|
|
303
|
+
const t = String(e.fileUrl || e.url || "").trim(), n = String(e.fileKey || e.key || w(t) || "").trim();
|
|
304
|
+
if (!n && !t) return null;
|
|
305
|
+
const r = n || w(t);
|
|
306
|
+
return {
|
|
307
|
+
id: e.id,
|
|
308
|
+
fileName: e.fileName || e.name || (r || t).split("?")[0].split("/").filter(Boolean).pop() || "file",
|
|
309
|
+
fileKey: r,
|
|
310
|
+
fileUrl: T(t) ? t : "",
|
|
311
|
+
expireAt: e.expireAt != null ? Number(e.expireAt) : void 0,
|
|
312
|
+
bucketKind: e.bucketKind
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
const St = /* @__PURE__ */ new Set([
|
|
316
|
+
"previewSrc",
|
|
317
|
+
"previewUrl",
|
|
318
|
+
"url",
|
|
319
|
+
"raw",
|
|
320
|
+
"uid",
|
|
321
|
+
"status",
|
|
322
|
+
"percent",
|
|
323
|
+
"expireAt",
|
|
324
|
+
"name",
|
|
325
|
+
"key",
|
|
326
|
+
"fileUrl",
|
|
327
|
+
"fileKey",
|
|
328
|
+
"fileName",
|
|
329
|
+
"id"
|
|
330
|
+
]);
|
|
331
|
+
function V(e, t = {}) {
|
|
332
|
+
const n = String(e || "").trim();
|
|
333
|
+
return n ? (t.bucketKind || "private") === "public" && T(n) && !Te(n) ? n : T(n) ? w(n) || "" : n.replace(/^\//, "").split("?")[0] : "";
|
|
334
|
+
}
|
|
335
|
+
function ve(e, t) {
|
|
336
|
+
const n = J(e);
|
|
337
|
+
if (!n) return null;
|
|
338
|
+
const r = t && t.bucketKind || e && typeof e == "object" && e.bucketKind || "private", i = V(n.fileKey || n.fileUrl || "", { bucketKind: r });
|
|
339
|
+
if (!i) return null;
|
|
340
|
+
const s = {
|
|
341
|
+
...n.id != null && n.id !== "" ? { id: n.id } : {},
|
|
342
|
+
fileName: n.fileName || i.split("?")[0].split("/").filter(Boolean).pop() || "file",
|
|
343
|
+
fileUrl: i,
|
|
344
|
+
fileKey: V(i, { bucketKind: "private" }) || i
|
|
345
|
+
};
|
|
346
|
+
return e && typeof e == "object" && Object.keys(e).forEach((o) => {
|
|
347
|
+
St.has(o) || e[o] !== void 0 && (s[o] = e[o]);
|
|
348
|
+
}), t && typeof t == "object" && Object.keys(t).forEach((o) => {
|
|
349
|
+
t[o] !== void 0 && (s[o] = t[o]);
|
|
350
|
+
}), s;
|
|
351
|
+
}
|
|
352
|
+
function bt(e, t) {
|
|
353
|
+
return Array.isArray(e) ? e.map((n) => ve(n, t)).filter(Boolean) : [];
|
|
354
|
+
}
|
|
355
|
+
function ht(e = {}) {
|
|
356
|
+
const t = e.accessKeyId || e.AccessKeyId || e.accessKeyID || "", n = e.accessKeySecret || e.AccessKeySecret || "", r = e.securityToken || e.SecurityToken || e.stsToken || e.token || "", i = e.bucketName || e.bucket || e.BucketName || "", s = e.bucketKind === "public" ? "public" : "private";
|
|
357
|
+
let o = String(e.endPoint || e.endpoint || e.EndPoint || "").replace(/^https?:\/\//i, "").replace(/\/$/, "");
|
|
358
|
+
i && o.startsWith(`${i}.`) && (o = o.slice(i.length + 1));
|
|
359
|
+
const c = e.region || (o.startsWith("oss-") ? o.replace(/\.aliyuncs\.com.*$/i, "") : ""), a = String(e.host || e.ossUrl || e.domain || e.cdnDomain || "").trim().replace(/\/$/, ""), f = i && o ? `https://${i}.${o}` : Ne(), u = a || f;
|
|
360
|
+
return {
|
|
361
|
+
accessKeyId: t,
|
|
362
|
+
accessKeySecret: n,
|
|
363
|
+
securityToken: r,
|
|
364
|
+
bucketName: i,
|
|
365
|
+
endPoint: o,
|
|
366
|
+
region: c,
|
|
367
|
+
ossUrl: u,
|
|
368
|
+
host: u,
|
|
369
|
+
bucketKind: s,
|
|
370
|
+
expiration: e.expiration
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
function Z(e) {
|
|
374
|
+
return Y().getOssSts(e);
|
|
375
|
+
}
|
|
376
|
+
function wt(e) {
|
|
377
|
+
return Y().getUploadSign(e);
|
|
378
|
+
}
|
|
379
|
+
const _t = 120, Nt = 300, le = 50, P = /* @__PURE__ */ new Map(), H = /* @__PURE__ */ new Map();
|
|
380
|
+
function Ee(e = []) {
|
|
381
|
+
return [
|
|
382
|
+
...new Set(
|
|
383
|
+
(e || []).map((t) => w(t) || String(t || "").trim()).filter(Boolean)
|
|
384
|
+
)
|
|
385
|
+
];
|
|
386
|
+
}
|
|
387
|
+
function ke(e) {
|
|
388
|
+
return e == null ? "" : String(e);
|
|
389
|
+
}
|
|
390
|
+
async function At(e, t) {
|
|
391
|
+
const n = Ee(e).sort();
|
|
392
|
+
if (!n.length) return { items: [], expireAt: void 0 };
|
|
393
|
+
const r = [];
|
|
394
|
+
let i;
|
|
395
|
+
for (let s = 0; s < n.length; s += le) {
|
|
396
|
+
const o = n.slice(s, s + le), c = `${o.join("\0")}::${ke(t)}`;
|
|
397
|
+
let a = H.get(c);
|
|
398
|
+
if (!a) {
|
|
399
|
+
const u = { keys: o };
|
|
400
|
+
t != null && (u.ttlSeconds = t), a = Y().batchSign(u).finally(() => {
|
|
401
|
+
H.delete(c);
|
|
402
|
+
}), H.set(c, a);
|
|
403
|
+
}
|
|
404
|
+
const f = await a;
|
|
405
|
+
(f == null ? void 0 : f.expireAt) != null && (i = f.expireAt), Array.isArray(f == null ? void 0 : f.items) && r.push(...f.items);
|
|
406
|
+
}
|
|
407
|
+
return { items: r, expireAt: i };
|
|
408
|
+
}
|
|
409
|
+
function Tt(e) {
|
|
410
|
+
const t = P.get(e);
|
|
411
|
+
if (!t) return;
|
|
412
|
+
P.delete(e), t.timer && (clearTimeout(t.timer), t.timer = null);
|
|
413
|
+
const n = [...t.keySet], r = t.ttlSeconds;
|
|
414
|
+
At(n, r).then(
|
|
415
|
+
(i) => {
|
|
416
|
+
t.waiters.forEach((s) => s.resolve(i));
|
|
417
|
+
},
|
|
418
|
+
(i) => {
|
|
419
|
+
t.waiters.forEach((s) => s.reject(i));
|
|
420
|
+
}
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
function vt(e) {
|
|
424
|
+
const t = P.get(e);
|
|
425
|
+
if (!t) return;
|
|
426
|
+
t.timer && (clearTimeout(t.timer), t.timer = null);
|
|
427
|
+
const n = Date.now() - t.firstAt, r = Nt - n, i = r <= 0 ? 0 : Math.min(_t, r);
|
|
428
|
+
t.timer = setTimeout(() => {
|
|
429
|
+
Tt(e);
|
|
430
|
+
}, i);
|
|
431
|
+
}
|
|
432
|
+
function I(e = {}) {
|
|
433
|
+
const t = Ee(e.keys);
|
|
434
|
+
if (!t.length)
|
|
435
|
+
return Promise.resolve({ items: [], expireAt: void 0 });
|
|
436
|
+
const n = e.ttlSeconds, r = ke(n);
|
|
437
|
+
return new Promise((i, s) => {
|
|
438
|
+
let o = P.get(r);
|
|
439
|
+
o || (o = {
|
|
440
|
+
keySet: /* @__PURE__ */ new Set(),
|
|
441
|
+
waiters: [],
|
|
442
|
+
timer: null,
|
|
443
|
+
firstAt: Date.now(),
|
|
444
|
+
ttlSeconds: n
|
|
445
|
+
}, P.set(r, o)), t.forEach((c) => o.keySet.add(c)), o.waiters.push({ resolve: i, reject: s }), vt(r);
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
function Et(e) {
|
|
449
|
+
return I(e);
|
|
450
|
+
}
|
|
451
|
+
async function xe(e = {}) {
|
|
452
|
+
const { dir: t, foldName: n, getOss: r, ossinfo: i, bucketKind: s } = e, o = t || Q(n || "portal_cms"), c = i || (typeof r == "function" ? await r(o) : await Z({ dir: o, bucketKind: s })), a = ht(c || {});
|
|
453
|
+
if (!a.accessKeyId || !a.accessKeySecret || !a.bucketName)
|
|
454
|
+
throw new Error("[mgacn-commonsdk] 获取 OSS STS 失败:凭证字段不完整");
|
|
455
|
+
if (!a.securityToken)
|
|
456
|
+
throw new Error("[mgacn-commonsdk] 获取 OSS STS 失败:缺少 securityToken");
|
|
457
|
+
const f = {
|
|
458
|
+
bucket: a.bucketName,
|
|
459
|
+
accessKeyId: a.accessKeyId,
|
|
460
|
+
accessKeySecret: a.accessKeySecret,
|
|
461
|
+
stsToken: a.securityToken,
|
|
462
|
+
secure: !0,
|
|
463
|
+
success_action_status: "200"
|
|
464
|
+
};
|
|
465
|
+
a.region && (f.region = a.region), a.endPoint && (f.endpoint = a.endPoint);
|
|
466
|
+
const u = new gt(f);
|
|
467
|
+
return u.options.ossUrl = a.host || Ne(), u.options.uploadDir = o, u.options.bucketKind = a.bucketKind, u;
|
|
468
|
+
}
|
|
469
|
+
async function Oe({ key: e, bucketKind: t = "private", host: n = "" } = {}) {
|
|
470
|
+
const r = w(e) || String(e || "").trim();
|
|
471
|
+
if (!r) return { url: "", expireAt: void 0 };
|
|
472
|
+
if (t === "public") {
|
|
473
|
+
const i = String(n || "").replace(/\/$/, "");
|
|
474
|
+
return { url: i ? `${i}/${r}` : "", expireAt: void 0 };
|
|
475
|
+
}
|
|
476
|
+
try {
|
|
477
|
+
const i = await I({ keys: [r] }), o = (Array.isArray(i == null ? void 0 : i.items) ? i.items : []).find((f) => (f == null ? void 0 : f.key) === r), c = (o == null ? void 0 : o.url) || "", a = (o == null ? void 0 : o.expireAt) != null ? Number(o.expireAt) : (i == null ? void 0 : i.expireAt) != null ? Number(i.expireAt) : $(c);
|
|
478
|
+
return { url: c, expireAt: a };
|
|
479
|
+
} catch {
|
|
480
|
+
return { url: "", expireAt: void 0 };
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
async function kt(e = {}) {
|
|
484
|
+
var C, ne;
|
|
485
|
+
const { client: t, file: n, dir: r, foldName: i, fileName: s, onProgress: o, bucketKind: c } = e;
|
|
486
|
+
if (!n)
|
|
487
|
+
throw new Error("[mgacn-commonsdk] uploadToOss 缺少 file");
|
|
488
|
+
const a = t || await xe({
|
|
489
|
+
dir: r,
|
|
490
|
+
foldName: i,
|
|
491
|
+
bucketKind: c
|
|
492
|
+
}), f = r || a.options.uploadDir || Q(i), u = c || a.options.bucketKind || "private";
|
|
493
|
+
let l = s;
|
|
494
|
+
if (!l) {
|
|
495
|
+
const x = n.name || "file", _ = x.lastIndexOf("."), Ue = _ > -1 ? x.slice(_) : "";
|
|
496
|
+
l = `${f}${Ae(10)}${Ue}`;
|
|
497
|
+
}
|
|
498
|
+
const g = (x) => {
|
|
499
|
+
if (typeof o != "function") return;
|
|
500
|
+
const _ = Number(x);
|
|
501
|
+
Number.isFinite(_) && o(Math.min(100, Math.max(0, Math.round(_ * 100))));
|
|
502
|
+
}, h = {
|
|
503
|
+
partSize: Math.min(
|
|
504
|
+
2 * 1024 * 1024,
|
|
505
|
+
Math.max(256 * 1024, Math.ceil(n.size / 20) || 256 * 1024)
|
|
506
|
+
),
|
|
507
|
+
parallel: 3,
|
|
508
|
+
progress: async (x) => {
|
|
509
|
+
const _ = Math.min(0.9, Number(x) || 0);
|
|
510
|
+
g(_ > 0 && _ < 0.01 ? 0.01 : _);
|
|
511
|
+
}
|
|
512
|
+
}, S = async (x) => {
|
|
513
|
+
const _ = x && u === "public" ? { "x-oss-object-acl": "public-read" } : void 0;
|
|
514
|
+
return a.multipartUpload(l, n, {
|
|
515
|
+
...h,
|
|
516
|
+
..._ ? { headers: _ } : {}
|
|
517
|
+
});
|
|
518
|
+
};
|
|
519
|
+
let p;
|
|
520
|
+
try {
|
|
521
|
+
g(0.02), p = await S(u === "public");
|
|
522
|
+
} catch {
|
|
523
|
+
g(0.02), p = await S(!1);
|
|
524
|
+
}
|
|
525
|
+
const b = ((C = p == null ? void 0 : p.res) == null ? void 0 : C.statusCode) ?? ((ne = p == null ? void 0 : p.res) == null ? void 0 : ne.status);
|
|
526
|
+
if (b && b !== 200)
|
|
527
|
+
throw new Error("[mgacn-commonsdk] 上传失败");
|
|
528
|
+
g(0.92);
|
|
529
|
+
const m = String(a.options.ossUrl || "").replace(/\/$/, ""), y = m ? `${m}/${l}` : l, M = u === "public" ? y : l, U = await Oe({
|
|
530
|
+
key: l,
|
|
531
|
+
bucketKind: u,
|
|
532
|
+
host: m
|
|
533
|
+
});
|
|
534
|
+
return g(1), {
|
|
535
|
+
key: l,
|
|
536
|
+
name: l,
|
|
537
|
+
url: M,
|
|
538
|
+
previewUrl: U.url || "",
|
|
539
|
+
expireAt: U.expireAt,
|
|
540
|
+
host: m,
|
|
541
|
+
bucketKind: u,
|
|
542
|
+
raw: p,
|
|
543
|
+
client: a
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
const mn = {
|
|
547
|
+
methods: {
|
|
548
|
+
getDir() {
|
|
549
|
+
return Q(this.foldName || "portal_cms");
|
|
550
|
+
},
|
|
551
|
+
randomString: Ae,
|
|
552
|
+
getOss() {
|
|
553
|
+
return Z({
|
|
554
|
+
dir: this.getDir(),
|
|
555
|
+
bucketKind: this.bucketKind || "private"
|
|
556
|
+
});
|
|
557
|
+
},
|
|
558
|
+
async createOssClient() {
|
|
559
|
+
return xe({
|
|
560
|
+
dir: this.getDir(),
|
|
561
|
+
bucketKind: this.bucketKind || "private",
|
|
562
|
+
getOss: () => this.getOss()
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
async function xt(e, t = {}) {
|
|
568
|
+
var g;
|
|
569
|
+
const n = J(e);
|
|
570
|
+
if (!n)
|
|
571
|
+
return B.warning("无可预览文件"), null;
|
|
572
|
+
const { forceResign: r = !1, ttlSeconds: i, leadMs: s = 12e4 } = t, o = typeof t.resign == "function" ? t.resign : (d) => I({ keys: d, ttlSeconds: i });
|
|
573
|
+
let c = n.fileUrl || "";
|
|
574
|
+
const a = n.fileKey || w(c), f = n.expireAt != null ? Number(n.expireAt) : $(c);
|
|
575
|
+
if ((r || !c || !T(c) || F(f, s)) && a)
|
|
576
|
+
try {
|
|
577
|
+
const d = await o([a]);
|
|
578
|
+
d && Array.isArray(d.items) ? c = ((g = d.items.find((h) => h.key === a)) == null ? void 0 : g.url) || c : d && typeof d == "object" && d[a] && (c = d[a]);
|
|
579
|
+
} catch (d) {
|
|
580
|
+
return B.error((d == null ? void 0 : d.message) || "获取预览地址失败"), null;
|
|
581
|
+
}
|
|
582
|
+
if (!c || !T(c))
|
|
583
|
+
return B.warning("暂无可用预览地址,请稍后重试"), null;
|
|
584
|
+
if (e && typeof e == "object") {
|
|
585
|
+
"previewSrc" in e && (e.previewSrc = c);
|
|
586
|
+
const d = $(c);
|
|
587
|
+
d != null && (e.expireAt = d);
|
|
588
|
+
}
|
|
589
|
+
return { window: we({
|
|
590
|
+
src: c,
|
|
591
|
+
name: n.fileName || ""
|
|
592
|
+
}), src: c, fileName: n.fileName || "" };
|
|
593
|
+
}
|
|
594
|
+
function Ot(e) {
|
|
595
|
+
const t = /* @__PURE__ */ Object.create(null), n = /* @__PURE__ */ Object.create(null), r = typeof e == "function" ? e : (u) => I(u);
|
|
596
|
+
function i(u) {
|
|
597
|
+
const l = w(u) || u;
|
|
598
|
+
!l || !n[l] || (clearTimeout(n[l]), delete n[l]);
|
|
599
|
+
}
|
|
600
|
+
function s() {
|
|
601
|
+
Object.keys(n).forEach((u) => i(u));
|
|
602
|
+
}
|
|
603
|
+
async function o(u = [], l) {
|
|
604
|
+
const g = [...new Set(u.map((p) => w(p)).filter(Boolean))];
|
|
605
|
+
if (!g.length) return { items: [] };
|
|
606
|
+
const d = await r({
|
|
607
|
+
keys: g.slice(0, 50),
|
|
608
|
+
...l != null ? { ttlSeconds: l } : {}
|
|
609
|
+
}), h = d == null ? void 0 : d.expireAt, S = Array.isArray(d == null ? void 0 : d.items) ? d.items : [];
|
|
610
|
+
return S.forEach((p) => {
|
|
611
|
+
if (p != null && p.key && (p != null && p.url)) {
|
|
612
|
+
const b = p.expireAt ?? h;
|
|
613
|
+
t[p.key] = { url: p.url, expireAt: b }, c([p.key], b);
|
|
614
|
+
}
|
|
615
|
+
}), d || { items: S };
|
|
616
|
+
}
|
|
617
|
+
function c(u, l, g = 12e4) {
|
|
618
|
+
if (l == null || Number.isNaN(Number(l))) return null;
|
|
619
|
+
const d = [...new Set((u || []).map((b) => w(b)).filter(Boolean))];
|
|
620
|
+
if (!d.length) return null;
|
|
621
|
+
const S = Number(l) * 1e3 - Date.now();
|
|
622
|
+
let p;
|
|
623
|
+
return S <= 0 ? p = 0 : S <= g ? p = Math.max(S / 2, 1e3) : p = S - g, d.forEach((b) => {
|
|
624
|
+
i(b), n[b] = setTimeout(() => {
|
|
625
|
+
delete n[b], o([b]);
|
|
626
|
+
}, p);
|
|
627
|
+
}), n[d[0]];
|
|
628
|
+
}
|
|
629
|
+
function a(u, l, g) {
|
|
630
|
+
const d = w(u) || u;
|
|
631
|
+
if (!d) return;
|
|
632
|
+
const h = g != null ? Number(g) : $(l);
|
|
633
|
+
t[d] = { url: l, expireAt: h }, h && c([d], h);
|
|
634
|
+
}
|
|
635
|
+
async function f(u, l = {}) {
|
|
636
|
+
var y;
|
|
637
|
+
const g = w(u) || u;
|
|
638
|
+
if (!g) return "";
|
|
639
|
+
const { force: d = !1, leadMs: h = 12e4, ttlSeconds: S } = l, p = t[g], b = l.url || (p == null ? void 0 : p.url) || "", m = l.expireAt != null ? Number(l.expireAt) : (p == null ? void 0 : p.expireAt) ?? $(b);
|
|
640
|
+
return !d && b && T(b) && !F(m, h) ? b : (await o([g], S), ((y = t[g]) == null ? void 0 : y.url) || b || "");
|
|
641
|
+
}
|
|
642
|
+
return {
|
|
643
|
+
cache: t,
|
|
644
|
+
resign: o,
|
|
645
|
+
schedule: c,
|
|
646
|
+
track: a,
|
|
647
|
+
ensure: f,
|
|
648
|
+
clearSchedule: i,
|
|
649
|
+
clearAll: s,
|
|
650
|
+
isExpiringSoon: F
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
function Me(e) {
|
|
654
|
+
const t = String(e || "").trim().toUpperCase();
|
|
655
|
+
if (/^\d{15}$/.test(t)) {
|
|
656
|
+
const f = +`19${t.slice(6, 8)}`, u = Number(t.slice(8, 10)), l = Number(t.slice(10, 12)), g = new Date(f, u - 1, l);
|
|
657
|
+
return g.getFullYear() === f && g.getMonth() + 1 === u && g.getDate() === l;
|
|
658
|
+
}
|
|
659
|
+
if (!/^\d{17}[\dX]$/.test(t)) return !1;
|
|
660
|
+
const n = Number(t.slice(6, 10)), r = Number(t.slice(10, 12)), i = Number(t.slice(12, 14)), s = new Date(n, r - 1, i);
|
|
661
|
+
if (s.getFullYear() !== n || s.getMonth() + 1 !== r || s.getDate() !== i) return !1;
|
|
662
|
+
const o = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2], c = "10X98765432";
|
|
663
|
+
let a = 0;
|
|
664
|
+
for (let f = 0; f < 17; f++) a += Number(t[f]) * o[f];
|
|
665
|
+
return c[a % 11] === t[17];
|
|
666
|
+
}
|
|
667
|
+
function De(e) {
|
|
668
|
+
const t = String(e || "").trim().replace(/\s+/g, "");
|
|
669
|
+
return t ? /^1\d{10}$/.test(t) || /^\+[1-9]\d{6,14}$/.test(t) : !1;
|
|
670
|
+
}
|
|
671
|
+
function $e(e) {
|
|
672
|
+
const t = String(e || "").trim();
|
|
673
|
+
return t ? /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t) : !1;
|
|
674
|
+
}
|
|
675
|
+
function ee(e) {
|
|
676
|
+
return e == null || e === "";
|
|
677
|
+
}
|
|
678
|
+
function Mt(e, t, n) {
|
|
679
|
+
if (ee(t)) {
|
|
680
|
+
n();
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
if (!Me(t)) {
|
|
684
|
+
n(new Error("请输入正确的身份证号(15/18位)"));
|
|
685
|
+
return;
|
|
686
|
+
}
|
|
687
|
+
n();
|
|
688
|
+
}
|
|
689
|
+
function Dt(e, t, n) {
|
|
690
|
+
if (ee(t)) {
|
|
691
|
+
n();
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
if (!De(t)) {
|
|
695
|
+
n(new Error("请输入正确的国内或海外手机号"));
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
698
|
+
n();
|
|
699
|
+
}
|
|
700
|
+
function $t(e, t, n) {
|
|
701
|
+
if (ee(t)) {
|
|
702
|
+
n();
|
|
703
|
+
return;
|
|
704
|
+
}
|
|
705
|
+
if (!$e(t)) {
|
|
706
|
+
n(new Error("请输入正确的邮箱"));
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
n();
|
|
710
|
+
}
|
|
711
|
+
function Kt(e) {
|
|
712
|
+
return !!(e == null || typeof e == "string" && e.trim() === "" || Array.isArray(e) && e.length === 0 || typeof e == "object" && !Array.isArray(e) && Object.keys(e).length === 0);
|
|
713
|
+
}
|
|
714
|
+
function q(e) {
|
|
715
|
+
if (e === null || typeof e != "object") return e;
|
|
716
|
+
if (e instanceof Date) return new Date(e.getTime());
|
|
717
|
+
if (Array.isArray(e)) return e.map((n) => q(n));
|
|
718
|
+
const t = {};
|
|
719
|
+
return Object.keys(e).forEach((n) => {
|
|
720
|
+
t[n] = q(e[n]);
|
|
721
|
+
}), t;
|
|
722
|
+
}
|
|
723
|
+
function Pt(e, t = 300) {
|
|
724
|
+
let n = null;
|
|
725
|
+
return function(...i) {
|
|
726
|
+
n && clearTimeout(n), n = setTimeout(() => {
|
|
727
|
+
e.apply(this, i);
|
|
728
|
+
}, t);
|
|
729
|
+
};
|
|
730
|
+
}
|
|
731
|
+
function It(e, t = 300) {
|
|
732
|
+
let n = 0;
|
|
733
|
+
return function(...i) {
|
|
734
|
+
const s = Date.now();
|
|
735
|
+
s - n >= t && (n = s, e.apply(this, i));
|
|
736
|
+
};
|
|
737
|
+
}
|
|
738
|
+
function Ke(e) {
|
|
739
|
+
if (e == null || e === "") return null;
|
|
740
|
+
if (e instanceof Date)
|
|
741
|
+
return Number.isNaN(e.getTime()) ? null : e;
|
|
742
|
+
if (typeof e == "number") {
|
|
743
|
+
const i = new Date(e);
|
|
744
|
+
return Number.isNaN(i.getTime()) ? null : i;
|
|
745
|
+
}
|
|
746
|
+
const t = String(e).trim();
|
|
747
|
+
if (!t) return null;
|
|
748
|
+
if (/^\d{10,13}$/.test(t)) {
|
|
749
|
+
const i = t.length === 10 ? Number(t) * 1e3 : Number(t), s = new Date(i);
|
|
750
|
+
return Number.isNaN(s.getTime()) ? null : s;
|
|
751
|
+
}
|
|
752
|
+
if (/[Zz]$|[+-]\d{2}:?\d{2}$/.test(t)) {
|
|
753
|
+
const i = new Date(t);
|
|
754
|
+
return Number.isNaN(i.getTime()) ? null : i;
|
|
755
|
+
}
|
|
756
|
+
const n = t.match(
|
|
757
|
+
/^(\d{4})[-/.年](\d{1,2})[-/.月](\d{1,2})日?(?:[\sT]+(\d{1,2}):(\d{1,2})(?::(\d{1,2}))?(?:\.(\d{1,3}))?)?/
|
|
758
|
+
);
|
|
759
|
+
if (n) {
|
|
760
|
+
const [, i, s, o, c = "0", a = "0", f = "0", u = "0"] = n, l = new Date(
|
|
761
|
+
Number(i),
|
|
762
|
+
Number(s) - 1,
|
|
763
|
+
Number(o),
|
|
764
|
+
Number(c),
|
|
765
|
+
Number(a),
|
|
766
|
+
Number(f),
|
|
767
|
+
Number(String(u).padEnd(3, "0"))
|
|
768
|
+
);
|
|
769
|
+
return Number.isNaN(l.getTime()) ? null : l;
|
|
770
|
+
}
|
|
771
|
+
const r = new Date(t);
|
|
772
|
+
return Number.isNaN(r.getTime()) ? null : r;
|
|
773
|
+
}
|
|
774
|
+
function X(e, t = "YYYY-MM-DD HH:mm:ss") {
|
|
775
|
+
const n = Ke(e);
|
|
776
|
+
if (!n) return "";
|
|
777
|
+
const r = n.getFullYear(), i = n.getMonth() + 1, s = n.getDate(), o = n.getHours(), c = n.getMinutes(), a = n.getSeconds(), f = {
|
|
778
|
+
YYYY: String(r),
|
|
779
|
+
MM: String(i).padStart(2, "0"),
|
|
780
|
+
DD: String(s).padStart(2, "0"),
|
|
781
|
+
HH: String(o).padStart(2, "0"),
|
|
782
|
+
mm: String(c).padStart(2, "0"),
|
|
783
|
+
ss: String(a).padStart(2, "0"),
|
|
784
|
+
M: String(i),
|
|
785
|
+
D: String(s),
|
|
786
|
+
H: String(o),
|
|
787
|
+
m: String(c),
|
|
788
|
+
s: String(a)
|
|
789
|
+
};
|
|
790
|
+
return t.replace(/YYYY|MM|DD|HH|mm|ss|M|D|H|m|s/g, (u) => f[u]);
|
|
791
|
+
}
|
|
792
|
+
function Ut() {
|
|
793
|
+
const e = /* @__PURE__ */ new Date();
|
|
794
|
+
e.setHours(23, 59, 59, 0);
|
|
795
|
+
const t = /* @__PURE__ */ new Date();
|
|
796
|
+
return t.setDate(t.getDate() - 30), t.setHours(0, 0, 0, 0), {
|
|
797
|
+
start: X(t, "YYYY-MM-DD HH:mm:ss"),
|
|
798
|
+
end: X(e, "YYYY-MM-DD HH:mm:ss")
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
function A(e) {
|
|
802
|
+
const t = {};
|
|
803
|
+
return Object.keys(e || {}).forEach((n) => {
|
|
804
|
+
const r = e[n];
|
|
805
|
+
r == null || r === "" || Array.isArray(r) && r.length === 0 || (t[n] = r);
|
|
806
|
+
}), t;
|
|
807
|
+
}
|
|
808
|
+
function Ct(e) {
|
|
809
|
+
return e == null || e === "" ? "-" : e;
|
|
810
|
+
}
|
|
811
|
+
function te(e, t = 2) {
|
|
812
|
+
if (!Number.isFinite(e)) return e;
|
|
813
|
+
const n = Math.max(0, Math.floor(Number(t) || 0));
|
|
814
|
+
return +(Math.round(+`${e}e${n}`) + `e-${n}`);
|
|
815
|
+
}
|
|
816
|
+
function W(e, t = 2) {
|
|
817
|
+
if (e == null || e === "") return "-";
|
|
818
|
+
const n = Number(e);
|
|
819
|
+
if (Number.isNaN(n)) return e;
|
|
820
|
+
const r = te(n, t).toFixed(t), [i, s] = r.split("."), o = i.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
821
|
+
if (s == null) return o;
|
|
822
|
+
const c = s.replace(/0+$/, "");
|
|
823
|
+
return c ? `${o}.${c}` : o;
|
|
824
|
+
}
|
|
825
|
+
function jt(e) {
|
|
826
|
+
if (e == null || e === "") return "-";
|
|
827
|
+
const t = Number(e);
|
|
828
|
+
return Number.isNaN(t) ? "-" : Math.abs(t) > 1e4 ? `${W(t / 1e4, 2)}w` : String(W(t, 0));
|
|
829
|
+
}
|
|
830
|
+
function Rt(e, t = 4, n = "toDecimal") {
|
|
831
|
+
if (n === "toPercent" || n === "toPercentText") {
|
|
832
|
+
if (e == null || e === "") return n === "toPercentText" ? "-" : e;
|
|
833
|
+
const i = Number(e);
|
|
834
|
+
if (!Number.isFinite(i) || Number.isNaN(i)) return n === "toPercentText" ? "-" : e;
|
|
835
|
+
if (i === 0) return n === "toPercentText" ? "0%" : 0;
|
|
836
|
+
const s = Number(String(Number((i * 100).toFixed(2))).replace(/(?:\.0*|(\.\d+?)0+)$/, "$1"));
|
|
837
|
+
return n === "toPercentText" ? `${s}%` : s;
|
|
838
|
+
}
|
|
839
|
+
if (e === "" || e == null) return;
|
|
840
|
+
const r = Number(e);
|
|
841
|
+
if (Number.isFinite(r))
|
|
842
|
+
return Number((r / 100).toFixed(t));
|
|
843
|
+
}
|
|
844
|
+
function Ft(e) {
|
|
845
|
+
if (e === "" || e == null) return "";
|
|
846
|
+
const t = Number(e);
|
|
847
|
+
return Number.isFinite(t) ? t : "";
|
|
848
|
+
}
|
|
849
|
+
function Yt(e, t = 2, n = 9999999999999) {
|
|
850
|
+
if (e === 0 || e === "0") return 0;
|
|
851
|
+
if (e == null || e === "") return "";
|
|
852
|
+
let r = Number(e);
|
|
853
|
+
if (!Number.isFinite(r)) return "";
|
|
854
|
+
const i = Number(n), s = Number.isFinite(i) ? Math.abs(i) : 9999999999999;
|
|
855
|
+
return Math.abs(r) >= s && (r = r < 0 ? -s : s), Number.isInteger(r) ? r : te(r, t);
|
|
856
|
+
}
|
|
857
|
+
function Bt(e = "id") {
|
|
858
|
+
return `${e}_${Date.now()}_${Math.random().toString(36).slice(2, 9)}`;
|
|
859
|
+
}
|
|
860
|
+
const pn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
861
|
+
__proto__: null,
|
|
862
|
+
FILE_PREVIEW_ROUTE_PATH: be,
|
|
863
|
+
batchSign: I,
|
|
864
|
+
batchSignOss: Et,
|
|
865
|
+
buildFilePreviewHref: he,
|
|
866
|
+
cleanNumber: Yt,
|
|
867
|
+
cleanParams: A,
|
|
868
|
+
clearPlatformCache: ct,
|
|
869
|
+
createOssResign: Ot,
|
|
870
|
+
debounce: Pt,
|
|
871
|
+
deepClone: q,
|
|
872
|
+
downloadBlob: me,
|
|
873
|
+
exportFile: st,
|
|
874
|
+
extractObjectKey: w,
|
|
875
|
+
findPlatformLogo: ut,
|
|
876
|
+
formatDate: X,
|
|
877
|
+
formatEmpty: Ct,
|
|
878
|
+
formatFansCount: jt,
|
|
879
|
+
formatNum: W,
|
|
880
|
+
getFileExtension: k,
|
|
881
|
+
getOssSts: Z,
|
|
882
|
+
getRecentMonthRange: Ut,
|
|
883
|
+
getUploadSign: wt,
|
|
884
|
+
isEmail: $e,
|
|
885
|
+
isEmpty: Kt,
|
|
886
|
+
isExpiringSoon: F,
|
|
887
|
+
isHttpUrl: T,
|
|
888
|
+
isMainlandIdCard: Me,
|
|
889
|
+
isMobile: De,
|
|
890
|
+
isSignedUrl: Te,
|
|
891
|
+
normalizeAttachFile: J,
|
|
892
|
+
openFilePreview: we,
|
|
893
|
+
openOssFile: xt,
|
|
894
|
+
parseDate: Ke,
|
|
895
|
+
parseExpireAtFromUrl: $,
|
|
896
|
+
preloadPlatformList: lt,
|
|
897
|
+
resolveFilePreviewType: ge,
|
|
898
|
+
resolveUploadPreviewUrl: Oe,
|
|
899
|
+
resolveVideoMimeType: ye,
|
|
900
|
+
resolveVideoSources: Se,
|
|
901
|
+
roundHalfUp: te,
|
|
902
|
+
setPlatformCache: pe,
|
|
903
|
+
throttle: It,
|
|
904
|
+
toNumberOrEmpty: Ft,
|
|
905
|
+
toOssSaveFile: ve,
|
|
906
|
+
toOssSaveFiles: bt,
|
|
907
|
+
toOssSaveUrl: V,
|
|
908
|
+
toRebateRatio: Rt,
|
|
909
|
+
uniqueId: Bt,
|
|
910
|
+
uploadToOss: kt,
|
|
911
|
+
validateEmail: $t,
|
|
912
|
+
validateIdCardNo: Mt,
|
|
913
|
+
validateMobile: Dt
|
|
914
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
915
|
+
function gn(e) {
|
|
916
|
+
if (!e)
|
|
917
|
+
throw new Error("[mgacn-commonsdk] createApi 需要传入 request 实例");
|
|
918
|
+
return {
|
|
919
|
+
// ---------- 注销登录 ----------
|
|
920
|
+
logout(t) {
|
|
921
|
+
return e.GET(`/yhAdmin/login/exit/${t}`);
|
|
922
|
+
},
|
|
923
|
+
// ---------- 用户 ----------
|
|
924
|
+
getUserInfo(t) {
|
|
925
|
+
return e.GET(`/yhAdmin/user/queryUser/${t}`);
|
|
926
|
+
},
|
|
927
|
+
/**
|
|
928
|
+
* 用户下拉选择列表
|
|
929
|
+
* POST /yhAdmin/user/listForSelect
|
|
930
|
+
* @param {object} [params]
|
|
931
|
+
* @param {0|1} [params.status] 0 正常/有效,1 禁用/锁定;不传查全部
|
|
932
|
+
* @param {0|1} [params.isDelete] 0 否,1 是;不传默认查未删除
|
|
933
|
+
* @param {string} [params.realName] 真实姓名,模糊
|
|
934
|
+
* @param {string} [params.username] 登录账号/工号,模糊
|
|
935
|
+
* @param {string} [params.mobile] 手机号,模糊
|
|
936
|
+
* @param {string} [params.openId] 第三方 openId,模糊
|
|
937
|
+
* @param {string} [params.createTimeStart]
|
|
938
|
+
* @param {string} [params.createTimeEnd]
|
|
939
|
+
* @param {string} [params.updateTimeStart]
|
|
940
|
+
* @param {string} [params.updateTimeEnd]
|
|
941
|
+
* @returns {Promise<Array>} 用户列表(兼容 result / list / 直接数组)
|
|
942
|
+
*/
|
|
943
|
+
async listUserForSelect(t = {}) {
|
|
944
|
+
const n = await e.POST("/yhAdmin/user/listForSelect", A(t));
|
|
945
|
+
return Array.isArray(n) ? n : Array.isArray(n == null ? void 0 : n.result) ? n.result : Array.isArray(n == null ? void 0 : n.list) ? n.list : [];
|
|
946
|
+
},
|
|
947
|
+
/**
|
|
948
|
+
* 按角色名称查询用户列表(下拉)
|
|
949
|
+
* POST /yhAdmin/user/queryUserByRoleName
|
|
950
|
+
* systemId 由组件库自动填充,宿主勿传
|
|
951
|
+
* @param {object} params
|
|
952
|
+
* @param {string} params.roleName 角色名称
|
|
953
|
+
*/
|
|
954
|
+
async queryByRoleName(t = {}) {
|
|
955
|
+
const { systemId: n, ...r } = t && typeof t == "object" ? t : {}, i = await e.POST(
|
|
956
|
+
"/yhAdmin/user/queryUserByRoleName",
|
|
957
|
+
A({
|
|
958
|
+
...r,
|
|
959
|
+
systemId: z()
|
|
960
|
+
})
|
|
961
|
+
);
|
|
962
|
+
return Array.isArray(i) ? i : Array.isArray(i == null ? void 0 : i.result) ? i.result : Array.isArray(i == null ? void 0 : i.list) ? i.list : [];
|
|
963
|
+
},
|
|
964
|
+
/**
|
|
965
|
+
* 查询部门树
|
|
966
|
+
* POST /yhAdmin/dept/queryDeptTree
|
|
967
|
+
* @param {object} [params]
|
|
968
|
+
* @param {string} [params.deptName] 部门名称
|
|
969
|
+
* @param {string[]} [params.deptIds] 部门 IDS
|
|
970
|
+
* @param {boolean} [params.queryUser] 是否查询用户
|
|
971
|
+
* @returns {Promise<Array>} 部门树(兼容 result / list / 直接数组)
|
|
972
|
+
*/
|
|
973
|
+
async queryDeptTree(t = {}) {
|
|
974
|
+
const n = await e.POST("/yhAdmin/dept/queryDeptTree", A(t));
|
|
975
|
+
return Array.isArray(n) ? n : [];
|
|
976
|
+
},
|
|
977
|
+
/**
|
|
978
|
+
* 飞书关联审批分页(待办 / 已办 / 抄送我 / 已发起)
|
|
979
|
+
* POST /yhShared/feishuApproval/pageRelated
|
|
980
|
+
* @param {object} params
|
|
981
|
+
* @param {'todo'|'done'|'cc'|'initiated'} params.tab
|
|
982
|
+
* @param {string} params.unionId 飞书 union_id
|
|
983
|
+
* @param {string} [params.approvalCode] 审批定义 Code,空表示全部
|
|
984
|
+
* @param {string} [params.status] PENDING / APPROVED / REJECTED / CANCELED,空表示全部
|
|
985
|
+
* @param {string} [params.keyword] 审批名称、实例 Code
|
|
986
|
+
* @param {number} [params.page] 页码,从 0 开始
|
|
987
|
+
* @param {number} [params.limit] 每页条数
|
|
988
|
+
* @returns {Promise<{result: Array, totalCount: number, pageCount: number}>}
|
|
989
|
+
*/
|
|
990
|
+
pageRelated(t = {}) {
|
|
991
|
+
return e.POST("/yhShared/feishuApproval/pageRelated", A(t));
|
|
992
|
+
},
|
|
993
|
+
/**
|
|
994
|
+
* 关联审批的审批类型
|
|
995
|
+
* GET /yhShared/feishuApproval/definitions
|
|
996
|
+
* @returns {Promise<Array<{approvalCode: string, approvalName: string}>>}
|
|
997
|
+
*/
|
|
998
|
+
async listApprovalDefinitions() {
|
|
999
|
+
const t = await e.GET("/yhShared/feishuApproval/definitions");
|
|
1000
|
+
return Array.isArray(t) ? t : Array.isArray(t == null ? void 0 : t.result) ? t.result : Array.isArray(t == null ? void 0 : t.list) ? t.list : [];
|
|
1001
|
+
},
|
|
1002
|
+
/**
|
|
1003
|
+
* 媒介供应商全量列表(下拉)
|
|
1004
|
+
* GET /yhAccount/mediaSupplier/listAll
|
|
1005
|
+
*/
|
|
1006
|
+
listMediaSupplierAll() {
|
|
1007
|
+
return e.GET("/yhAccount/mediaSupplier/listAll");
|
|
1008
|
+
},
|
|
1009
|
+
/**
|
|
1010
|
+
* 账号库平台配置全量列表(下拉)
|
|
1011
|
+
* GET /yhAccount/platformInfo/listAll
|
|
1012
|
+
*/
|
|
1013
|
+
listPlatformInfoAll() {
|
|
1014
|
+
return e.GET("/yhAccount/platformInfo/listAll");
|
|
1015
|
+
},
|
|
1016
|
+
/**
|
|
1017
|
+
* 标签配置全量列表
|
|
1018
|
+
* GET /yhShared/tagConfig/queryAllTagConfigs
|
|
1019
|
+
* @param {object} [params]
|
|
1020
|
+
* @param {string} [params.businessKey]
|
|
1021
|
+
*/
|
|
1022
|
+
queryAllTagConfigs(t = {}) {
|
|
1023
|
+
return e.GET("/yhShared/tagConfig/queryAllTagConfigs", {
|
|
1024
|
+
params: A(t)
|
|
1025
|
+
});
|
|
1026
|
+
},
|
|
1027
|
+
/**
|
|
1028
|
+
* 写入埋点数据
|
|
1029
|
+
* POST /yhAdmin/trace/addTraceData
|
|
1030
|
+
* userId / projectId(系统 id) / clientType 由组件库自动填充,宿主勿传
|
|
1031
|
+
* @param {object} params 宿主业务参数
|
|
1032
|
+
* @param {string} params.traceId 事件 ID
|
|
1033
|
+
* @param {string} [params.route] 页面路由
|
|
1034
|
+
* @param {string} [params.wxUserId] 微信用户 ID
|
|
1035
|
+
*/
|
|
1036
|
+
addTraceData(t = {}) {
|
|
1037
|
+
const { userId: n, projectId: r, clientType: i, ...s } = t && typeof t == "object" ? t : {};
|
|
1038
|
+
return e.POST(
|
|
1039
|
+
"/yhAdmin/trace/addTraceData",
|
|
1040
|
+
A({
|
|
1041
|
+
...s,
|
|
1042
|
+
userId: et(),
|
|
1043
|
+
projectId: z(),
|
|
1044
|
+
clientType: 1
|
|
1045
|
+
})
|
|
1046
|
+
);
|
|
1047
|
+
},
|
|
1048
|
+
// ---------- OSS(契约对齐 OSS 私有化 §15)----------
|
|
1049
|
+
/**
|
|
1050
|
+
* STS 直传凭证
|
|
1051
|
+
* @param {string|{ dir: string, bucketKind?: 'private'|'public', fileTypes?: string[] }} param
|
|
1052
|
+
*/
|
|
1053
|
+
getOssSts(t) {
|
|
1054
|
+
const n = A(t && typeof t == "object" ? {
|
|
1055
|
+
dir: t.dir,
|
|
1056
|
+
bucketKind: t.bucketKind,
|
|
1057
|
+
fileTypes: t.fileTypes
|
|
1058
|
+
} : { dir: t });
|
|
1059
|
+
return n.bucketKind || Array.isArray(n.fileTypes) ? e.POST("/yhAdmin/oss/getStsToken", n) : e.GET("/yhAdmin/oss/getStsToken", { params: n });
|
|
1060
|
+
},
|
|
1061
|
+
/**
|
|
1062
|
+
* PostObject 上传签名;响应直接是 OssSignModel 对象(勿 JSON.parse)
|
|
1063
|
+
* @param {{ dir: string, bucketKind?: 'private'|'public', fileTypes?: string[] }} param
|
|
1064
|
+
*/
|
|
1065
|
+
getUploadSign(t = {}) {
|
|
1066
|
+
return e.POST(
|
|
1067
|
+
"/yhAdmin/oss/getUploadSign",
|
|
1068
|
+
A({
|
|
1069
|
+
dir: t.dir,
|
|
1070
|
+
bucketKind: t.bucketKind,
|
|
1071
|
+
fileTypes: t.fileTypes
|
|
1072
|
+
})
|
|
1073
|
+
);
|
|
1074
|
+
},
|
|
1075
|
+
/**
|
|
1076
|
+
* 全业务统一批量续签(yh-admin)
|
|
1077
|
+
* POST /yhAdmin/oss/batchSign
|
|
1078
|
+
* @param {{ keys: string[], ttlSeconds?: number }} param
|
|
1079
|
+
*/
|
|
1080
|
+
batchSign(t = {}) {
|
|
1081
|
+
return e.POST(
|
|
1082
|
+
"/yhAdmin/oss/batchSign",
|
|
1083
|
+
A({
|
|
1084
|
+
keys: t.keys,
|
|
1085
|
+
ttlSeconds: t.ttlSeconds
|
|
1086
|
+
})
|
|
1087
|
+
);
|
|
1088
|
+
},
|
|
1089
|
+
/** @deprecated 使用 batchSign;保留别名兼容旧调用 */
|
|
1090
|
+
batchSignOss(t = {}) {
|
|
1091
|
+
return this.batchSign(t);
|
|
1092
|
+
}
|
|
1093
|
+
};
|
|
1094
|
+
}
|
|
1095
|
+
const Pe = "__MGACN_COMMONSDK_API__";
|
|
1096
|
+
function yn(e) {
|
|
1097
|
+
globalThis[Pe] = e;
|
|
1098
|
+
}
|
|
1099
|
+
function Y() {
|
|
1100
|
+
const e = globalThis[Pe];
|
|
1101
|
+
if (!e)
|
|
1102
|
+
throw new Error("[mgacn-commonsdk] 请先 app.use(MgacnCommonSdk, { tokenKey, baseURL })");
|
|
1103
|
+
return e;
|
|
1104
|
+
}
|
|
1105
|
+
const Ie = "__MGACN_COMMONSDK_PERMISSION_GETTER__";
|
|
1106
|
+
function Sn(e) {
|
|
1107
|
+
globalThis[Ie] = typeof e == "function" ? e : null;
|
|
1108
|
+
}
|
|
1109
|
+
function Lt() {
|
|
1110
|
+
return globalThis[Ie] || null;
|
|
1111
|
+
}
|
|
1112
|
+
function Gt(e, t, n = "and") {
|
|
1113
|
+
const r = (Array.isArray(t) ? t : [t]).map((s) => String(s ?? "").trim()).filter(Boolean);
|
|
1114
|
+
if (!r.length) return !0;
|
|
1115
|
+
const i = new Set((e || []).map(String));
|
|
1116
|
+
return n === "or" ? r.some((s) => i.has(s)) : r.every((s) => i.has(s));
|
|
1117
|
+
}
|
|
1118
|
+
function bn(e, t = "and") {
|
|
1119
|
+
const n = Lt();
|
|
1120
|
+
return typeof n != "function" ? !0 : Gt(n(), e, t);
|
|
1121
|
+
}
|
|
1122
|
+
const Ht = (e, t) => {
|
|
1123
|
+
const n = e.__vccOpts || e;
|
|
1124
|
+
for (const [r, i] of t)
|
|
1125
|
+
n[r] = i;
|
|
1126
|
+
return n;
|
|
1127
|
+
}, zt = {
|
|
1128
|
+
key: 0,
|
|
1129
|
+
class: "mg-file-preview__empty"
|
|
1130
|
+
}, Vt = {
|
|
1131
|
+
key: 1,
|
|
1132
|
+
class: "mg-file-preview__fallback"
|
|
1133
|
+
}, qt = {
|
|
1134
|
+
key: 0,
|
|
1135
|
+
class: "mg-file-preview__fallback-name"
|
|
1136
|
+
}, Xt = {
|
|
1137
|
+
key: 2,
|
|
1138
|
+
class: "mg-file-preview__image"
|
|
1139
|
+
}, Wt = {
|
|
1140
|
+
key: 3,
|
|
1141
|
+
class: "mg-file-preview__video-wrap"
|
|
1142
|
+
}, Qt = {
|
|
1143
|
+
key: 0,
|
|
1144
|
+
class: "mg-file-preview__tip"
|
|
1145
|
+
}, Jt = { class: "mg-file-preview__video" }, Zt = {
|
|
1146
|
+
key: 4,
|
|
1147
|
+
class: "mg-file-preview__pdf"
|
|
1148
|
+
}, en = {
|
|
1149
|
+
key: 5,
|
|
1150
|
+
class: "mg-file-preview__word"
|
|
1151
|
+
}, tn = /* @__PURE__ */ Object.assign({ name: "MgFilePreview" }, {
|
|
1152
|
+
__name: "FilePreview",
|
|
1153
|
+
props: {
|
|
1154
|
+
/** 文件地址(URL / Blob URL) */
|
|
1155
|
+
src: {
|
|
1156
|
+
type: String,
|
|
1157
|
+
default: ""
|
|
1158
|
+
},
|
|
1159
|
+
/** 文件名(用于识别类型;可不带路径) */
|
|
1160
|
+
name: {
|
|
1161
|
+
type: String,
|
|
1162
|
+
default: ""
|
|
1163
|
+
},
|
|
1164
|
+
/**
|
|
1165
|
+
* 强制指定类型:image | video | pdf | word | excel | unsupported
|
|
1166
|
+
* 不传则根据 name / src 扩展名推断
|
|
1167
|
+
*/
|
|
1168
|
+
fileType: {
|
|
1169
|
+
type: String,
|
|
1170
|
+
default: ""
|
|
1171
|
+
},
|
|
1172
|
+
/** 预览区高度,如 70vh / 600 */
|
|
1173
|
+
height: {
|
|
1174
|
+
type: [String, Number],
|
|
1175
|
+
default: "70vh"
|
|
1176
|
+
}
|
|
1177
|
+
},
|
|
1178
|
+
emits: ["ready", "error", "download"],
|
|
1179
|
+
setup(e, { emit: t }) {
|
|
1180
|
+
const n = e, r = t, i = ie(null), s = ie(!1);
|
|
1181
|
+
let o = null;
|
|
1182
|
+
const c = j(
|
|
1183
|
+
() => ge({
|
|
1184
|
+
src: n.src,
|
|
1185
|
+
name: n.name,
|
|
1186
|
+
fileType: n.fileType
|
|
1187
|
+
})
|
|
1188
|
+
), a = j(() => {
|
|
1189
|
+
const m = String(n.name || "").trim();
|
|
1190
|
+
if (m) return m;
|
|
1191
|
+
const y = String(n.src || "").trim();
|
|
1192
|
+
if (!y) return "";
|
|
1193
|
+
const M = y.split("?")[0].split("#")[0];
|
|
1194
|
+
return M.slice(M.lastIndexOf("/") + 1) || y;
|
|
1195
|
+
}), f = j(() => c.value !== "video" ? !1 : (k(n.name) || k(n.src)) === "mov"), u = j(() => {
|
|
1196
|
+
const m = n.height;
|
|
1197
|
+
return m == null || m === "" ? {} : { height: typeof m == "number" ? `${m}px` : String(m) };
|
|
1198
|
+
});
|
|
1199
|
+
function l() {
|
|
1200
|
+
if (o) {
|
|
1201
|
+
try {
|
|
1202
|
+
o.dispose();
|
|
1203
|
+
} catch {
|
|
1204
|
+
}
|
|
1205
|
+
o = null;
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
async function g() {
|
|
1209
|
+
l(), !(c.value !== "video" || !n.src) && (await Ve(), i.value && (o = Xe(i.value, {
|
|
1210
|
+
controls: !0,
|
|
1211
|
+
fill: !0,
|
|
1212
|
+
fluid: !1,
|
|
1213
|
+
preload: "metadata",
|
|
1214
|
+
sources: Se(n.src, n.name)
|
|
1215
|
+
}), o.ready(() => r("ready", { type: "video" })), o.on("error", () => r("error", { type: "video", message: "视频加载失败" }))));
|
|
1216
|
+
}
|
|
1217
|
+
function d() {
|
|
1218
|
+
s.value = !1, r("ready", { type: "pdf" });
|
|
1219
|
+
}
|
|
1220
|
+
function h(m) {
|
|
1221
|
+
s.value = !1, r("error", { type: "pdf", message: (m == null ? void 0 : m.message) || "PDF 加载失败", error: m });
|
|
1222
|
+
}
|
|
1223
|
+
function S() {
|
|
1224
|
+
r("ready", { type: c.value });
|
|
1225
|
+
}
|
|
1226
|
+
function p(m) {
|
|
1227
|
+
r("error", {
|
|
1228
|
+
type: c.value,
|
|
1229
|
+
message: (m == null ? void 0 : m.message) || "文档预览失败",
|
|
1230
|
+
error: m
|
|
1231
|
+
});
|
|
1232
|
+
}
|
|
1233
|
+
function b() {
|
|
1234
|
+
if (r("download", { src: n.src, name: a.value }), !n.src || typeof window > "u") return;
|
|
1235
|
+
const m = document.createElement("a");
|
|
1236
|
+
m.href = n.src, m.download = a.value || `file.${k(n.name || n.src) || "bin"}`, m.target = "_blank", m.rel = "noopener noreferrer", document.body.appendChild(m), m.click(), document.body.removeChild(m);
|
|
1237
|
+
}
|
|
1238
|
+
return je(
|
|
1239
|
+
() => [n.src, c.value],
|
|
1240
|
+
([m, y]) => {
|
|
1241
|
+
y === "pdf" && m ? s.value = !0 : s.value = !1, y === "video" && m ? g() : l(), y === "image" && m && r("ready", { type: "image" });
|
|
1242
|
+
},
|
|
1243
|
+
{ immediate: !0 }
|
|
1244
|
+
), Re(() => {
|
|
1245
|
+
l();
|
|
1246
|
+
}), (m, y) => {
|
|
1247
|
+
const M = se("el-button"), U = se("el-image"), C = Fe("loading");
|
|
1248
|
+
return N(), v("div", {
|
|
1249
|
+
class: Be(["mg-file-preview", [`is-${c.value}`]]),
|
|
1250
|
+
style: Ye(u.value)
|
|
1251
|
+
}, [
|
|
1252
|
+
e.src ? c.value === "unsupported" ? (N(), v("div", Vt, [
|
|
1253
|
+
y[1] || (y[1] = E("p", { class: "mg-file-preview__fallback-title" }, "暂不支持在线预览该格式", -1)),
|
|
1254
|
+
a.value ? (N(), v("p", qt, Le(a.value), 1)) : L("", !0),
|
|
1255
|
+
R(M, {
|
|
1256
|
+
type: "primary",
|
|
1257
|
+
onClick: b
|
|
1258
|
+
}, {
|
|
1259
|
+
default: oe(() => [...y[0] || (y[0] = [
|
|
1260
|
+
Ge("下载文件", -1)
|
|
1261
|
+
])]),
|
|
1262
|
+
_: 1
|
|
1263
|
+
})
|
|
1264
|
+
])) : c.value === "image" ? (N(), v("div", Xt, [
|
|
1265
|
+
R(U, {
|
|
1266
|
+
src: e.src,
|
|
1267
|
+
fit: "contain",
|
|
1268
|
+
"preview-src-list": [e.src],
|
|
1269
|
+
"preview-teleported": "",
|
|
1270
|
+
"hide-on-click-modal": ""
|
|
1271
|
+
}, {
|
|
1272
|
+
error: oe(() => [...y[2] || (y[2] = [
|
|
1273
|
+
E("div", { class: "mg-file-preview__empty" }, "图片加载失败", -1)
|
|
1274
|
+
])]),
|
|
1275
|
+
_: 1
|
|
1276
|
+
}, 8, ["src", "preview-src-list"])
|
|
1277
|
+
])) : c.value === "video" ? (N(), v("div", Wt, [
|
|
1278
|
+
f.value ? (N(), v("div", Qt, [
|
|
1279
|
+
y[3] || (y[3] = E("span", null, " .mov 受浏览器解码能力限制(如 HEVC),若无法播放请 ", -1)),
|
|
1280
|
+
E("button", {
|
|
1281
|
+
type: "button",
|
|
1282
|
+
class: "mg-file-preview__tip-link",
|
|
1283
|
+
onClick: b
|
|
1284
|
+
}, "下载原文件"),
|
|
1285
|
+
y[4] || (y[4] = E("span", null, "查看。", -1))
|
|
1286
|
+
])) : L("", !0),
|
|
1287
|
+
E("div", Jt, [
|
|
1288
|
+
(N(), v("video", {
|
|
1289
|
+
key: e.src,
|
|
1290
|
+
ref_key: "videoEl",
|
|
1291
|
+
ref: i,
|
|
1292
|
+
class: "video-js vjs-big-play-centered mg-file-preview__video-el",
|
|
1293
|
+
playsinline: ""
|
|
1294
|
+
}))
|
|
1295
|
+
])
|
|
1296
|
+
])) : c.value === "pdf" ? He((N(), v("div", Zt, [
|
|
1297
|
+
R(G(qe), {
|
|
1298
|
+
source: e.src,
|
|
1299
|
+
class: "mg-file-preview__pdf-embed",
|
|
1300
|
+
onLoaded: d,
|
|
1301
|
+
onLoadingFailed: h
|
|
1302
|
+
}, null, 8, ["source"])
|
|
1303
|
+
])), [
|
|
1304
|
+
[C, s.value]
|
|
1305
|
+
]) : c.value === "word" ? (N(), v("div", en, [
|
|
1306
|
+
E("div", { class: "mg-file-preview__tip" }, [
|
|
1307
|
+
y[5] || (y[5] = E("span", null, " Word 在线预览对复杂排版(文本框、形状、绝对定位等)支持有限,可能出现内容缺失;如预览不完整请 ", -1)),
|
|
1308
|
+
E("button", {
|
|
1309
|
+
type: "button",
|
|
1310
|
+
class: "mg-file-preview__tip-link",
|
|
1311
|
+
onClick: b
|
|
1312
|
+
}, "下载原文件"),
|
|
1313
|
+
y[6] || (y[6] = E("span", null, "查看。", -1))
|
|
1314
|
+
]),
|
|
1315
|
+
R(G(We), {
|
|
1316
|
+
src: e.src,
|
|
1317
|
+
class: "mg-file-preview__office",
|
|
1318
|
+
onRendered: S,
|
|
1319
|
+
onError: p
|
|
1320
|
+
}, null, 8, ["src"])
|
|
1321
|
+
])) : c.value === "excel" ? (N(), ze(G(Qe), {
|
|
1322
|
+
key: 6,
|
|
1323
|
+
src: e.src,
|
|
1324
|
+
class: "mg-file-preview__office",
|
|
1325
|
+
onRendered: S,
|
|
1326
|
+
onError: p
|
|
1327
|
+
}, null, 8, ["src"])) : L("", !0) : (N(), v("div", zt, "暂无预览文件"))
|
|
1328
|
+
], 6);
|
|
1329
|
+
};
|
|
1330
|
+
}
|
|
1331
|
+
}), hn = /* @__PURE__ */ Ht(tn, [["__scopeId", "data-v-2dc0862c"]]);
|
|
1332
|
+
export {
|
|
1333
|
+
Ct as A,
|
|
1334
|
+
bn as B,
|
|
1335
|
+
dn as C,
|
|
1336
|
+
Sn as D,
|
|
1337
|
+
an as E,
|
|
1338
|
+
hn as F,
|
|
1339
|
+
gn as G,
|
|
1340
|
+
fn as H,
|
|
1341
|
+
yn as I,
|
|
1342
|
+
Et as J,
|
|
1343
|
+
xe as K,
|
|
1344
|
+
Ot as L,
|
|
1345
|
+
tt as M,
|
|
1346
|
+
Z as N,
|
|
1347
|
+
Lt as O,
|
|
1348
|
+
z as P,
|
|
1349
|
+
wt as Q,
|
|
1350
|
+
et as R,
|
|
1351
|
+
J as S,
|
|
1352
|
+
Oe as T,
|
|
1353
|
+
pn as U,
|
|
1354
|
+
Ht as _,
|
|
1355
|
+
Je as a,
|
|
1356
|
+
nt as b,
|
|
1357
|
+
Gt as c,
|
|
1358
|
+
k as d,
|
|
1359
|
+
q as e,
|
|
1360
|
+
A as f,
|
|
1361
|
+
Y as g,
|
|
1362
|
+
Pt as h,
|
|
1363
|
+
be as i,
|
|
1364
|
+
he as j,
|
|
1365
|
+
mn as k,
|
|
1366
|
+
T as l,
|
|
1367
|
+
w as m,
|
|
1368
|
+
I as n,
|
|
1369
|
+
we as o,
|
|
1370
|
+
Te as p,
|
|
1371
|
+
xt as q,
|
|
1372
|
+
$ as r,
|
|
1373
|
+
Ze as s,
|
|
1374
|
+
V as t,
|
|
1375
|
+
kt as u,
|
|
1376
|
+
ve as v,
|
|
1377
|
+
bt as w,
|
|
1378
|
+
F as x,
|
|
1379
|
+
W as y,
|
|
1380
|
+
Rt as z
|
|
1381
|
+
};
|