nhanh-pure-function 2.0.2 → 2.0.4
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/Constant.d.ts +4 -1
- package/dist/User/index.d.ts +16 -0
- package/dist/Utility/index.d.ts +54 -10
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +33 -0
- package/dist/index.es.js +587 -357
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".nhanh-pure-function{--nhanh: 2233}.no-select{-webkit-user-select:none;-ms-user-select:none;user-select:none}")),document.head.appendChild(e)}}catch(n){console.error("vite-plugin-css-injected-by-js",n)}})();
|
|
2
|
-
var
|
|
3
|
-
var
|
|
2
|
+
var K = Object.defineProperty;
|
|
3
|
+
var H = (n) => {
|
|
4
4
|
throw TypeError(n);
|
|
5
5
|
};
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var s = (n,
|
|
9
|
-
const
|
|
6
|
+
var ee = (n, t, e) => t in n ? K(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
7
|
+
var y = (n, t, e) => ee(n, typeof t != "symbol" ? t + "" : t, e), X = (n, t, e) => t.has(n) || H("Cannot " + e);
|
|
8
|
+
var s = (n, t, e) => (X(n, t, "read from private field"), e ? e.call(n) : t.get(n)), d = (n, t, e) => t.has(n) ? H("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, e), l = (n, t, e, o) => (X(n, t, "write to private field"), o ? o.call(n, e) : t.set(n, e), e);
|
|
9
|
+
const te = {
|
|
10
10
|
/* 常见扩展名映射 */
|
|
11
11
|
".mp3": "audio/mpeg",
|
|
12
12
|
".mp4": "video/mp4",
|
|
@@ -70,7 +70,7 @@ const V = {
|
|
|
70
70
|
".eot": "application/vnd.ms-fontobject",
|
|
71
71
|
".map": "application/json"
|
|
72
72
|
// 可根据需要继续扩展
|
|
73
|
-
},
|
|
73
|
+
}, $ = {
|
|
74
74
|
image: [
|
|
75
75
|
".jpg",
|
|
76
76
|
".jpeg",
|
|
@@ -250,7 +250,7 @@ const V = {
|
|
|
250
250
|
".awk",
|
|
251
251
|
".php"
|
|
252
252
|
]
|
|
253
|
-
},
|
|
253
|
+
}, W = [
|
|
254
254
|
"",
|
|
255
255
|
"万",
|
|
256
256
|
"亿",
|
|
@@ -265,177 +265,171 @@ const V = {
|
|
|
265
265
|
"载",
|
|
266
266
|
"极"
|
|
267
267
|
];
|
|
268
|
-
function
|
|
268
|
+
function le(n) {
|
|
269
269
|
return n != null;
|
|
270
270
|
}
|
|
271
|
-
function
|
|
271
|
+
function ue(n) {
|
|
272
272
|
return !(n === null || typeof n != "object" || Array.isArray(n));
|
|
273
273
|
}
|
|
274
|
-
function
|
|
274
|
+
function me(n) {
|
|
275
275
|
if (typeof n != "function")
|
|
276
276
|
return console.error("非函数:", n);
|
|
277
|
-
const
|
|
278
|
-
|
|
277
|
+
const t = function(e) {
|
|
278
|
+
e.didTimeout || e.timeRemaining() <= 0 ? requestIdleCallback(t) : n();
|
|
279
279
|
};
|
|
280
|
-
requestIdleCallback(
|
|
280
|
+
requestIdleCallback(t);
|
|
281
281
|
}
|
|
282
|
-
function
|
|
283
|
-
const
|
|
284
|
-
return new Promise((o,
|
|
285
|
-
const
|
|
286
|
-
if (+/* @__PURE__ */ new Date() -
|
|
282
|
+
function de(n, t) {
|
|
283
|
+
const e = +/* @__PURE__ */ new Date();
|
|
284
|
+
return new Promise((o, r) => {
|
|
285
|
+
const i = () => {
|
|
286
|
+
if (+/* @__PURE__ */ new Date() - e >= t) return r("超时");
|
|
287
287
|
if (n()) return o("完成");
|
|
288
|
-
requestIdleCallback(
|
|
288
|
+
requestIdleCallback(i);
|
|
289
289
|
};
|
|
290
|
-
|
|
290
|
+
i();
|
|
291
291
|
});
|
|
292
292
|
}
|
|
293
|
-
function
|
|
293
|
+
function fe(n, t, e = ",") {
|
|
294
294
|
const o = new RegExp(
|
|
295
|
-
`(^|${
|
|
295
|
+
`(^|${e})${t}(${e}|$)`,
|
|
296
296
|
"g"
|
|
297
297
|
);
|
|
298
|
-
return n.replace(o, function(
|
|
299
|
-
return
|
|
298
|
+
return n.replace(o, function(r, i, c) {
|
|
299
|
+
return i === c ? e : "";
|
|
300
300
|
});
|
|
301
301
|
}
|
|
302
|
-
function
|
|
302
|
+
function he(n) {
|
|
303
303
|
return n.charAt(0).toUpperCase() + n.slice(1);
|
|
304
304
|
}
|
|
305
|
-
function
|
|
306
|
-
if (o < +/* @__PURE__ */ new Date() -
|
|
305
|
+
function Y(n, t, e = [], o = +/* @__PURE__ */ new Date()) {
|
|
306
|
+
if (o < +/* @__PURE__ */ new Date() - 50) {
|
|
307
307
|
console.error("_MergeObjects 合并异常:疑似死循环");
|
|
308
308
|
return;
|
|
309
309
|
}
|
|
310
|
-
const
|
|
311
|
-
if (r !=
|
|
310
|
+
const r = G(n), i = G(t);
|
|
311
|
+
if (r != i) return t;
|
|
312
312
|
if (r == "object" || r == "array") {
|
|
313
|
-
if (
|
|
314
|
-
if (
|
|
315
|
-
for (const
|
|
316
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
317
|
-
const
|
|
318
|
-
n[
|
|
313
|
+
if (e.some(([c, a]) => c == n && a == t)) return n;
|
|
314
|
+
if (e.push([n, t]), r == "object") {
|
|
315
|
+
for (const c in t)
|
|
316
|
+
if (Object.prototype.hasOwnProperty.call(t, c)) {
|
|
317
|
+
const a = t[c], m = n[c], u = Y(m, a, e, o);
|
|
318
|
+
n[c] = u;
|
|
319
319
|
}
|
|
320
320
|
return n;
|
|
321
321
|
} else if (r == "array")
|
|
322
|
-
return
|
|
323
|
-
const
|
|
324
|
-
n[
|
|
322
|
+
return t.forEach((c, a) => {
|
|
323
|
+
const m = c, u = n[a], f = Y(u, m, e, o);
|
|
324
|
+
n[a] = f;
|
|
325
325
|
}), n;
|
|
326
|
-
} else return
|
|
326
|
+
} else return t;
|
|
327
327
|
}
|
|
328
|
-
function
|
|
328
|
+
function pe(n, t = "YYYY-MM-DD hh:mm:ss", e = !0) {
|
|
329
329
|
const o = new Date(n);
|
|
330
330
|
if (isNaN(o.getTime()))
|
|
331
331
|
return console.error("Invalid date"), "";
|
|
332
|
-
const
|
|
333
|
-
YYYY: (
|
|
334
|
-
MM: (
|
|
332
|
+
const r = {
|
|
333
|
+
YYYY: (i) => i.getFullYear(),
|
|
334
|
+
MM: (i) => i.getMonth() + 1,
|
|
335
335
|
// Adjust for 0-based month
|
|
336
|
-
DD: (
|
|
337
|
-
hh: (
|
|
338
|
-
mm: (
|
|
339
|
-
ss: (
|
|
340
|
-
ms: (
|
|
336
|
+
DD: (i) => i.getDate(),
|
|
337
|
+
hh: (i) => i.getHours(),
|
|
338
|
+
mm: (i) => i.getMinutes(),
|
|
339
|
+
ss: (i) => i.getSeconds(),
|
|
340
|
+
ms: (i) => i.getMilliseconds()
|
|
341
341
|
};
|
|
342
|
-
return
|
|
343
|
-
const c = i
|
|
344
|
-
return
|
|
342
|
+
return t.replace(/YYYY|MM|DD|hh|mm|ss|ms/g, (i) => {
|
|
343
|
+
const c = r[i](o);
|
|
344
|
+
return e ? String(c).padStart(2, "0") : String(c);
|
|
345
345
|
});
|
|
346
346
|
}
|
|
347
|
-
function
|
|
348
|
-
return new Promise((
|
|
349
|
-
fetch(n).then((o) =>
|
|
350
|
-
console.error("Error fetching :", o),
|
|
347
|
+
function ge(n) {
|
|
348
|
+
return new Promise((t, e) => {
|
|
349
|
+
fetch(n).then((o) => t(o.text())).catch((o) => {
|
|
350
|
+
console.error("Error fetching :", o), e(o);
|
|
351
351
|
});
|
|
352
352
|
});
|
|
353
353
|
}
|
|
354
|
-
function
|
|
355
|
-
if (!n || (n = String(n).trim(), n === "")) return
|
|
356
|
-
const
|
|
357
|
-
return
|
|
354
|
+
function B(n, t = "file") {
|
|
355
|
+
if (!n || (n = String(n).trim(), n === "")) return t;
|
|
356
|
+
const e = n.split("/");
|
|
357
|
+
return e[e.length - 1].split("?")[0];
|
|
358
358
|
}
|
|
359
|
-
function
|
|
360
|
-
return new Promise((
|
|
359
|
+
function we(n, t) {
|
|
360
|
+
return new Promise((e, o) => {
|
|
361
361
|
try {
|
|
362
|
-
|
|
363
|
-
const
|
|
364
|
-
c.href =
|
|
362
|
+
t = t || B(n, "downloaded_file"), fetch(n).then((r) => (r.ok || o(`文件下载失败,状态码: ${r.status}`), r.blob())).then((r) => {
|
|
363
|
+
const i = URL.createObjectURL(r), c = document.createElement("a");
|
|
364
|
+
c.href = i, c.download = decodeURIComponent(t), document.body.appendChild(c), c.click(), document.body.removeChild(c), URL.revokeObjectURL(i), e(r);
|
|
365
365
|
}).catch(o);
|
|
366
|
-
} catch (
|
|
367
|
-
o(
|
|
366
|
+
} catch (r) {
|
|
367
|
+
o(r);
|
|
368
368
|
}
|
|
369
369
|
});
|
|
370
370
|
}
|
|
371
|
-
function
|
|
372
|
-
let
|
|
373
|
-
function
|
|
371
|
+
function xe(n, t = 10) {
|
|
372
|
+
let e = 0, o = t;
|
|
373
|
+
function r() {
|
|
374
374
|
if (o > 0)
|
|
375
|
-
o--, requestAnimationFrame(
|
|
375
|
+
o--, requestAnimationFrame(r);
|
|
376
376
|
else {
|
|
377
|
-
const c = (+/* @__PURE__ */ new Date() -
|
|
377
|
+
const c = (+/* @__PURE__ */ new Date() - e) / t, a = 1e3 / c;
|
|
378
378
|
n(Number(a.toFixed(2)), Number(c.toFixed(2)));
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
381
|
requestAnimationFrame(() => {
|
|
382
|
-
|
|
382
|
+
e = +/* @__PURE__ */ new Date(), r();
|
|
383
383
|
});
|
|
384
384
|
}
|
|
385
|
-
function
|
|
386
|
-
return n = n.replace(/([^a-zA-Z][a-z])/g, (
|
|
385
|
+
function ve(n, t) {
|
|
386
|
+
return n = n.replace(/([^a-zA-Z][a-z])/g, (e) => e.toUpperCase()), t ? n.replace(/[^a-zA-Z]+/g, "") : n;
|
|
387
387
|
}
|
|
388
|
-
function
|
|
389
|
-
if (!
|
|
390
|
-
let c =
|
|
391
|
-
c = c ==
|
|
388
|
+
function be(n, t, e) {
|
|
389
|
+
if (!e) {
|
|
390
|
+
let c = t.replace(/^[^.]+./, "");
|
|
391
|
+
c = c == t ? "text/plain" : "application/" + c, e = { type: c };
|
|
392
392
|
}
|
|
393
|
-
const o = new Blob(n,
|
|
394
|
-
|
|
395
|
-
}
|
|
396
|
-
function ft(n) {
|
|
397
|
-
const e = n.split("?")[1] || "", t = new URLSearchParams(e), o = {};
|
|
398
|
-
return t.forEach((i, r) => {
|
|
399
|
-
o[r] = i;
|
|
400
|
-
}), o;
|
|
393
|
+
const o = new Blob(n, e), r = URL.createObjectURL(o), i = document.createElement("a");
|
|
394
|
+
i.href = r, i.download = t, document.body.appendChild(i), i.click(), document.body.removeChild(i), URL.revokeObjectURL(r);
|
|
401
395
|
}
|
|
402
|
-
function
|
|
403
|
-
return n + "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(
|
|
404
|
-
const
|
|
405
|
-
return (
|
|
396
|
+
function ye(n = "") {
|
|
397
|
+
return n + "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(t) {
|
|
398
|
+
const e = Math.random() * 16 | 0;
|
|
399
|
+
return (t === "x" ? e : e & 3 | 8).toString(16);
|
|
406
400
|
});
|
|
407
401
|
}
|
|
408
|
-
function
|
|
409
|
-
let
|
|
402
|
+
function ne(n, t) {
|
|
403
|
+
let e;
|
|
410
404
|
return function(...o) {
|
|
411
|
-
clearTimeout(
|
|
412
|
-
n(...o),
|
|
413
|
-
},
|
|
405
|
+
clearTimeout(e), e = setTimeout(() => {
|
|
406
|
+
n(...o), e = void 0;
|
|
407
|
+
}, t);
|
|
414
408
|
};
|
|
415
409
|
}
|
|
416
|
-
function
|
|
417
|
-
let
|
|
410
|
+
function Ee(n, t) {
|
|
411
|
+
let e = -1 / 0;
|
|
418
412
|
return function(...o) {
|
|
419
|
-
const
|
|
420
|
-
if (
|
|
421
|
-
|
|
413
|
+
const r = performance.now();
|
|
414
|
+
if (r - e > t) {
|
|
415
|
+
e = r;
|
|
422
416
|
try {
|
|
423
417
|
n(...o);
|
|
424
|
-
} catch (
|
|
425
|
-
console.error("Throttled function execution failed:",
|
|
418
|
+
} catch (i) {
|
|
419
|
+
console.error("Throttled function execution failed:", i);
|
|
426
420
|
}
|
|
427
421
|
}
|
|
428
422
|
};
|
|
429
423
|
}
|
|
430
|
-
function
|
|
424
|
+
function G(n) {
|
|
431
425
|
return Array.isArray(n) ? "array" : n === null ? "null" : typeof n;
|
|
432
426
|
}
|
|
433
|
-
function
|
|
434
|
-
const
|
|
427
|
+
function Ce(n) {
|
|
428
|
+
const t = () => Promise.resolve(), e = (a) => (console.error(a), Promise.reject(a));
|
|
435
429
|
function o() {
|
|
436
|
-
return navigator.clipboard.writeText(n).then(
|
|
430
|
+
return navigator.clipboard.writeText(n).then(t).catch(e);
|
|
437
431
|
}
|
|
438
|
-
function
|
|
432
|
+
function r() {
|
|
439
433
|
const a = document.createElement("div");
|
|
440
434
|
a.innerText = n, document.body.appendChild(a);
|
|
441
435
|
const m = document.createRange();
|
|
@@ -444,59 +438,59 @@ function xt(n) {
|
|
|
444
438
|
let f = !1;
|
|
445
439
|
return u && (u.removeAllRanges(), u.addRange(m), f = document.execCommand("copy")), document.body.removeChild(a), f ? Promise.resolve() : Promise.reject();
|
|
446
440
|
}
|
|
447
|
-
function
|
|
441
|
+
function i() {
|
|
448
442
|
const a = document.createElement("textarea");
|
|
449
443
|
a.value = n, document.body.appendChild(a), a.select(), a.setSelectionRange(0, n.length);
|
|
450
444
|
let m = !1;
|
|
451
445
|
return document.activeElement === a && (m = document.execCommand("Copy", !0)), document.body.removeChild(a), m ? Promise.resolve() : Promise.reject();
|
|
452
446
|
}
|
|
453
447
|
function c() {
|
|
454
|
-
return
|
|
455
|
-
|
|
448
|
+
return r().then(t).catch(() => {
|
|
449
|
+
i().then(t).catch(() => e("复制方式尽皆失效"));
|
|
456
450
|
});
|
|
457
451
|
}
|
|
458
452
|
return navigator.clipboard ? o().catch(c) : c();
|
|
459
453
|
}
|
|
460
|
-
function
|
|
461
|
-
const
|
|
462
|
-
return
|
|
454
|
+
function Fe(n, t) {
|
|
455
|
+
const e = t.split(".");
|
|
456
|
+
return e.reduce((o, r, i) => (r in o || (i === e.length - 1 ? o[r] = void 0 : o[r] = {}), o[r]), n);
|
|
463
457
|
}
|
|
464
|
-
function
|
|
465
|
-
const
|
|
466
|
-
return
|
|
458
|
+
function Le(n, t) {
|
|
459
|
+
const e = t.split(".");
|
|
460
|
+
return e.reduce((o, r, i) => o.hasOwnProperty(r) ? o[r] : o[r] = i == e.length - 1 ? void 0 : {}, n);
|
|
467
461
|
}
|
|
468
|
-
function
|
|
469
|
-
const o =
|
|
470
|
-
return o.reduce((
|
|
462
|
+
function je(n, t, e) {
|
|
463
|
+
const o = t.split(".");
|
|
464
|
+
return o.reduce((r, i, c) => (c === o.length - 1 && (r[i] = e), r[i]), n);
|
|
471
465
|
}
|
|
472
|
-
function
|
|
473
|
-
return new Promise((
|
|
466
|
+
function Me(n) {
|
|
467
|
+
return new Promise((t, e) => {
|
|
474
468
|
if (typeof n != "string" || n.trim() === "" || !n.includes("://")) {
|
|
475
|
-
|
|
469
|
+
e(new Error("Invalid URL: Must be a non-empty string"));
|
|
476
470
|
return;
|
|
477
471
|
}
|
|
478
472
|
try {
|
|
479
473
|
new XMLHttpRequest().open("HEAD", n, !0);
|
|
480
|
-
} catch (
|
|
481
|
-
|
|
474
|
+
} catch (i) {
|
|
475
|
+
e(new Error(`Invalid URL format: ${i.message}`));
|
|
482
476
|
return;
|
|
483
477
|
}
|
|
484
478
|
const o = new XMLHttpRequest();
|
|
485
479
|
o.open("HEAD", n, !0);
|
|
486
|
-
const
|
|
487
|
-
|
|
480
|
+
const r = (i) => {
|
|
481
|
+
e(new Error(`Request failed: ${i.type}`));
|
|
488
482
|
};
|
|
489
483
|
o.onreadystatechange = function() {
|
|
490
|
-
o.readyState === XMLHttpRequest.DONE && (o.status === 0 ?
|
|
491
|
-
}, o.onerror =
|
|
484
|
+
o.readyState === XMLHttpRequest.DONE && (o.status === 0 ? e(new Error("Network error or CORS blocked")) : o.status >= 200 && o.status < 300 ? t(!0) : e(new Error(`HTTP Error: ${o.status}`)));
|
|
485
|
+
}, o.onerror = r, o.onabort = r, o.ontimeout = r;
|
|
492
486
|
try {
|
|
493
487
|
o.send();
|
|
494
|
-
} catch (
|
|
495
|
-
|
|
488
|
+
} catch (i) {
|
|
489
|
+
e(new Error(`Request send failed: ${i.message}`));
|
|
496
490
|
}
|
|
497
491
|
});
|
|
498
492
|
}
|
|
499
|
-
function
|
|
493
|
+
function Re(n) {
|
|
500
494
|
return [
|
|
501
495
|
"https:",
|
|
502
496
|
// HTTPS协议,用于安全地浏览网页
|
|
@@ -518,20 +512,24 @@ function Et(n) {
|
|
|
518
512
|
// Remote Desktop Protocol,用于安全的远程桌面连接
|
|
519
513
|
"vpn:"
|
|
520
514
|
// VPN协议,用于创建安全的网络连接
|
|
521
|
-
].some((
|
|
522
|
-
}
|
|
523
|
-
const
|
|
524
|
-
|
|
525
|
-
if (
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
515
|
+
].some((e) => n.startsWith(e));
|
|
516
|
+
}
|
|
517
|
+
const F = class F {
|
|
518
|
+
constructor() {
|
|
519
|
+
if (new.target === F)
|
|
520
|
+
throw new Error("请直接使用静态方法,而不是实例化此类");
|
|
521
|
+
}
|
|
522
|
+
static check(t, e) {
|
|
523
|
+
if (!t || typeof t != "string")
|
|
524
|
+
return console.error("Invalid URL provided"), e ? !1 : "unknown";
|
|
525
|
+
const o = B(t).toLowerCase();
|
|
526
|
+
if (e) {
|
|
527
|
+
if (!$.hasOwnProperty(e))
|
|
528
|
+
return console.error(`Unknown file type: ${e}`), "unknown";
|
|
529
|
+
const r = $[e];
|
|
530
|
+
return F._checkExtension(o, r);
|
|
533
531
|
}
|
|
534
|
-
return
|
|
532
|
+
return F._detectFileType(o);
|
|
535
533
|
}
|
|
536
534
|
/**
|
|
537
535
|
* 静态方法,用于解析地址信息
|
|
@@ -541,10 +539,10 @@ const C = class C {
|
|
|
541
539
|
* @param {string} url - 以逗号分隔的URL字符串,每个URL代表一个资源的位置
|
|
542
540
|
* @returns {Array} - 包含每个URL及其相关信息(名称和类型)的对象数组
|
|
543
541
|
*/
|
|
544
|
-
static parseAddresses(
|
|
545
|
-
return !
|
|
546
|
-
const o =
|
|
547
|
-
return { url:
|
|
542
|
+
static parseAddresses(t) {
|
|
543
|
+
return !t || typeof t != "string" ? (console.error("Invalid URL provided"), []) : t.split(",").map((e) => {
|
|
544
|
+
const o = B(e), r = this.check(e);
|
|
545
|
+
return { url: e, name: o, type: r };
|
|
548
546
|
});
|
|
549
547
|
}
|
|
550
548
|
/**
|
|
@@ -553,13 +551,13 @@ const C = class C {
|
|
|
553
551
|
* @param {string} [accept] - 可接受的 MIME 类型模式(如 "image/*, text/plain")
|
|
554
552
|
* @returns {boolean} - 如果类型匹配,则返回 true,否则返回 false
|
|
555
553
|
*/
|
|
556
|
-
static matchesMimeType(
|
|
557
|
-
if (!
|
|
558
|
-
if (typeof
|
|
559
|
-
const o =
|
|
560
|
-
return
|
|
554
|
+
static matchesMimeType(t, e) {
|
|
555
|
+
if (!e) return !0;
|
|
556
|
+
if (typeof t != "string" || typeof e != "string") return !1;
|
|
557
|
+
const o = F._normalizeType(t), r = e.split(",").map((a) => F._normalizeType(a.trim())), [i, c = "*"] = o.split("/");
|
|
558
|
+
return r.some((a) => {
|
|
561
559
|
const [m, u = "*"] = a.split("/");
|
|
562
|
-
return (m === "*" ||
|
|
560
|
+
return (m === "*" || i === "*" || m === i) && (u === "*" || c === "*" || u === c);
|
|
563
561
|
});
|
|
564
562
|
}
|
|
565
563
|
/**
|
|
@@ -570,8 +568,8 @@ const C = class C {
|
|
|
570
568
|
* @param {string} type - 文件类型或MIME类型字符串
|
|
571
569
|
* @returns {string} 标准化的MIME类型字符串,如果无法识别则返回原始输入
|
|
572
570
|
*/
|
|
573
|
-
static _normalizeType(
|
|
574
|
-
return
|
|
571
|
+
static _normalizeType(t) {
|
|
572
|
+
return t.startsWith(".") && !t.includes("/") ? te[t.toLowerCase()] || t : t.includes("/") ? t : `${t}/*`;
|
|
575
573
|
}
|
|
576
574
|
/**
|
|
577
575
|
* 检查URL是否具有任何指定的文件扩展名
|
|
@@ -579,69 +577,169 @@ const C = class C {
|
|
|
579
577
|
* @param {string[]} validExtensions - 有效文件扩展名的数组
|
|
580
578
|
* @returns {boolean} - 如果URL具有任何指定的文件扩展名,则返回true,否则返回false
|
|
581
579
|
*/
|
|
582
|
-
static _checkExtension(
|
|
583
|
-
return
|
|
580
|
+
static _checkExtension(t, e) {
|
|
581
|
+
return e.some((o) => t.endsWith(o));
|
|
584
582
|
}
|
|
585
583
|
/**
|
|
586
584
|
* 检测文件URL的类型
|
|
587
585
|
* @param {string} url - 文件的URL
|
|
588
586
|
* @returns {string} - 如果URL与任何已知类型匹配,则返回文件类型,否则返回"unknown"
|
|
589
587
|
*/
|
|
590
|
-
static _detectFileType(
|
|
591
|
-
for (const [
|
|
592
|
-
if (o.some((
|
|
593
|
-
return
|
|
588
|
+
static _detectFileType(t) {
|
|
589
|
+
for (const [e, o] of F.cachedEntries)
|
|
590
|
+
if (o.some((r) => t.endsWith(r)))
|
|
591
|
+
return e;
|
|
594
592
|
return "unknown";
|
|
595
593
|
}
|
|
596
594
|
};
|
|
597
595
|
// 缓存文件扩展名的条目,以提高性能
|
|
598
|
-
|
|
599
|
-
let
|
|
600
|
-
function
|
|
601
|
-
return n.map((
|
|
596
|
+
y(F, "cachedEntries", Object.entries($));
|
|
597
|
+
let V = F;
|
|
598
|
+
function Te(n) {
|
|
599
|
+
return n.map((t, e) => n.slice(e).concat(n.slice(0, e)));
|
|
602
600
|
}
|
|
603
|
-
function
|
|
604
|
-
const
|
|
601
|
+
function ke(n) {
|
|
602
|
+
const t = window.structuredClone, e = (o) => o === null || typeof o != "object" ? o : Y(Array.isArray(o) ? [] : {}, o);
|
|
605
603
|
try {
|
|
606
|
-
return
|
|
604
|
+
return t ? t(n) : e(n);
|
|
607
605
|
} catch (o) {
|
|
608
|
-
return console.error("structuredClone error:", o),
|
|
606
|
+
return console.error("structuredClone error:", o), t && e(n);
|
|
609
607
|
}
|
|
610
608
|
}
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
609
|
+
const N = class N {
|
|
610
|
+
/**
|
|
611
|
+
* 构造函数
|
|
612
|
+
* @throws 如果尝试实例化该类,则抛出错误,因为应该使用静态方法
|
|
613
|
+
*/
|
|
614
|
+
constructor() {
|
|
615
|
+
if (new.target === N)
|
|
616
|
+
throw new Error("请直接使用静态方法,而不是实例化此类");
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* 根据键打开或聚焦窗口
|
|
620
|
+
* @param key 窗口的唯一键
|
|
621
|
+
* @param url 要打开的URL
|
|
622
|
+
* @param target 窗口的目标
|
|
623
|
+
* @param windowFeatures 新窗口的特性
|
|
624
|
+
* @returns 返回已打开或新打开的窗口
|
|
625
|
+
*/
|
|
626
|
+
static open(t, e, o, r) {
|
|
627
|
+
const i = this.keys.get(t);
|
|
628
|
+
if (i && !i.closed)
|
|
629
|
+
return i.focus(), i;
|
|
630
|
+
{
|
|
631
|
+
const c = window.open(e, o, r);
|
|
632
|
+
if (c)
|
|
633
|
+
return this.keys.set(t, c), c;
|
|
634
|
+
console.error("window.open failed: 可能是浏览器阻止了弹出窗口"), this.keys.delete(t);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* 检查指定键的窗口是否打开
|
|
639
|
+
* @param key 窗口的唯一键
|
|
640
|
+
* @returns 如果窗口打开则返回true,否则返回false
|
|
641
|
+
*/
|
|
642
|
+
static isOpen(t) {
|
|
643
|
+
const e = this.keys.get(t);
|
|
644
|
+
return e != null && e.closed && this.keys.delete(t), this.keys.has(t);
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* 获取与指定键关联的窗口
|
|
648
|
+
* @param key 窗口的唯一键
|
|
649
|
+
* @returns 返回对应的窗口,如果窗口已关闭则返回undefined
|
|
650
|
+
*/
|
|
651
|
+
static getWindow(t) {
|
|
652
|
+
if (this.isOpen(t)) return this.keys.get(t);
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* 关闭与指定键关联的窗口
|
|
656
|
+
* @param key 窗口的唯一键
|
|
657
|
+
*/
|
|
658
|
+
static close(t) {
|
|
659
|
+
const e = this.keys.get(t);
|
|
660
|
+
e && (e.close(), this.keys.delete(t));
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* 关闭所有打开的窗口并清空Map
|
|
664
|
+
*/
|
|
665
|
+
static closeAll() {
|
|
666
|
+
this.keys.forEach((t, e) => t.close()), this.keys.clear();
|
|
667
|
+
}
|
|
668
|
+
};
|
|
669
|
+
// 存储键与对应窗口的Map
|
|
670
|
+
y(N, "keys", /* @__PURE__ */ new Map());
|
|
671
|
+
let Z = N;
|
|
672
|
+
function Ue(n, t = "image/png") {
|
|
673
|
+
try {
|
|
674
|
+
let e, o = t;
|
|
675
|
+
if (n instanceof File)
|
|
676
|
+
return URL.createObjectURL(n);
|
|
677
|
+
if (typeof n == "string") {
|
|
678
|
+
let i = n;
|
|
679
|
+
const c = i.match(/^data:([^;]*)(;base64)?,(.*)$/i);
|
|
680
|
+
if (c) {
|
|
681
|
+
if (!c[2])
|
|
682
|
+
throw new Error("无效的数据 URL:缺少 base64 编码声明");
|
|
683
|
+
if (o = c[1] || o, i = c[3], !i)
|
|
684
|
+
throw new Error("数据 URL 包含空有效负载");
|
|
685
|
+
}
|
|
686
|
+
i = i.replace(/[^A-Za-z0-9+/=]/g, "");
|
|
687
|
+
const a = atob(i);
|
|
688
|
+
e = new Uint8Array(a.length);
|
|
689
|
+
for (let m = 0; m < a.length; m++)
|
|
690
|
+
e[m] = a.charCodeAt(m);
|
|
691
|
+
} else if (n instanceof ArrayBuffer)
|
|
692
|
+
e = new Uint8Array(n);
|
|
693
|
+
else if (n instanceof Uint8Array)
|
|
694
|
+
e = n;
|
|
695
|
+
else
|
|
696
|
+
throw new Error(
|
|
697
|
+
"不支持的数据类型。应为 Base64 字符串、ArrayBuffer 或 Uint8Array"
|
|
698
|
+
);
|
|
699
|
+
const r = new Blob([e], { type: o });
|
|
700
|
+
return URL.createObjectURL(r);
|
|
701
|
+
} catch (e) {
|
|
702
|
+
return console.error(
|
|
703
|
+
"数据到 ImageURL 的转换失败:",
|
|
704
|
+
e.message,
|
|
705
|
+
e.stack || "没有可用的堆栈跟踪"
|
|
706
|
+
), null;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
function Pe(n) {
|
|
710
|
+
const t = ne(n, 100);
|
|
711
|
+
let e = 0, o = 0;
|
|
712
|
+
return function(r) {
|
|
713
|
+
const i = r.target;
|
|
714
|
+
if (!i || !(i instanceof HTMLElement)) return;
|
|
617
715
|
const {
|
|
618
716
|
scrollTop: c,
|
|
619
717
|
scrollHeight: a,
|
|
620
718
|
clientHeight: m,
|
|
621
719
|
scrollLeft: u,
|
|
622
720
|
scrollWidth: f,
|
|
623
|
-
clientWidth:
|
|
624
|
-
} =
|
|
625
|
-
function
|
|
626
|
-
if (
|
|
627
|
-
const
|
|
628
|
-
if (
|
|
629
|
-
a - c - m <= 1 &&
|
|
721
|
+
clientWidth: g
|
|
722
|
+
} = i;
|
|
723
|
+
function A() {
|
|
724
|
+
if (e == c) return;
|
|
725
|
+
const q = e > c;
|
|
726
|
+
if (e = c, q) return;
|
|
727
|
+
a - c - m <= 1 && t("vertical");
|
|
630
728
|
}
|
|
631
|
-
function
|
|
729
|
+
function J() {
|
|
632
730
|
if (o == u) return;
|
|
633
|
-
const
|
|
634
|
-
if (o = u,
|
|
635
|
-
f - u -
|
|
731
|
+
const q = o > u;
|
|
732
|
+
if (o = u, q) return;
|
|
733
|
+
f - u - g <= 1 && t("horizontal");
|
|
636
734
|
}
|
|
637
|
-
|
|
735
|
+
A(), J();
|
|
638
736
|
};
|
|
639
737
|
}
|
|
640
|
-
function
|
|
641
|
-
const { isClickAllowed: o, uiLibrary:
|
|
738
|
+
function ze(n, t, e) {
|
|
739
|
+
const { isClickAllowed: o, uiLibrary: r = ["naiveUI", "ElementPlus", "Element"] } = e || {}, i = function(m) {
|
|
642
740
|
const u = [];
|
|
643
741
|
for (const f in m)
|
|
644
|
-
Object.hasOwnProperty.call(m, f) &&
|
|
742
|
+
Object.hasOwnProperty.call(m, f) && r.includes(f) && u.push(...m[f]);
|
|
645
743
|
return u;
|
|
646
744
|
}({
|
|
647
745
|
naiveUI: [
|
|
@@ -653,37 +751,37 @@ function Mt(n, e, t) {
|
|
|
653
751
|
Element: [".el-popper"]
|
|
654
752
|
});
|
|
655
753
|
function c() {
|
|
656
|
-
|
|
754
|
+
t(), document.removeEventListener("mousedown", a);
|
|
657
755
|
}
|
|
658
756
|
function a(m) {
|
|
659
757
|
if (o) {
|
|
660
|
-
const
|
|
661
|
-
if (
|
|
662
|
-
if (
|
|
758
|
+
const g = o(m);
|
|
759
|
+
if (g) return;
|
|
760
|
+
if (g === !1) return c();
|
|
663
761
|
}
|
|
664
762
|
const u = m.target;
|
|
665
763
|
if (!(u instanceof HTMLElement) || !(u != null && u.closest("body"))) return;
|
|
666
|
-
n.concat(
|
|
764
|
+
n.concat(i).some((g) => !!(u != null && u.closest(g))) || c();
|
|
667
765
|
}
|
|
668
766
|
requestAnimationFrame(
|
|
669
767
|
() => document.addEventListener("mousedown", a)
|
|
670
768
|
);
|
|
671
769
|
}
|
|
672
|
-
var
|
|
673
|
-
class
|
|
770
|
+
var w, j, M, U, P, E, C, L, z;
|
|
771
|
+
class De {
|
|
674
772
|
constructor() {
|
|
675
|
-
d(this,
|
|
676
|
-
d(this,
|
|
677
|
-
d(this,
|
|
678
|
-
d(this,
|
|
773
|
+
d(this, w);
|
|
774
|
+
d(this, j, !1);
|
|
775
|
+
d(this, M, {});
|
|
776
|
+
d(this, U, 0);
|
|
679
777
|
d(this, P, 0);
|
|
680
|
-
d(this,
|
|
681
|
-
d(this,
|
|
682
|
-
d(this,
|
|
683
|
-
d(this,
|
|
778
|
+
d(this, E, 0);
|
|
779
|
+
d(this, C, 0);
|
|
780
|
+
d(this, L);
|
|
781
|
+
d(this, z);
|
|
684
782
|
}
|
|
685
|
-
init(
|
|
686
|
-
l(this,
|
|
783
|
+
init(t, e) {
|
|
784
|
+
l(this, w, t), l(this, L, e == null ? void 0 : e.limit), l(this, z, e == null ? void 0 : e.dragDom), l(this, M, {
|
|
687
785
|
mousedown: this.mousedown.bind(this),
|
|
688
786
|
mousemove: this.mousemove.bind(this),
|
|
689
787
|
mouseup: this.mouseup.bind(this)
|
|
@@ -692,47 +790,47 @@ class Lt {
|
|
|
692
790
|
finish() {
|
|
693
791
|
this.bindOrUnbindEvent("unbind");
|
|
694
792
|
}
|
|
695
|
-
bindOrUnbindEvent(
|
|
696
|
-
const
|
|
697
|
-
if (!s(this,
|
|
698
|
-
s(this,
|
|
793
|
+
bindOrUnbindEvent(t) {
|
|
794
|
+
const e = t === "bind" ? "addEventListener" : "removeEventListener";
|
|
795
|
+
if (!s(this, w)) return console.error("No DOM");
|
|
796
|
+
s(this, w)[e]("mousedown", s(this, M).mousedown), document[e]("mousemove", s(this, M).mousemove), document[e]("mouseup", s(this, M).mouseup);
|
|
699
797
|
}
|
|
700
798
|
alterLocation() {
|
|
701
|
-
if (!s(this,
|
|
702
|
-
s(this,
|
|
799
|
+
if (!s(this, w)) return console.error("No DOM");
|
|
800
|
+
s(this, L) && (l(this, E, Math.min(s(this, E), s(this, L).max.top)), l(this, E, Math.max(s(this, E), s(this, L).min.top)), l(this, C, Math.min(s(this, C), s(this, L).max.left)), l(this, C, Math.max(s(this, C), s(this, L).min.left))), s(this, w).style.setProperty("--top", s(this, E) + "px"), s(this, w).style.setProperty("--left", s(this, C) + "px");
|
|
703
801
|
}
|
|
704
|
-
mousedown(
|
|
705
|
-
if (!s(this,
|
|
706
|
-
if (s(this,
|
|
707
|
-
document.body.classList.add("no-select"), l(this,
|
|
708
|
-
const
|
|
709
|
-
l(this,
|
|
802
|
+
mousedown(t) {
|
|
803
|
+
if (!s(this, w)) return console.error("No DOM");
|
|
804
|
+
if (s(this, z) && t.target != s(this, z)) return;
|
|
805
|
+
document.body.classList.add("no-select"), l(this, j, !0);
|
|
806
|
+
const e = s(this, w).getBoundingClientRect(), { pageX: o, pageY: r } = t;
|
|
807
|
+
l(this, U, o), l(this, P, r), l(this, E, e.y), l(this, C, e.x);
|
|
710
808
|
}
|
|
711
|
-
mousemove(
|
|
712
|
-
const { pageX:
|
|
713
|
-
s(this,
|
|
809
|
+
mousemove(t) {
|
|
810
|
+
const { pageX: e, pageY: o } = t;
|
|
811
|
+
s(this, j) && (l(this, E, s(this, E) + (o - s(this, P))), l(this, C, s(this, C) + (e - s(this, U))), l(this, U, e), l(this, P, o), this.alterLocation());
|
|
714
812
|
}
|
|
715
813
|
mouseup() {
|
|
716
|
-
s(this,
|
|
814
|
+
s(this, j) && (l(this, j, !1), document.body.classList.remove("no-select"));
|
|
717
815
|
}
|
|
718
816
|
}
|
|
719
|
-
|
|
720
|
-
var x,
|
|
721
|
-
class
|
|
817
|
+
w = new WeakMap(), j = new WeakMap(), M = new WeakMap(), U = new WeakMap(), P = new WeakMap(), E = new WeakMap(), C = new WeakMap(), L = new WeakMap(), z = new WeakMap();
|
|
818
|
+
var x, R, T, D, I, v, b, p, O, _;
|
|
819
|
+
class Ie {
|
|
722
820
|
constructor() {
|
|
723
821
|
d(this, x);
|
|
724
|
-
d(this,
|
|
725
|
-
d(this,
|
|
726
|
-
d(this,
|
|
727
|
-
d(this,
|
|
728
|
-
d(this, b, 0);
|
|
822
|
+
d(this, R, !1);
|
|
823
|
+
d(this, T, {});
|
|
824
|
+
d(this, D, 0);
|
|
825
|
+
d(this, I, 0);
|
|
729
826
|
d(this, v, 0);
|
|
730
|
-
d(this,
|
|
731
|
-
d(this,
|
|
732
|
-
d(this,
|
|
827
|
+
d(this, b, 0);
|
|
828
|
+
d(this, p);
|
|
829
|
+
d(this, O);
|
|
830
|
+
d(this, _);
|
|
733
831
|
}
|
|
734
|
-
init(
|
|
735
|
-
l(this, x,
|
|
832
|
+
init(t, e = {}) {
|
|
833
|
+
l(this, x, t), l(this, p, e.limit), l(this, O, e.update_move), l(this, _, e.update_up), l(this, T, {
|
|
736
834
|
mousedown: this.mousedown.bind(this),
|
|
737
835
|
mousemove: this.mousemove.bind(this),
|
|
738
836
|
mouseup: this.mouseup.bind(this)
|
|
@@ -741,172 +839,304 @@ class Rt {
|
|
|
741
839
|
finish() {
|
|
742
840
|
this.bindOrUnbindEvent("unbind");
|
|
743
841
|
}
|
|
744
|
-
bindOrUnbindEvent(
|
|
745
|
-
const
|
|
842
|
+
bindOrUnbindEvent(t) {
|
|
843
|
+
const e = t === "bind" ? "addEventListener" : "removeEventListener";
|
|
746
844
|
if (!s(this, x)) return console.error("No DOM");
|
|
747
|
-
s(this, x)[
|
|
845
|
+
s(this, x)[e]("mousedown", s(this, T).mousedown), document[e]("mousemove", s(this, T).mousemove), document[e]("mouseup", s(this, T).mouseup);
|
|
748
846
|
}
|
|
749
847
|
updateValue() {
|
|
750
|
-
const
|
|
751
|
-
top: s(this,
|
|
752
|
-
left: s(this,
|
|
848
|
+
const t = {
|
|
849
|
+
top: s(this, v),
|
|
850
|
+
left: s(this, b),
|
|
753
851
|
percentage: { top: 0, left: 0 }
|
|
754
852
|
};
|
|
755
|
-
if (s(this,
|
|
756
|
-
const
|
|
757
|
-
|
|
758
|
-
top:
|
|
759
|
-
left:
|
|
853
|
+
if (s(this, p)) {
|
|
854
|
+
const e = (o) => s(this, p) ? (t[o] - s(this, p).min[o]) / (s(this, p).max[o] - s(this, p).min[o]) : 0;
|
|
855
|
+
t.percentage = {
|
|
856
|
+
top: e("top") || 0,
|
|
857
|
+
left: e("left") || 0
|
|
760
858
|
};
|
|
761
859
|
}
|
|
762
|
-
return
|
|
860
|
+
return t;
|
|
763
861
|
}
|
|
764
862
|
alterLocation() {
|
|
765
863
|
if (!s(this, x)) return console.error("No DOM");
|
|
766
|
-
s(this,
|
|
864
|
+
s(this, p) && (l(this, v, Math.min(s(this, v), s(this, p).max.top)), l(this, v, Math.max(s(this, v), s(this, p).min.top)), l(this, b, Math.min(s(this, b), s(this, p).max.left)), l(this, b, Math.max(s(this, b), s(this, p).min.left))), s(this, O) && s(this, O).call(this, this.updateValue()), s(this, x).style.setProperty("--top", s(this, v) + "px"), s(this, x).style.setProperty("--left", s(this, b) + "px");
|
|
767
865
|
}
|
|
768
|
-
mousedown(
|
|
866
|
+
mousedown(t) {
|
|
769
867
|
if (!s(this, x)) return console.error("No DOM");
|
|
770
|
-
document.body.classList.add("no-select"), l(this,
|
|
771
|
-
const
|
|
772
|
-
l(this,
|
|
773
|
-
const { pageX: o, pageY:
|
|
774
|
-
l(this,
|
|
868
|
+
document.body.classList.add("no-select"), l(this, R, !0);
|
|
869
|
+
const e = s(this, x).getBoundingClientRect();
|
|
870
|
+
l(this, I, e.y), l(this, D, e.x);
|
|
871
|
+
const { pageX: o, pageY: r } = t;
|
|
872
|
+
l(this, v, r - s(this, I)), l(this, b, o - s(this, D)), this.alterLocation();
|
|
775
873
|
}
|
|
776
|
-
mousemove(
|
|
777
|
-
const { pageX:
|
|
778
|
-
s(this,
|
|
874
|
+
mousemove(t) {
|
|
875
|
+
const { pageX: e, pageY: o } = t;
|
|
876
|
+
s(this, R) && (l(this, v, o - s(this, I)), l(this, b, e - s(this, D)), this.alterLocation());
|
|
779
877
|
}
|
|
780
878
|
mouseup() {
|
|
781
|
-
s(this,
|
|
879
|
+
s(this, R) && (l(this, R, !1), document.body.classList.remove("no-select"), s(this, _) && s(this, _).call(this, this.updateValue()));
|
|
782
880
|
}
|
|
783
881
|
}
|
|
784
|
-
x = new WeakMap(),
|
|
785
|
-
function
|
|
786
|
-
const
|
|
882
|
+
x = new WeakMap(), R = new WeakMap(), T = new WeakMap(), D = new WeakMap(), I = new WeakMap(), v = new WeakMap(), b = new WeakMap(), p = new WeakMap(), O = new WeakMap(), _ = new WeakMap();
|
|
883
|
+
function oe(n) {
|
|
884
|
+
const t = n;
|
|
787
885
|
if (n) {
|
|
788
886
|
if (n.requestFullscreen)
|
|
789
887
|
return n.requestFullscreen();
|
|
790
|
-
if (
|
|
791
|
-
return
|
|
792
|
-
if (
|
|
793
|
-
return
|
|
794
|
-
if (
|
|
795
|
-
return
|
|
888
|
+
if (t.mozRequestFullScreen)
|
|
889
|
+
return t.mozRequestFullScreen();
|
|
890
|
+
if (t.webkitRequestFullscreen)
|
|
891
|
+
return t.webkitRequestFullscreen();
|
|
892
|
+
if (t.msRequestFullscreen)
|
|
893
|
+
return t.msRequestFullscreen();
|
|
796
894
|
} else return Promise.reject("No DOM");
|
|
797
895
|
return Promise.reject("No Fullscreen API");
|
|
798
896
|
}
|
|
799
|
-
function
|
|
897
|
+
function re() {
|
|
800
898
|
const n = document;
|
|
801
899
|
return document.exitFullscreen ? document.exitFullscreen() : n.mozCancelFullScreen ? n.mozCancelFullScreen() : n.webkitExitFullscreen ? n.webkitExitFullscreen() : n.msExitFullscreen ? n.msExitFullscreen() : Promise.reject("No ExitFullscreen API");
|
|
802
900
|
}
|
|
803
|
-
function
|
|
901
|
+
function ie() {
|
|
804
902
|
const n = document;
|
|
805
903
|
return document.fullscreenElement || n.webkitFullscreenElement || n.mozFullScreenElement || n.msFullscreenElement;
|
|
806
904
|
}
|
|
807
|
-
function
|
|
905
|
+
function Oe(n) {
|
|
808
906
|
return function() {
|
|
809
|
-
|
|
907
|
+
ie() ? re() : oe(n);
|
|
810
908
|
};
|
|
811
909
|
}
|
|
812
|
-
function
|
|
910
|
+
function _e(n, t) {
|
|
813
911
|
if (typeof n == "number") return n;
|
|
814
912
|
if (/px/.test(n)) return Number(n.replace(/px/, "")) || 0;
|
|
815
|
-
const
|
|
816
|
-
|
|
817
|
-
const o =
|
|
818
|
-
return
|
|
913
|
+
const e = document.createElement("div");
|
|
914
|
+
e.style.width = n, t = t || document.body, t.appendChild(e);
|
|
915
|
+
const o = e.getBoundingClientRect().width;
|
|
916
|
+
return t.removeChild(e), o;
|
|
819
917
|
}
|
|
820
|
-
function
|
|
821
|
-
|
|
918
|
+
function Se(n, t) {
|
|
919
|
+
if (!n) return;
|
|
920
|
+
let e, o;
|
|
921
|
+
if (typeof t == "string") {
|
|
922
|
+
const i = document.querySelector(t);
|
|
923
|
+
if (!i) return;
|
|
924
|
+
const c = i.getBoundingClientRect();
|
|
925
|
+
e = c.width, o = c.height;
|
|
926
|
+
} else if (Array.isArray(t))
|
|
927
|
+
e = t[0], o = t[1];
|
|
928
|
+
else {
|
|
929
|
+
const i = t.getBoundingClientRect();
|
|
930
|
+
e = i.width, o = i.height;
|
|
931
|
+
}
|
|
932
|
+
const r = e / o;
|
|
933
|
+
return r > n ? [n * o, o] : r < n ? [e, e / n] : [e, o];
|
|
934
|
+
}
|
|
935
|
+
function Ae(n, t = 5e3) {
|
|
936
|
+
return new Promise((e, o) => {
|
|
937
|
+
const r = new Image();
|
|
938
|
+
r.src = n;
|
|
939
|
+
const i = setTimeout(() => {
|
|
940
|
+
o(new Error("图片加载超时")), r.onload = null, r.onerror = null;
|
|
941
|
+
}, t);
|
|
942
|
+
r.onload = () => {
|
|
943
|
+
clearTimeout(i);
|
|
944
|
+
const c = r.naturalWidth, a = r.naturalHeight, m = c / a;
|
|
945
|
+
e([r, m]);
|
|
946
|
+
}, r.onerror = () => {
|
|
947
|
+
clearTimeout(i), o(new Error("图片加载失败"));
|
|
948
|
+
}, r.crossOrigin = "Anonymous";
|
|
949
|
+
});
|
|
822
950
|
}
|
|
823
|
-
function
|
|
824
|
-
return
|
|
951
|
+
function Ne(n, t, e = 2) {
|
|
952
|
+
return !Number.isFinite(n) || !Number.isFinite(t) || !Number.isFinite(e) ? (console.error("所有参数必须是有限的数字"), "") : t === 0 ? (console.error("分母不能为零"), "") : e < 0 ? (console.error("小数位数不能为负数"), "") : (n / t * 100).toFixed(e) + "%";
|
|
825
953
|
}
|
|
826
|
-
function
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
954
|
+
function qe(n, t, e) {
|
|
955
|
+
return Math.abs(n - t) <= e;
|
|
956
|
+
}
|
|
957
|
+
function $e(n, t = 500) {
|
|
958
|
+
let e;
|
|
959
|
+
function o(r) {
|
|
960
|
+
e || (e = r);
|
|
961
|
+
let i = Math.min((r - e) / t, 1);
|
|
962
|
+
n(i), r - e < t && requestAnimationFrame(o);
|
|
832
963
|
}
|
|
833
964
|
requestAnimationFrame(o);
|
|
834
965
|
}
|
|
835
|
-
function
|
|
966
|
+
function Ye(n) {
|
|
836
967
|
return n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
837
968
|
}
|
|
838
|
-
function
|
|
839
|
-
const
|
|
969
|
+
function Be(n, t) {
|
|
970
|
+
const e = {
|
|
840
971
|
join: !0,
|
|
841
972
|
suffix: "",
|
|
842
973
|
decimalPlaces: 2
|
|
843
|
-
}, { join: o, suffix:
|
|
844
|
-
...
|
|
845
|
-
...
|
|
974
|
+
}, { join: o, suffix: r, decimalPlaces: i } = {
|
|
975
|
+
...e,
|
|
976
|
+
...t || {}
|
|
846
977
|
}, c = Number(n);
|
|
847
|
-
if (isNaN(c)) return o ? `0${
|
|
848
|
-
const a = Math.abs(c), m = c >= 0, u = Math.max(0, Math.floor(Math.log10(a) / 4)), f = Math.pow(1e4, u),
|
|
849
|
-
return o ? `${
|
|
850
|
-
}
|
|
851
|
-
function
|
|
852
|
-
let
|
|
853
|
-
const { x: o, y:
|
|
854
|
-
for (let c = 0, a =
|
|
855
|
-
const m =
|
|
856
|
-
u >
|
|
857
|
-
}
|
|
858
|
-
return
|
|
859
|
-
}
|
|
860
|
-
function
|
|
861
|
-
const
|
|
862
|
-
let
|
|
978
|
+
if (isNaN(c)) return o ? `0${r}` : [0, r];
|
|
979
|
+
const a = Math.abs(c), m = c >= 0, u = Math.max(0, Math.floor(Math.log10(a) / 4)), f = Math.pow(1e4, u), g = a / f, A = (m ? 1 : -1) * parseFloat(g.toFixed(Math.max(0, i)));
|
|
980
|
+
return o ? `${A}${W[u]}${r}` : [A, W[u] + r];
|
|
981
|
+
}
|
|
982
|
+
function He(n, t) {
|
|
983
|
+
let e = !1;
|
|
984
|
+
const { x: o, y: r } = n, i = t.length;
|
|
985
|
+
for (let c = 0, a = i - 1; c < i; a = c++) {
|
|
986
|
+
const m = t[c].x, u = t[c].y, f = t[a].x, g = t[a].y;
|
|
987
|
+
u > r != g > r && o < (f - m) * (r - u) / (g - u) + m && (e = !e);
|
|
988
|
+
}
|
|
989
|
+
return e;
|
|
990
|
+
}
|
|
991
|
+
function Xe(n) {
|
|
992
|
+
const t = ["B", "KB", "MB", "GB", "TB", "PB"];
|
|
993
|
+
let e = 0;
|
|
863
994
|
for (; n > 1024; )
|
|
864
|
-
n /= 1024,
|
|
865
|
-
return `${Math.round(n * 100) / 100} ${e
|
|
995
|
+
n /= 1024, e++;
|
|
996
|
+
return `${Math.round(n * 100) / 100} ${t[e]}`;
|
|
997
|
+
}
|
|
998
|
+
class k {
|
|
999
|
+
constructor(t, e) {
|
|
1000
|
+
y(this, "resolve");
|
|
1001
|
+
y(this, "reject");
|
|
1002
|
+
this.resolve = t, this.reject = e;
|
|
1003
|
+
}
|
|
1004
|
+
run(t) {
|
|
1005
|
+
var e, o;
|
|
1006
|
+
return t instanceof Promise ? t.then((r) => {
|
|
1007
|
+
var i;
|
|
1008
|
+
return (i = this.resolve) == null || i.call(this), r;
|
|
1009
|
+
}).catch((r) => {
|
|
1010
|
+
var i;
|
|
1011
|
+
return (i = this.reject) == null || i.call(this), Promise.reject(r);
|
|
1012
|
+
}) : t ? (e = this.resolve) == null || e.call(this) : (o = this.reject) == null || o.call(this), t;
|
|
1013
|
+
}
|
|
866
1014
|
}
|
|
1015
|
+
class se extends k {
|
|
1016
|
+
constructor(t) {
|
|
1017
|
+
super(), this.resolve = t;
|
|
1018
|
+
}
|
|
1019
|
+
warning(...t) {
|
|
1020
|
+
const e = () => {
|
|
1021
|
+
var o, r;
|
|
1022
|
+
return (r = (o = S.tips).warning) == null ? void 0 : r.call(o, ...t);
|
|
1023
|
+
};
|
|
1024
|
+
return new k(this.resolve, e);
|
|
1025
|
+
}
|
|
1026
|
+
error(...t) {
|
|
1027
|
+
const e = () => {
|
|
1028
|
+
var o, r;
|
|
1029
|
+
return (r = (o = S.tips).error) == null ? void 0 : r.call(o, ...t);
|
|
1030
|
+
};
|
|
1031
|
+
return new k(this.resolve, e);
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
class ce extends k {
|
|
1035
|
+
constructor(t) {
|
|
1036
|
+
super(), this.reject = t;
|
|
1037
|
+
}
|
|
1038
|
+
info(...t) {
|
|
1039
|
+
const e = () => {
|
|
1040
|
+
var o, r;
|
|
1041
|
+
return (r = (o = S.tips).info) == null ? void 0 : r.call(o, ...t);
|
|
1042
|
+
};
|
|
1043
|
+
return new k(e, this.reject);
|
|
1044
|
+
}
|
|
1045
|
+
success(...t) {
|
|
1046
|
+
const e = () => {
|
|
1047
|
+
var o, r;
|
|
1048
|
+
return (r = (o = S.tips).success) == null ? void 0 : r.call(o, ...t);
|
|
1049
|
+
};
|
|
1050
|
+
return new k(e, this.reject);
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
const h = class h {
|
|
1054
|
+
/**
|
|
1055
|
+
* 构造函数
|
|
1056
|
+
* @throws 如果尝试实例化该类,则抛出错误,因为应该使用静态方法
|
|
1057
|
+
*/
|
|
1058
|
+
constructor() {
|
|
1059
|
+
if (new.target === h)
|
|
1060
|
+
throw new Error("请直接使用静态方法,而不是实例化此类");
|
|
1061
|
+
}
|
|
1062
|
+
static register(t, e) {
|
|
1063
|
+
if (typeof e != "function")
|
|
1064
|
+
return console.error("TipHandler must be a function");
|
|
1065
|
+
h.tips[t] = e;
|
|
1066
|
+
}
|
|
1067
|
+
static resolveTip(t) {
|
|
1068
|
+
return function(...e) {
|
|
1069
|
+
const o = () => {
|
|
1070
|
+
var r, i;
|
|
1071
|
+
return (i = (r = h.tips)[t]) == null ? void 0 : i.call(r, ...e);
|
|
1072
|
+
};
|
|
1073
|
+
return new se(o);
|
|
1074
|
+
};
|
|
1075
|
+
}
|
|
1076
|
+
static rejectTip(t) {
|
|
1077
|
+
return function(...e) {
|
|
1078
|
+
const o = () => {
|
|
1079
|
+
var r, i;
|
|
1080
|
+
return (i = (r = h.tips)[t]) == null ? void 0 : i.call(r, ...e);
|
|
1081
|
+
};
|
|
1082
|
+
return new ce(o);
|
|
1083
|
+
};
|
|
1084
|
+
}
|
|
1085
|
+
};
|
|
1086
|
+
y(h, "tips", {
|
|
1087
|
+
info: void 0,
|
|
1088
|
+
success: void 0,
|
|
1089
|
+
warning: void 0,
|
|
1090
|
+
error: void 0
|
|
1091
|
+
}), y(h, "info", h.resolveTip("info")), y(h, "success", h.resolveTip("success")), y(h, "warning", h.rejectTip("warning")), y(h, "error", h.rejectTip("error"));
|
|
1092
|
+
let S = h;
|
|
867
1093
|
export {
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
1094
|
+
Se as _CalculateCanvasSize,
|
|
1095
|
+
he as _CapitalizeFirstLetter,
|
|
1096
|
+
Me as _CheckConnectionWithXHR,
|
|
1097
|
+
ke as _Clone,
|
|
1098
|
+
ze as _CloseOnOutsideClick,
|
|
1099
|
+
ve as _ConvertToCamelCase,
|
|
1100
|
+
Ne as _ConvertToPercentage,
|
|
1101
|
+
Ce as _CopyToClipboard,
|
|
1102
|
+
be as _CreateAndDownloadFile,
|
|
1103
|
+
Ue as _Danger_ConvertDataToImageUrl,
|
|
1104
|
+
G as _DataType,
|
|
1105
|
+
ne as _Debounce,
|
|
1106
|
+
we as _DownloadFile,
|
|
1107
|
+
De as _Drag,
|
|
1108
|
+
oe as _EnterFullscreen,
|
|
1109
|
+
fe as _ExcludeSubstring,
|
|
1110
|
+
me as _ExecuteWhenIdle,
|
|
1111
|
+
re as _ExitFullscreen,
|
|
1112
|
+
V as _FileTypeChecker,
|
|
1113
|
+
Xe as _FormatFileSize,
|
|
1114
|
+
Ye as _FormatNumber,
|
|
1115
|
+
Be as _FormatNumberWithUnit,
|
|
1116
|
+
Oe as _Fullscreen,
|
|
1117
|
+
ye as _GenerateUUID,
|
|
1118
|
+
xe as _GetFrameRate,
|
|
1119
|
+
B as _GetHrefName,
|
|
1120
|
+
_e as _GetOtherSizeInPixels,
|
|
1121
|
+
Le as _GetTargetByPath,
|
|
1122
|
+
Fe as _InitTargetByPath,
|
|
1123
|
+
ie as _IsFullscreen,
|
|
1124
|
+
ue as _IsObject,
|
|
1125
|
+
He as _IsPointInPolygon,
|
|
1126
|
+
Re as _IsSecureContext,
|
|
1127
|
+
qe as _IsWithinErrorMargin,
|
|
1128
|
+
Z as _KeyedWindowManager,
|
|
1129
|
+
Ae as _LoadImage,
|
|
1130
|
+
Ie as _LocalDrag,
|
|
1131
|
+
Y as _MergeObjects,
|
|
1132
|
+
le as _NotNull,
|
|
1133
|
+
ge as _ReadFile,
|
|
1134
|
+
Te as _RotateList,
|
|
1135
|
+
$e as _Schedule,
|
|
1136
|
+
Pe as _ScrollEndListener,
|
|
1137
|
+
Ee as _Throttle,
|
|
1138
|
+
pe as _TimeTransition,
|
|
1139
|
+
S as _Tip,
|
|
1140
|
+
je as _UpdateTargetByPath,
|
|
1141
|
+
de as _WaitForCondition
|
|
912
1142
|
};
|