@yh-kit/utils 1.11.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/utils.js +142 -133
- package/dist/utils.umd.cjs +1 -1
- package/package.json +1 -1
- package/types/utils/lib/download/index.d.ts +6 -0
package/dist/utils.js
CHANGED
|
@@ -2,13 +2,13 @@ const w = (e) => {
|
|
|
2
2
|
if (!e || !e.length) return {};
|
|
3
3
|
const n = {};
|
|
4
4
|
return e.forEach((t) => {
|
|
5
|
-
const
|
|
6
|
-
n[t?.value] =
|
|
5
|
+
const o = Object.assign({ label: t.label, text: t.label }, t);
|
|
6
|
+
n[t?.value] = o;
|
|
7
7
|
}), n;
|
|
8
|
-
},
|
|
8
|
+
}, b = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
9
9
|
__proto__: null,
|
|
10
10
|
toEnumObj: w
|
|
11
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
11
|
+
}, Symbol.toStringTag, { value: "Module" })), A = Object.assign(
|
|
12
12
|
{
|
|
13
13
|
/**
|
|
14
14
|
* 数组去重
|
|
@@ -35,8 +35,8 @@ const w = (e) => {
|
|
|
35
35
|
*/
|
|
36
36
|
countOfAppear(e, n) {
|
|
37
37
|
let t = 0;
|
|
38
|
-
for (const
|
|
39
|
-
|
|
38
|
+
for (const o of e)
|
|
39
|
+
o === n && t++;
|
|
40
40
|
return t;
|
|
41
41
|
},
|
|
42
42
|
/**
|
|
@@ -47,11 +47,11 @@ const w = (e) => {
|
|
|
47
47
|
*/
|
|
48
48
|
indexsOfAppear(e, n) {
|
|
49
49
|
let t = -1;
|
|
50
|
-
const
|
|
50
|
+
const o = [];
|
|
51
51
|
do
|
|
52
|
-
t = e.indexOf(n, t + 1), t !== -1 &&
|
|
52
|
+
t = e.indexOf(n, t + 1), t !== -1 && o.push(t);
|
|
53
53
|
while (t !== -1);
|
|
54
|
-
return
|
|
54
|
+
return o;
|
|
55
55
|
},
|
|
56
56
|
/**
|
|
57
57
|
* 数组排序-默认升序
|
|
@@ -60,7 +60,7 @@ const w = (e) => {
|
|
|
60
60
|
* @returns 排序后的数组
|
|
61
61
|
*/
|
|
62
62
|
sort(e, n = "asc") {
|
|
63
|
-
return e ? e.sort((t,
|
|
63
|
+
return e ? e.sort((t, o) => n === "asc" ? t > o ? 1 : -1 : t < o ? 1 : -1) : [];
|
|
64
64
|
},
|
|
65
65
|
/**
|
|
66
66
|
* 数组乱序(洗牌算法)
|
|
@@ -111,9 +111,9 @@ const w = (e) => {
|
|
|
111
111
|
/** 最小值索引 */
|
|
112
112
|
index: 0
|
|
113
113
|
};
|
|
114
|
-
for (let t = 1,
|
|
115
|
-
const
|
|
116
|
-
n.value >
|
|
114
|
+
for (let t = 1, o = e.length; t < o; t++) {
|
|
115
|
+
const r = e[t];
|
|
116
|
+
n.value > r && (n.value = r, n.index = t);
|
|
117
117
|
}
|
|
118
118
|
return n;
|
|
119
119
|
},
|
|
@@ -124,16 +124,16 @@ const w = (e) => {
|
|
|
124
124
|
*/
|
|
125
125
|
getMaxValueAndIndex(e) {
|
|
126
126
|
return e.length === 0 ? { value: 0, index: 0 } : e.reduce(
|
|
127
|
-
(n, t,
|
|
127
|
+
(n, t, o) => t < n.value ? { value: t, index: o } : n,
|
|
128
128
|
{ value: e[0], index: 0 }
|
|
129
129
|
);
|
|
130
130
|
}
|
|
131
131
|
},
|
|
132
132
|
{
|
|
133
|
-
...
|
|
133
|
+
...b
|
|
134
134
|
}
|
|
135
135
|
);
|
|
136
|
-
class
|
|
136
|
+
class U {
|
|
137
137
|
/** Base64 编码表 */
|
|
138
138
|
static BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
139
139
|
/**
|
|
@@ -145,12 +145,12 @@ class T {
|
|
|
145
145
|
* @param sliceSize 可选参数,表示分片大小,默认为512字节。用于控制每次处理的Base64字符串长度,以优化大文件的处理。
|
|
146
146
|
* @returns 返回转换后的Blob对象,如果转换失败,则返回null。
|
|
147
147
|
*/
|
|
148
|
-
static toBlob(n, t = "",
|
|
148
|
+
static toBlob(n, t = "", o = 512) {
|
|
149
149
|
const s = (n.split(",")[1] || n).replace(/-/g, "+").replace(/_/g, "/"), a = "=".repeat((4 - s.length % 4) % 4), u = s + a;
|
|
150
150
|
try {
|
|
151
151
|
const i = atob(u), d = [];
|
|
152
|
-
for (let c = 0; c < i.length; c +=
|
|
153
|
-
const l = i.slice(c, c +
|
|
152
|
+
for (let c = 0; c < i.length; c += o) {
|
|
153
|
+
const l = i.slice(c, c + o), h = new Array(l.length);
|
|
154
154
|
for (let f = 0; f < l.length; f++)
|
|
155
155
|
h[f] = l.charCodeAt(f);
|
|
156
156
|
const p = new Uint8Array(h);
|
|
@@ -171,7 +171,7 @@ class T {
|
|
|
171
171
|
* @param mimeType MIME类型,默认为"text/plain"。
|
|
172
172
|
* @returns 返回一个File对象,包含解码后的数据。
|
|
173
173
|
*/
|
|
174
|
-
static toFile(n, t = "file.txt",
|
|
174
|
+
static toFile(n, t = "file.txt", o = "text/plain") {
|
|
175
175
|
const s = n.replace(/^data:.+;base64,/, "").replace(/-/g, "+").replace(/_/g, "/"), a = "=".repeat((4 - s.length % 4) % 4), u = s + a, i = atob(u), d = [];
|
|
176
176
|
for (let l = 0; l < i.length; l += 512) {
|
|
177
177
|
const h = i.slice(l, l + 512), p = new Array(h.length);
|
|
@@ -179,8 +179,8 @@ class T {
|
|
|
179
179
|
p[f] = h.charCodeAt(f);
|
|
180
180
|
d.push(new Uint8Array(p));
|
|
181
181
|
}
|
|
182
|
-
const c = new Blob(d, { type:
|
|
183
|
-
return new File([c], t, { type:
|
|
182
|
+
const c = new Blob(d, { type: o });
|
|
183
|
+
return new File([c], t, { type: o });
|
|
184
184
|
}
|
|
185
185
|
/**
|
|
186
186
|
* base64加密 -- 普通字符串转 Base64 编码
|
|
@@ -208,20 +208,20 @@ class T {
|
|
|
208
208
|
*/
|
|
209
209
|
static _stringToUtf8Bytes(n) {
|
|
210
210
|
const t = [];
|
|
211
|
-
for (let
|
|
212
|
-
let
|
|
213
|
-
if (
|
|
214
|
-
t.push(
|
|
215
|
-
else if (
|
|
216
|
-
t.push(192 |
|
|
217
|
-
else if (
|
|
218
|
-
t.push(224 |
|
|
211
|
+
for (let o = 0; o < n.length; o++) {
|
|
212
|
+
let r = n.charCodeAt(o);
|
|
213
|
+
if (r < 128)
|
|
214
|
+
t.push(r);
|
|
215
|
+
else if (r < 2048)
|
|
216
|
+
t.push(192 | r >> 6), t.push(128 | r & 63);
|
|
217
|
+
else if (r < 55296 || r >= 57344)
|
|
218
|
+
t.push(224 | r >> 12), t.push(128 | r >> 6 & 63), t.push(128 | r & 63);
|
|
219
219
|
else {
|
|
220
|
-
|
|
221
|
-
const s =
|
|
220
|
+
o++;
|
|
221
|
+
const s = r, a = n.charCodeAt(o);
|
|
222
222
|
if (isNaN(a))
|
|
223
223
|
throw new Error("代理对不完整");
|
|
224
|
-
|
|
224
|
+
r = 65536 + ((s & 1023) << 10) + (a & 1023), t.push(240 | r >> 18), t.push(128 | r >> 12 & 63), t.push(128 | r >> 6 & 63), t.push(128 | r & 63);
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
227
|
return t;
|
|
@@ -230,19 +230,19 @@ class T {
|
|
|
230
230
|
* UTF-8 字节数组转字符串
|
|
231
231
|
*/
|
|
232
232
|
static _utf8BytesToString(n) {
|
|
233
|
-
let t = "",
|
|
234
|
-
for (;
|
|
235
|
-
const
|
|
236
|
-
if (
|
|
237
|
-
t += String.fromCharCode(
|
|
238
|
-
else if (
|
|
239
|
-
const s = n[
|
|
240
|
-
t += String.fromCharCode((
|
|
241
|
-
} else if (
|
|
242
|
-
const s = n[
|
|
243
|
-
t += String.fromCharCode((
|
|
244
|
-
} else if (
|
|
245
|
-
const s = n[
|
|
233
|
+
let t = "", o = 0;
|
|
234
|
+
for (; o < n.length; ) {
|
|
235
|
+
const r = n[o++];
|
|
236
|
+
if (r < 128)
|
|
237
|
+
t += String.fromCharCode(r);
|
|
238
|
+
else if (r >= 192 && r < 224) {
|
|
239
|
+
const s = n[o++] & 63;
|
|
240
|
+
t += String.fromCharCode((r & 31) << 6 | s);
|
|
241
|
+
} else if (r >= 224 && r < 240) {
|
|
242
|
+
const s = n[o++] & 63, a = n[o++] & 63;
|
|
243
|
+
t += String.fromCharCode((r & 15) << 12 | s << 6 | a);
|
|
244
|
+
} else if (r >= 240 && r < 248) {
|
|
245
|
+
const s = n[o++] & 63, a = n[o++] & 63, u = n[o++] & 63, i = (r & 7) << 18 | s << 12 | a << 6 | u, d = Math.floor((i - 65536) / 1024) + 55296, c = (i - 65536) % 1024 + 56320;
|
|
246
246
|
t += String.fromCharCode(d, c);
|
|
247
247
|
} else
|
|
248
248
|
t += "�";
|
|
@@ -253,9 +253,9 @@ class T {
|
|
|
253
253
|
* 字节数组转 Base64 编码
|
|
254
254
|
*/
|
|
255
255
|
static _bytesToBase64(n) {
|
|
256
|
-
let t = "",
|
|
257
|
-
for (;
|
|
258
|
-
const
|
|
256
|
+
let t = "", o = 0;
|
|
257
|
+
for (; o < n.length; ) {
|
|
258
|
+
const r = n[o++], s = o < n.length, a = s ? n[o++] : 0, u = o < n.length, i = u ? n[o++] : 0, d = r >> 2, c = (r & 3) << 4 | a >> 4, l = (a & 15) << 2 | i >> 6, h = i & 63;
|
|
259
259
|
s ? u ? t += this.BASE64_CHARS.charAt(d) + this.BASE64_CHARS.charAt(c) + this.BASE64_CHARS.charAt(l) + this.BASE64_CHARS.charAt(h) : t += this.BASE64_CHARS.charAt(d) + this.BASE64_CHARS.charAt(c) + this.BASE64_CHARS.charAt(l) + "=" : t += this.BASE64_CHARS.charAt(d) + this.BASE64_CHARS.charAt(c) + "==";
|
|
260
260
|
}
|
|
261
261
|
return t;
|
|
@@ -265,9 +265,9 @@ class T {
|
|
|
265
265
|
*/
|
|
266
266
|
static _base64ToBytes(n) {
|
|
267
267
|
const t = n.length;
|
|
268
|
-
let
|
|
269
|
-
t >= 2 && (n[t - 1] === "=" &&
|
|
270
|
-
const
|
|
268
|
+
let o = 0;
|
|
269
|
+
t >= 2 && (n[t - 1] === "=" && o++, n[t - 2] === "=" && o++);
|
|
270
|
+
const r = Math.floor(t * 3 / 4) - o, s = new Array(r), a = new Array(256).fill(-1);
|
|
271
271
|
for (let d = 0; d < this.BASE64_CHARS.length; d++)
|
|
272
272
|
a[this.BASE64_CHARS.charCodeAt(d)] = d;
|
|
273
273
|
let u = 0, i = 0;
|
|
@@ -450,8 +450,8 @@ const S = {
|
|
|
450
450
|
* @returns void
|
|
451
451
|
*/
|
|
452
452
|
setCookie(e, n, t = 7) {
|
|
453
|
-
const
|
|
454
|
-
|
|
453
|
+
const o = /* @__PURE__ */ new Date();
|
|
454
|
+
o.setTime(o.getTime() + t * 24 * 60 * 60 * 1e3), document.cookie = `${e}=${encodeURIComponent(n)};expires=${o.toUTCString()};path=/`;
|
|
455
455
|
},
|
|
456
456
|
/**
|
|
457
457
|
* 删除cookie
|
|
@@ -461,7 +461,7 @@ const S = {
|
|
|
461
461
|
deleteCookie(e) {
|
|
462
462
|
this.setCookie(e, "", -1);
|
|
463
463
|
}
|
|
464
|
-
},
|
|
464
|
+
}, T = {
|
|
465
465
|
/**
|
|
466
466
|
* 获取当前时间字符串
|
|
467
467
|
* @param locales 区域设置。如:'zh-CN','en-US',"chinese"。默认'zh-CN'。
|
|
@@ -478,8 +478,8 @@ const S = {
|
|
|
478
478
|
* @returns 相差天数
|
|
479
479
|
*/
|
|
480
480
|
diffDays(e, n) {
|
|
481
|
-
const t = new Date(e).getTime(),
|
|
482
|
-
return t >
|
|
481
|
+
const t = new Date(e).getTime(), o = new Date(n).getTime();
|
|
482
|
+
return t > o ? Math.abs(Math.floor((t - o) / (24 * 3600 * 1e3))) : Math.abs(Math.floor((o - t) / (24 * 3600 * 1e3)));
|
|
483
483
|
},
|
|
484
484
|
/**
|
|
485
485
|
* 生成唯一ID(时间戳+随机数)
|
|
@@ -496,9 +496,9 @@ const S = {
|
|
|
496
496
|
* @returns 当年的第几天
|
|
497
497
|
*/
|
|
498
498
|
getWhichDays(e, n, t) {
|
|
499
|
-
let
|
|
500
|
-
for (let
|
|
501
|
-
switch (
|
|
499
|
+
let o = t;
|
|
500
|
+
for (let r = 1; r < n; r++)
|
|
501
|
+
switch (r) {
|
|
502
502
|
case 1:
|
|
503
503
|
case 3:
|
|
504
504
|
case 5:
|
|
@@ -506,16 +506,16 @@ const S = {
|
|
|
506
506
|
case 8:
|
|
507
507
|
case 10:
|
|
508
508
|
case 12:
|
|
509
|
-
|
|
509
|
+
o += 31;
|
|
510
510
|
break;
|
|
511
511
|
case 2:
|
|
512
|
-
S.isLeapYear(e) ?
|
|
512
|
+
S.isLeapYear(e) ? o += 29 : o += 28;
|
|
513
513
|
break;
|
|
514
514
|
default:
|
|
515
|
-
|
|
515
|
+
o += 30;
|
|
516
516
|
break;
|
|
517
517
|
}
|
|
518
|
-
return
|
|
518
|
+
return o;
|
|
519
519
|
},
|
|
520
520
|
/**
|
|
521
521
|
* 获取时间字符串(自动短化)
|
|
@@ -524,13 +524,13 @@ const S = {
|
|
|
524
524
|
* @returns 时间字符串
|
|
525
525
|
*/
|
|
526
526
|
getTimeStringAutoShort2(e, n) {
|
|
527
|
-
const t = /* @__PURE__ */ new Date(),
|
|
527
|
+
const t = /* @__PURE__ */ new Date(), o = new Date(e), r = t.getFullYear(), s = t.getMonth() + 1, a = t.getDate(), u = o.getFullYear(), i = o.getMonth() + 1, d = o.getDate();
|
|
528
528
|
let c = "";
|
|
529
|
-
const l = n ? " " + this.formatDate(
|
|
530
|
-
if (
|
|
529
|
+
const l = n ? " " + this.formatDate(o, "hh:mm") : "";
|
|
530
|
+
if (r === u) {
|
|
531
531
|
const f = t.getTime() - e;
|
|
532
532
|
if (s === i && a === d)
|
|
533
|
-
f < 60 * 1e3 ? c = "刚刚" : c = this.formatDate(
|
|
533
|
+
f < 60 * 1e3 ? c = "刚刚" : c = this.formatDate(o, "hh:mm");
|
|
534
534
|
else {
|
|
535
535
|
const g = /* @__PURE__ */ new Date();
|
|
536
536
|
g.setDate(g.getDate() - 1);
|
|
@@ -541,11 +541,11 @@ const S = {
|
|
|
541
541
|
c = "前天" + l;
|
|
542
542
|
else if (f / 36e5 <= 7 * 24) {
|
|
543
543
|
const y = new Array(7);
|
|
544
|
-
y[0] = "星期日", y[1] = "星期一", y[2] = "星期二", y[3] = "星期三", y[4] = "星期四", y[5] = "星期五", y[6] = "星期六", c = y[
|
|
545
|
-
} else c = this.formatDate(
|
|
544
|
+
y[0] = "星期日", y[1] = "星期一", y[2] = "星期二", y[3] = "星期三", y[4] = "星期四", y[5] = "星期五", y[6] = "星期六", c = y[o.getDay()] + l;
|
|
545
|
+
} else c = this.formatDate(o, "yyyy/M/d") + l;
|
|
546
546
|
}
|
|
547
547
|
} else
|
|
548
|
-
c = this.formatDate(
|
|
548
|
+
c = this.formatDate(o, "yyyy/M/d") + l;
|
|
549
549
|
return c;
|
|
550
550
|
},
|
|
551
551
|
/**
|
|
@@ -572,8 +572,8 @@ const S = {
|
|
|
572
572
|
//毫秒
|
|
573
573
|
};
|
|
574
574
|
/(y+)/.test(n) && (n = n.replace(RegExp.$1, (e.getFullYear() + "").substr(4 - RegExp.$1.length)));
|
|
575
|
-
for (const
|
|
576
|
-
new RegExp("(" +
|
|
575
|
+
for (const o in t)
|
|
576
|
+
new RegExp("(" + o + ")").test(n) && (n = n.replace(RegExp.$1, RegExp.$1.length === 1 ? t[o] : ("00" + t[o]).substr(("" + t[o]).length)));
|
|
577
577
|
return n;
|
|
578
578
|
}
|
|
579
579
|
}, L = {
|
|
@@ -587,8 +587,8 @@ const S = {
|
|
|
587
587
|
if (!e)
|
|
588
588
|
throw new Error("Element is not provided");
|
|
589
589
|
if (e instanceof SVGElement) {
|
|
590
|
-
const t = e.getBoundingClientRect(),
|
|
591
|
-
return t.top +
|
|
590
|
+
const t = e.getBoundingClientRect(), o = window.pageYOffset || document.documentElement.scrollTop;
|
|
591
|
+
return t.top + o;
|
|
592
592
|
}
|
|
593
593
|
let n = 0;
|
|
594
594
|
for (; e; )
|
|
@@ -654,10 +654,19 @@ const S = {
|
|
|
654
654
|
* @param filename 文件名
|
|
655
655
|
*/
|
|
656
656
|
saveAsBlob(e, n) {
|
|
657
|
-
const t = document.createElement("a"),
|
|
658
|
-
t.href =
|
|
657
|
+
const t = document.createElement("a"), o = window.URL.createObjectURL(e);
|
|
658
|
+
t.href = o, t.download = n, document.body.appendChild(t), t.click(), URL.revokeObjectURL(o), document.body.removeChild(t);
|
|
659
|
+
},
|
|
660
|
+
/**
|
|
661
|
+
* 直接下载url
|
|
662
|
+
* @param url 下载url
|
|
663
|
+
* @param filename 文件名
|
|
664
|
+
*/
|
|
665
|
+
saveAsUrl(e, n) {
|
|
666
|
+
const t = document.createElement("a");
|
|
667
|
+
t.href = e, t.download = n, document.body.appendChild(t), t.click(), URL.revokeObjectURL(e), document.body.removeChild(t);
|
|
659
668
|
}
|
|
660
|
-
},
|
|
669
|
+
}, k = {
|
|
661
670
|
/**
|
|
662
671
|
* echarts动画函数
|
|
663
672
|
* @param option echarts配置
|
|
@@ -665,14 +674,14 @@ const S = {
|
|
|
665
674
|
*/
|
|
666
675
|
animate(e, n) {
|
|
667
676
|
let t = -1;
|
|
668
|
-
const
|
|
669
|
-
let
|
|
670
|
-
|
|
677
|
+
const o = e.series[0].data.length;
|
|
678
|
+
let r;
|
|
679
|
+
r = setInterval(() => {
|
|
671
680
|
n.dispatchAction({
|
|
672
681
|
type: "downplay",
|
|
673
682
|
seriesIndex: 0,
|
|
674
683
|
dataIndex: t
|
|
675
|
-
}), t = (t + 1) %
|
|
684
|
+
}), t = (t + 1) % o, n.dispatchAction({
|
|
676
685
|
type: "highlight",
|
|
677
686
|
seriesIndex: 0,
|
|
678
687
|
dataIndex: t
|
|
@@ -680,28 +689,28 @@ const S = {
|
|
|
680
689
|
type: "showTip",
|
|
681
690
|
seriesIndex: 0,
|
|
682
691
|
dataIndex: t
|
|
683
|
-
}), t >
|
|
692
|
+
}), t > o && (t = 0);
|
|
684
693
|
}, 2e3), n.on("mouseover", () => {
|
|
685
|
-
clearInterval(
|
|
694
|
+
clearInterval(r), n.dispatchAction({
|
|
686
695
|
type: "downplay",
|
|
687
696
|
seriesIndex: 0,
|
|
688
697
|
dataIndex: t
|
|
689
698
|
});
|
|
690
699
|
});
|
|
691
700
|
}
|
|
692
|
-
},
|
|
701
|
+
}, H = {
|
|
693
702
|
/**
|
|
694
703
|
* 将选中的字母数组从A-Z排序:用于试题选择答案的排序实例
|
|
695
704
|
* @param arr 字母数组
|
|
696
705
|
* @returns
|
|
697
706
|
*/
|
|
698
707
|
sortFromA2Z(e) {
|
|
699
|
-
return e?.length ? e.sort((t,
|
|
700
|
-
const
|
|
701
|
-
return
|
|
708
|
+
return e?.length ? e.sort((t, o) => {
|
|
709
|
+
const r = t.toUpperCase(), s = o.toUpperCase();
|
|
710
|
+
return r < s ? -1 : r > s ? 1 : 0;
|
|
702
711
|
}) : void 0;
|
|
703
712
|
}
|
|
704
|
-
},
|
|
713
|
+
}, j = {
|
|
705
714
|
/**
|
|
706
715
|
* 角度(度数)转弧度
|
|
707
716
|
* 在数学和编程里,角度有两种常用单位,分别是度(°)和弧度(rad)。
|
|
@@ -721,11 +730,11 @@ const S = {
|
|
|
721
730
|
* @param targetLng 目标经度
|
|
722
731
|
* @returns 距离值 单位:km
|
|
723
732
|
*/
|
|
724
|
-
getDistance(e, n, t,
|
|
725
|
-
const
|
|
733
|
+
getDistance(e, n, t, o) {
|
|
734
|
+
const r = this.degrees2Radians(e), s = this.degrees2Radians(t), a = r - s, u = this.degrees2Radians(n) - this.degrees2Radians(o);
|
|
726
735
|
let i = 2 * Math.asin(
|
|
727
736
|
Math.sqrt(
|
|
728
|
-
Math.pow(Math.sin(a / 2), 2) + Math.cos(
|
|
737
|
+
Math.pow(Math.sin(a / 2), 2) + Math.cos(r) * Math.cos(s) * Math.pow(Math.sin(u / 2), 2)
|
|
729
738
|
)
|
|
730
739
|
);
|
|
731
740
|
return i = i * 6378.137, i = Math.round(i * 1e4) / 1e4, i = +i.toFixed(2), console.log("经纬度计算的距离为:" + i), i;
|
|
@@ -746,10 +755,10 @@ const S = {
|
|
|
746
755
|
* @returns 距离值
|
|
747
756
|
*/
|
|
748
757
|
calculateDistanceByHaversine(e, n, t = "km") {
|
|
749
|
-
const
|
|
750
|
-
if (
|
|
758
|
+
const o = this, r = e.longitude ?? e.lng, s = e.latitude ?? e.lat, a = n.longitude ?? n.lng, u = n.latitude ?? n.lat;
|
|
759
|
+
if (r === void 0 || s === void 0 || a === void 0 || u === void 0)
|
|
751
760
|
throw new Error("无效的坐标格式,缺少经纬度信息");
|
|
752
|
-
const i = 6371, d =
|
|
761
|
+
const i = 6371, d = o.degrees2Radians(s), c = o.degrees2Radians(u), l = o.degrees2Radians(u - s), h = o.degrees2Radians(a - r), p = Math.sin(l / 2) * Math.sin(l / 2) + Math.cos(d) * Math.cos(c) * Math.sin(h / 2) * Math.sin(h / 2), f = 2 * Math.atan2(Math.sqrt(p), Math.sqrt(1 - p)), g = i * f;
|
|
753
762
|
switch (t) {
|
|
754
763
|
case "m":
|
|
755
764
|
return g * 1e3;
|
|
@@ -774,17 +783,17 @@ const S = {
|
|
|
774
783
|
calculateDistancesByHaversine(e, n = "km", t = !1) {
|
|
775
784
|
if (e.length < 2)
|
|
776
785
|
return { segments: [], total: 0 };
|
|
777
|
-
const
|
|
778
|
-
let
|
|
786
|
+
const o = [];
|
|
787
|
+
let r = 0;
|
|
779
788
|
for (let s = 0; s < e.length - 1; s++) {
|
|
780
789
|
const a = this.calculateDistanceByHaversine(e[s], e[s + 1], n);
|
|
781
|
-
|
|
790
|
+
o.push(a), r += a;
|
|
782
791
|
}
|
|
783
792
|
if (t && e.length > 2) {
|
|
784
793
|
const s = this.calculateDistanceByHaversine(e[e.length - 1], e[0], n);
|
|
785
|
-
|
|
794
|
+
o.push(s), r += s;
|
|
786
795
|
}
|
|
787
|
-
return { segments:
|
|
796
|
+
return { segments: o, total: r };
|
|
788
797
|
}
|
|
789
798
|
};
|
|
790
799
|
class $ {
|
|
@@ -817,7 +826,7 @@ class $ {
|
|
|
817
826
|
throw new Error("输入不是有效的数字");
|
|
818
827
|
if (t > 9999999999999e-2 || t < -9999999999999e-2)
|
|
819
828
|
throw new Error("输入数字超出范围");
|
|
820
|
-
const
|
|
829
|
+
const o = t < 0, r = Math.abs(t), s = Math.floor(r), a = Math.round((r - s) * 100), u = ["零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"], i = ["", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾", "佰", "仟"], d = ["角", "分"];
|
|
821
830
|
let c = "", l = s;
|
|
822
831
|
if (l === 0)
|
|
823
832
|
c = u[0];
|
|
@@ -835,7 +844,7 @@ class $ {
|
|
|
835
844
|
f > 0 && (h += u[f] + d[0]), g > 0 && (h += u[g] + d[1]);
|
|
836
845
|
} else
|
|
837
846
|
h = "整";
|
|
838
|
-
let p = (
|
|
847
|
+
let p = (o ? "负" : "") + c + "圆" + h;
|
|
839
848
|
return p === "零圆整" && (p = "零圆"), p;
|
|
840
849
|
} catch (t) {
|
|
841
850
|
return console.error("转换失败:", t), "格式错误";
|
|
@@ -845,12 +854,12 @@ class $ {
|
|
|
845
854
|
const M = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], x = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
846
855
|
__proto__: null,
|
|
847
856
|
toLetter: M
|
|
848
|
-
}, Symbol.toStringTag, { value: "Module" })), E = (e) => e.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","),
|
|
857
|
+
}, Symbol.toStringTag, { value: "Module" })), E = (e) => e.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","), C = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
849
858
|
__proto__: null,
|
|
850
859
|
toMoney: E
|
|
851
860
|
}, Symbol.toStringTag, { value: "Module" })), N = {
|
|
852
861
|
...x,
|
|
853
|
-
...
|
|
862
|
+
...C,
|
|
854
863
|
/**
|
|
855
864
|
* 判断是否为数字
|
|
856
865
|
* @param val 待判断的值
|
|
@@ -886,8 +895,8 @@ const M = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], x = /*
|
|
|
886
895
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
887
896
|
deepCopy(e, n) {
|
|
888
897
|
for (const t in e) {
|
|
889
|
-
const
|
|
890
|
-
|
|
898
|
+
const o = e[t];
|
|
899
|
+
o instanceof Object ? (n[t] = {}, this.deepCopy(o, n[t])) : o instanceof Array ? (n[t] = [], this.deepCopy(o, n[t])) : n[t] = e[t];
|
|
891
900
|
}
|
|
892
901
|
}
|
|
893
902
|
}, F = {
|
|
@@ -1049,11 +1058,11 @@ const M = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], x = /*
|
|
|
1049
1058
|
*/
|
|
1050
1059
|
indexsOfAppear(e, n) {
|
|
1051
1060
|
let t = -1;
|
|
1052
|
-
const
|
|
1061
|
+
const o = [];
|
|
1053
1062
|
do
|
|
1054
|
-
t = e.indexOf(n, t + 1), t !== -1 &&
|
|
1063
|
+
t = e.indexOf(n, t + 1), t !== -1 && o.push(t);
|
|
1055
1064
|
while (t !== -1);
|
|
1056
|
-
return
|
|
1065
|
+
return o;
|
|
1057
1066
|
},
|
|
1058
1067
|
/**
|
|
1059
1068
|
* 获取字符串中出现次数最多的字符和次数
|
|
@@ -1066,15 +1075,15 @@ const M = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], x = /*
|
|
|
1066
1075
|
const a = e.charAt(s);
|
|
1067
1076
|
t[a] ? t[a]++ : t[a] = 1;
|
|
1068
1077
|
}
|
|
1069
|
-
let
|
|
1078
|
+
let o = 1;
|
|
1070
1079
|
for (const s in t)
|
|
1071
|
-
|
|
1072
|
-
const
|
|
1080
|
+
o < t[s] && (o = t[s]);
|
|
1081
|
+
const r = [];
|
|
1073
1082
|
for (const s in t)
|
|
1074
|
-
|
|
1075
|
-
return n[0] =
|
|
1083
|
+
o == t[s] && r.push(s);
|
|
1084
|
+
return n[0] = o, n[1] = r.join(), n;
|
|
1076
1085
|
}
|
|
1077
|
-
},
|
|
1086
|
+
}, B = (e) => {
|
|
1078
1087
|
const t = new RegExp("[?&]" + e + "=([^&#]*)", "i").exec(window.location.href);
|
|
1079
1088
|
return t ? decodeURIComponent(t[1]) : null;
|
|
1080
1089
|
};
|
|
@@ -1083,7 +1092,7 @@ function D(e) {
|
|
|
1083
1092
|
}
|
|
1084
1093
|
const R = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1085
1094
|
__proto__: null,
|
|
1086
|
-
getQueryInfoByName:
|
|
1095
|
+
getQueryInfoByName: B,
|
|
1087
1096
|
getQueryParam: D
|
|
1088
1097
|
}, Symbol.toStringTag, { value: "Module" })), q = {
|
|
1089
1098
|
...R,
|
|
@@ -1111,13 +1120,13 @@ const R = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
1111
1120
|
toList(e, n = 2) {
|
|
1112
1121
|
console.log(e, n);
|
|
1113
1122
|
const t = {};
|
|
1114
|
-
for (let
|
|
1115
|
-
t[
|
|
1116
|
-
e.forEach((
|
|
1117
|
-
const
|
|
1118
|
-
for (const
|
|
1119
|
-
|
|
1120
|
-
return
|
|
1123
|
+
for (let r = 0; r < n; r++)
|
|
1124
|
+
t[r] = [];
|
|
1125
|
+
e.forEach((r, s) => t[s % n].push(r));
|
|
1126
|
+
const o = [];
|
|
1127
|
+
for (const r in t)
|
|
1128
|
+
o.push(...t[r]);
|
|
1129
|
+
return o;
|
|
1121
1130
|
},
|
|
1122
1131
|
/**
|
|
1123
1132
|
* js瀑布流布局
|
|
@@ -1126,30 +1135,30 @@ const R = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
1126
1135
|
* @param step 间距
|
|
1127
1136
|
*/
|
|
1128
1137
|
jsLayout(e, n, t) {
|
|
1129
|
-
const
|
|
1138
|
+
const o = e.offsetWidth, r = n[0].offsetWidth, s = parseInt((o / r).toString()), a = (o - r * s) / (s - 1), u = [];
|
|
1130
1139
|
for (let i = 0, d = n.length; i < d; i++) {
|
|
1131
1140
|
const c = n[i];
|
|
1132
1141
|
if (i < s)
|
|
1133
|
-
c.style.left = (
|
|
1142
|
+
c.style.left = (r + a) * i + "px", u[i] = c.offsetHeight;
|
|
1134
1143
|
else {
|
|
1135
|
-
const { index: l, value: h } =
|
|
1136
|
-
c.style.left = (
|
|
1144
|
+
const { index: l, value: h } = A.getMinValueAndIndex(u);
|
|
1145
|
+
c.style.left = (r + a) * l + "px", c.style.top = h + t + "px", u[l] = c.offsetHeight + t + h;
|
|
1137
1146
|
}
|
|
1138
1147
|
}
|
|
1139
1148
|
}
|
|
1140
1149
|
};
|
|
1141
1150
|
export {
|
|
1142
|
-
|
|
1151
|
+
U as Base64Utils,
|
|
1143
1152
|
$ as MoneyFormatter,
|
|
1144
|
-
|
|
1153
|
+
A as arrayUtils,
|
|
1145
1154
|
S as booleanUtils,
|
|
1146
1155
|
O as cookieUtils,
|
|
1147
|
-
|
|
1156
|
+
T as dateUtils,
|
|
1148
1157
|
L as documentUtils,
|
|
1149
1158
|
I as downloadUtils,
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1159
|
+
k as echartsUtils,
|
|
1160
|
+
H as letterUtils,
|
|
1161
|
+
j as mapUtils,
|
|
1153
1162
|
N as numberUtils,
|
|
1154
1163
|
P as objectUtils,
|
|
1155
1164
|
F as phoneUtils,
|
package/dist/utils.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(h,w){typeof exports=="object"&&typeof module<"u"?w(exports):typeof define=="function"&&define.amd?define(["exports"],w):(h=typeof globalThis<"u"?globalThis:h||self,w(h.yhkitUtils={}))})(this,function(h){"use strict";const A=Object.assign({unique(e){return e?Array.from(new Set(e)):[]},isExist(e,n){return!e||!n?!1:e.indexOf(n)!==-1},countOfAppear(e,n){let t=0;for(const o of e)o===n&&t++;return t},indexsOfAppear(e,n){let t=-1;const o=[];do t=e.indexOf(n,t+1),t!==-1&&o.push(t);while(t!==-1);return o},sort(e,n="asc"){return e?e.sort((t,o)=>n==="asc"?t>o?1:-1:t<o?1:-1):[]},shuffle(e){if(!e)return[];for(let n=e.length-1;n>0;n--){const t=Math.floor(Math.random()*(n+1));[e[n],e[t]]=[e[t],e[n]]}return e},getMaxValue(e){return e?Math.max(...e):0},getMinValue(e){return e?Math.min(...e):0},getMinValueAndIndex(e){if(e.length===0)return{value:0,index:0};const n={value:e[0],index:0};for(let t=1,o=e.length;t<o;t++){const r=e[t];n.value>r&&(n.value=r,n.index=t)}return n},getMaxValueAndIndex(e){return e.length===0?{value:0,index:0}:e.reduce((n,t,o)=>t<n.value?{value:t,index:o}:n,{value:e[0],index:0})}},{...Object.freeze(Object.defineProperty({__proto__:null,toEnumObj:e=>{if(!e||!e.length)return{};const n={};return e.forEach(t=>{const o=Object.assign({label:t.label,text:t.label},t);n[t?.value]=o}),n}},Symbol.toStringTag,{value:"Module"}))});class M{static BASE64_CHARS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";static toBlob(n,t="",o=512){const s=(n.split(",")[1]||n).replace(/-/g,"+").replace(/_/g,"/"),c="=".repeat((4-s.length%4)%4),u=s+c;try{const i=atob(u),d=[];for(let a=0;a<i.length;a+=o){const l=i.slice(a,a+o),f=new Array(l.length);for(let g=0;g<l.length;g++)f[g]=l.charCodeAt(g);const p=new Uint8Array(f);d.push(p)}return new Blob(d,{type:t})}catch(i){return console.error("Failed to convert base64 to blob:",i),null}}static toFile(n,t="file.txt",o="text/plain"){const s=n.replace(/^data:.+;base64,/,"").replace(/-/g,"+").replace(/_/g,"/"),c="=".repeat((4-s.length%4)%4),u=s+c,i=atob(u),d=[];for(let l=0;l<i.length;l+=512){const f=i.slice(l,l+512),p=new Array(f.length);for(let g=0;g<f.length;g++)p[g]=f.charCodeAt(g);d.push(new Uint8Array(p))}const a=new Blob(d,{type:o});return new File([a],t,{type:o})}static encode(n){if(!n)return"";const t=this._stringToUtf8Bytes(n);return this._bytesToBase64(t)}static decode(n){if(!n)return"";n=n.replace(/\s/g,"");const t=this._base64ToBytes(n);return this._utf8BytesToString(t)}static _stringToUtf8Bytes(n){const t=[];for(let o=0;o<n.length;o++){let r=n.charCodeAt(o);if(r<128)t.push(r);else if(r<2048)t.push(192|r>>6),t.push(128|r&63);else if(r<55296||r>=57344)t.push(224|r>>12),t.push(128|r>>6&63),t.push(128|r&63);else{o++;const s=r,c=n.charCodeAt(o);if(isNaN(c))throw new Error("代理对不完整");r=65536+((s&1023)<<10)+(c&1023),t.push(240|r>>18),t.push(128|r>>12&63),t.push(128|r>>6&63),t.push(128|r&63)}}return t}static _utf8BytesToString(n){let t="",o=0;for(;o<n.length;){const r=n[o++];if(r<128)t+=String.fromCharCode(r);else if(r>=192&&r<224){const s=n[o++]&63;t+=String.fromCharCode((r&31)<<6|s)}else if(r>=224&&r<240){const s=n[o++]&63,c=n[o++]&63;t+=String.fromCharCode((r&15)<<12|s<<6|c)}else if(r>=240&&r<248){const s=n[o++]&63,c=n[o++]&63,u=n[o++]&63,i=(r&7)<<18|s<<12|c<<6|u,d=Math.floor((i-65536)/1024)+55296,a=(i-65536)%1024+56320;t+=String.fromCharCode(d,a)}else t+="�"}return t}static _bytesToBase64(n){let t="",o=0;for(;o<n.length;){const r=n[o++],s=o<n.length,c=s?n[o++]:0,u=o<n.length,i=u?n[o++]:0,d=r>>2,a=(r&3)<<4|c>>4,l=(c&15)<<2|i>>6,f=i&63;s?u?t+=this.BASE64_CHARS.charAt(d)+this.BASE64_CHARS.charAt(a)+this.BASE64_CHARS.charAt(l)+this.BASE64_CHARS.charAt(f):t+=this.BASE64_CHARS.charAt(d)+this.BASE64_CHARS.charAt(a)+this.BASE64_CHARS.charAt(l)+"=":t+=this.BASE64_CHARS.charAt(d)+this.BASE64_CHARS.charAt(a)+"=="}return t}static _base64ToBytes(n){const t=n.length;let o=0;t>=2&&(n[t-1]==="="&&o++,n[t-2]==="="&&o++);const r=Math.floor(t*3/4)-o,s=new Array(r),c=new Array(256).fill(-1);for(let d=0;d<this.BASE64_CHARS.length;d++)c[this.BASE64_CHARS.charCodeAt(d)]=d;let u=0,i=0;for(;i<t;){const d=c[n.charCodeAt(i++)],a=c[n.charCodeAt(i++)],l=i<t?c[n.charCodeAt(i++)]:-1,f=i<t?c[n.charCodeAt(i++)]:-1;if(d===-1||a===-1)throw new Error("无效的 Base64 字符");const p=d<<2|a>>4;if(s[u++]=p,l!==-1){const g=(a&15)<<4|l>>2;if(s[u++]=g,f!==-1){const y=(l&3)<<6|f;s[u++]=y}}}return s}}const S={isEmptyString(e){return typeof e=="string"&&e.trim()===""},isNumber(e){return typeof e=="number"&&!isNaN(e)},isObject(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)},isEmptyObject(e){return e?Object.keys(e).length===0&&e.constructor===Object:!0},isBoolean(e){return typeof e=="boolean"},isArray(e){return Array.isArray(e)},isFunction(e){return typeof e=="function"},isPromise(e){return!!e&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"},isElement(e){return e instanceof Element},isPhone(e){return/^1[3-9]\d{9}$/.test(e)},isEmail(e){return/^[\w.-]+@[\w.-]+\.\w+$/.test(e)},isJSON(e){try{return JSON.parse(e),!0}catch{return!1}},isImageLoaded(e){return e.complete&&e.naturalWidth!==0},isInViewport(e){const n=e.getBoundingClientRect();return n.top>=0&&n.left>=0&&n.bottom<=window.innerHeight&&n.right<=window.innerWidth},isLeapYear(e){return e%4===0&&e%100!==0||e%400===0},isMobile(){return/Mobi|Android|iPhone/i.test(navigator.userAgent)}},U={getCookie(e){if(!e)return;const n=document.cookie.match(new RegExp("(^| )"+e+"=([^;]+)"));return n?decodeURIComponent(n[2]):null},setCookie(e,n,t=7){const o=new Date;o.setTime(o.getTime()+t*24*60*60*1e3),document.cookie=`${e}=${encodeURIComponent(n)};expires=${o.toUTCString()};path=/`},deleteCookie(e){this.setCookie(e,"",-1)}},E={getTimeString(e,n=!1){return n?new Date().toLocaleString(e,{hour12:!0}):new Date().toLocaleString("chinese",{hour12:!1})},diffDays(e,n){const t=new Date(e).getTime(),o=new Date(n).getTime();return t>o?Math.abs(Math.floor((t-o)/(24*3600*1e3))):Math.abs(Math.floor((o-t)/(24*3600*1e3)))},uniqueId(){return Date.now().toString(36)+Math.random().toString(36).substr(2,5)},getWhichDays(e,n,t){let o=t;for(let r=1;r<n;r++)switch(r){case 1:case 3:case 5:case 7:case 8:case 10:case 12:o+=31;break;case 2:S.isLeapYear(e)?o+=29:o+=28;break;default:o+=30;break}return o},getTimeStringAutoShort2(e,n){const t=new Date,o=new Date(e),r=t.getFullYear(),s=t.getMonth()+1,c=t.getDate(),u=o.getFullYear(),i=o.getMonth()+1,d=o.getDate();let a="";const l=n?" "+this.formatDate(o,"hh:mm"):"";if(r===u){const g=t.getTime()-e;if(s===i&&c===d)g<60*1e3?a="刚刚":a=this.formatDate(o,"hh:mm");else{const y=new Date;y.setDate(y.getDate()-1);const b=new Date;if(b.setDate(b.getDate()-2),i===y.getMonth()+1&&d===y.getDate())a="昨天"+l;else if(i===b.getMonth()+1&&d===b.getDate())a="前天"+l;else if(g/36e5<=7*24){const m=new Array(7);m[0]="星期日",m[1]="星期一",m[2]="星期二",m[3]="星期三",m[4]="星期四",m[5]="星期五",m[6]="星期六",a=m[o.getDay()]+l}else a=this.formatDate(o,"yyyy/M/d")+l}}else a=this.formatDate(o,"yyyy/M/d")+l;return a},formatDate(e,n){const t={"M+":e.getMonth()+1,"d+":e.getDate(),"h+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds()};/(y+)/.test(n)&&(n=n.replace(RegExp.$1,(e.getFullYear()+"").substr(4-RegExp.$1.length)));for(const o in t)new RegExp("("+o+")").test(n)&&(n=n.replace(RegExp.$1,RegExp.$1.length===1?t[o]:("00"+t[o]).substr((""+t[o]).length)));return n}},B={getOffsetTop(e){if(!e)throw new Error("Element is not provided");if(e instanceof SVGElement){const t=e.getBoundingClientRect(),o=window.pageYOffset||document.documentElement.scrollTop;return t.top+o}let n=0;for(;e;)n+=e.offsetTop,e=e.offsetParent;return n},getScrollValue(){const e={scrollLeft:0,scrollTop:0};return e.scrollLeft=document.body.scrollLeft||document.documentElement.scrollLeft,e.scrollTop=document.body.scrollTop||document.documentElement.scrollTop,e},getPageValue(e){e=e||window.event;const n=e.pageX||e.clientX+this.getScrollValue().scrollLeft,t=e.pageY||e.clientY+this.getScrollValue().scrollTop;return{pageX:n,pageY:t}},addEventListener(e,n,t){e.addEventListener?e.addEventListener(n,t):e.attachEvent?e.attachEvent("on"+n,t):e["on"+n]=t},getViewportWidth(){return window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth},getViewportHeight(){return window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight}},C={saveAsBlob(e,n){const t=document.createElement("a"),o=window.URL.createObjectURL(e);t.href=o,t.download=n,document.body.appendChild(t),t.click(),URL.revokeObjectURL(o),document.body.removeChild(t)}},D={animate(e,n){let t=-1;const o=e.series[0].data.length;let r;r=setInterval(()=>{n.dispatchAction({type:"downplay",seriesIndex:0,dataIndex:t}),t=(t+1)%o,n.dispatchAction({type:"highlight",seriesIndex:0,dataIndex:t}),n.dispatchAction({type:"showTip",seriesIndex:0,dataIndex:t}),t>o&&(t=0)},2e3),n.on("mouseover",()=>{clearInterval(r),n.dispatchAction({type:"downplay",seriesIndex:0,dataIndex:t})})}},x={sortFromA2Z(e){return e?.length?e.sort((t,o)=>{const r=t.toUpperCase(),s=o.toUpperCase();return r<s?-1:r>s?1:0}):void 0}},R={degrees2Radians(e){return e*Math.PI/180},getDistance(e,n,t,o){const r=this.degrees2Radians(e),s=this.degrees2Radians(t),c=r-s,u=this.degrees2Radians(n)-this.degrees2Radians(o);let i=2*Math.asin(Math.sqrt(Math.pow(Math.sin(c/2),2)+Math.cos(r)*Math.cos(s)*Math.pow(Math.sin(u/2),2)));return i=i*6378.137,i=Math.round(i*1e4)/1e4,i=+i.toFixed(2),console.log("经纬度计算的距离为:"+i),i},calculateDistanceByHaversine(e,n,t="km"){const o=this,r=e.longitude??e.lng,s=e.latitude??e.lat,c=n.longitude??n.lng,u=n.latitude??n.lat;if(r===void 0||s===void 0||c===void 0||u===void 0)throw new Error("无效的坐标格式,缺少经纬度信息");const i=6371,d=o.degrees2Radians(s),a=o.degrees2Radians(u),l=o.degrees2Radians(u-s),f=o.degrees2Radians(c-r),p=Math.sin(l/2)*Math.sin(l/2)+Math.cos(d)*Math.cos(a)*Math.sin(f/2)*Math.sin(f/2),g=2*Math.atan2(Math.sqrt(p),Math.sqrt(1-p)),y=i*g;switch(t){case"m":return y*1e3;case"mi":return y*.621371;case"nmi":return y*.539957;default:return y}},calculateDistancesByHaversine(e,n="km",t=!1){if(e.length<2)return{segments:[],total:0};const o=[];let r=0;for(let s=0;s<e.length-1;s++){const c=this.calculateDistanceByHaversine(e[s],e[s+1],n);o.push(c),r+=c}if(t&&e.length>2){const s=this.calculateDistanceByHaversine(e[e.length-1],e[0],n);o.push(s),r+=s}return{segments:o,total:r}}};class T{static toStandardFormat(n){try{const t=typeof n=="string"?parseFloat(n):n;if(isNaN(t))throw new Error("输入不是有效的数字");if(!isFinite(t))throw new Error("输入是无穷大");return t.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}catch(t){return console.error("格式化失败:",t),"格式错误"}}static toChineseFormat(n){try{const t=typeof n=="string"?parseFloat(n):n;if(isNaN(t))throw new Error("输入不是有效的数字");if(t>9999999999999e-2||t<-9999999999999e-2)throw new Error("输入数字超出范围");const o=t<0,r=Math.abs(t),s=Math.floor(r),c=Math.round((r-s)*100),u=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],i=["","拾","佰","仟","万","拾","佰","仟","亿","拾","佰","仟"],d=["角","分"];let a="",l=s;if(l===0)a=u[0];else{let g=0;for(;l>0;){const y=l%10;y!==0?a=u[y]+i[g]+a:a.charAt(0)!==u[0]&&(a=u[y]+a),l=Math.floor(l/10),g++}a=a.replace(/零+/g,"零"),a=a.replace(/零+$/,"")}let f="";if(c>0){const g=Math.floor(c/10),y=c%10;g>0&&(f+=u[g]+d[0]),y>0&&(f+=u[y]+d[1])}else f="整";let p=(o?"负":"")+a+"圆"+f;return p==="零圆整"&&(p="零圆"),p}catch(t){return console.error("转换失败:",t),"格式错误"}}}const _={...Object.freeze(Object.defineProperty({__proto__:null,toLetter:e=>e>25||e<0?"":"ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e]},Symbol.toStringTag,{value:"Module"})),...Object.freeze(Object.defineProperty({__proto__:null,toMoney:e=>e.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")},Symbol.toStringTag,{value:"Module"})),isNumber(e){return typeof e=="number"&&!isNaN(e)}},v={isEmptyObject(e){return e?Object.keys(e).length===0&&e.constructor===Object:!0},copy(e,n){for(const t in e)n[t]=e[t]},deepCopy(e,n){for(const t in e){const o=e[t];o instanceof Object?(n[t]={},this.deepCopy(o,n[t])):o instanceof Array?(n[t]=[],this.deepCopy(o,n[t])):n[t]=e[t]}}},O={desensitize(e){return e?e.replace(/^(\d{3})\d{4}(\d{4})$/,"$1****$2")||e.slice(0,3)+"****"+e.slice(7):""}},L={color:function(){return`#${Math.random().toString(16).slice(2,8)}`},int(e,n){return Math.floor(Math.random()*(n-e+1))+e},uniqueId(){return Date.now().toString(36)+Math.random().toString(36).substr(2,5)}},I={mobile:/^1[3-9]\d{9}$/,email:/^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,chinese:/^[\u4e00-\u9fa5]+$/,english:/^[a-zA-Z]+$/,chineseStart:/^[\u4e00-\u9fa5]+\w*$/,integer:/^\d+$/,integerAndzero:/^(0|[1-9]+[0-9]*)$/,strongPassword:/^(?!.*[\s\p{C}])(?:(?=.*[A-Z])(?=.*[a-z])(?=.*[\d\W])|(?=.*\d)(?=.*[^\w\s])).{8,}$/u,decimal:/^0\.(0[1-9]|[1-9][0-9]*)$/},j={getLocal(e){return localStorage.getItem(e)},setLocal(e,n){localStorage.setItem(e,n)},removeLocal(e){localStorage.removeItem(e)},getSession(e){return sessionStorage.getItem(e)},setSession(e,n){sessionStorage.setItem(e,n)},removeSession(e){sessionStorage.removeItem(e)}},H={isExist(e,n){if(!e||!n)return!1;const t=e.split(",");return console.log("判断某元素是否在字符串中",t.indexOf(n)===-1),t.indexOf(n)!==-1},includes(e,n){return!e||!n?!1:e.includes(n)},isJSON(e){try{return JSON.parse(e),!0}catch{return!1}},indexsOfAppear(e,n){let t=-1;const o=[];do t=e.indexOf(n,t+1),t!==-1&&o.push(t);while(t!==-1);return o},getMaxTimesAndVal(e){const n=[0,""],t={};for(let s=0;s<e.length;s++){const c=e.charAt(s);t[c]?t[c]++:t[c]=1}let o=1;for(const s in t)o<t[s]&&(o=t[s]);const r=[];for(const s in t)o==t[s]&&r.push(s);return n[0]=o,n[1]=r.join(),n}},k=e=>{const t=new RegExp("[?&]"+e+"=([^&#]*)","i").exec(window.location.href);return t?decodeURIComponent(t[1]):null};function $(e){return new URLSearchParams(window.location.search).get(e)}const P={...Object.freeze(Object.defineProperty({__proto__:null,getQueryInfoByName:k,getQueryParam:$},Symbol.toStringTag,{value:"Module"})),getHost(){return window.location.host},getPath(){return window.location.pathname}},F={toList(e,n=2){console.log(e,n);const t={};for(let r=0;r<n;r++)t[r]=[];e.forEach((r,s)=>t[s%n].push(r));const o=[];for(const r in t)o.push(...t[r]);return o},jsLayout(e,n,t){const o=e.offsetWidth,r=n[0].offsetWidth,s=parseInt((o/r).toString()),c=(o-r*s)/(s-1),u=[];for(let i=0,d=n.length;i<d;i++){const a=n[i];if(i<s)a.style.left=(r+c)*i+"px",u[i]=a.offsetHeight;else{const{index:l,value:f}=A.getMinValueAndIndex(u);a.style.left=(r+c)*l+"px",a.style.top=f+t+"px",u[l]=a.offsetHeight+t+f}}}};h.Base64Utils=M,h.MoneyFormatter=T,h.arrayUtils=A,h.booleanUtils=S,h.cookieUtils=U,h.dateUtils=E,h.documentUtils=B,h.downloadUtils=C,h.echartsUtils=D,h.letterUtils=x,h.mapUtils=R,h.numberUtils=_,h.objectUtils=v,h.phoneUtils=O,h.randomUtils=L,h.regexpUtils=I,h.storageUtils=j,h.stringUtils=H,h.urlUtils=P,h.waterfallUtils=F,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(h,w){typeof exports=="object"&&typeof module<"u"?w(exports):typeof define=="function"&&define.amd?define(["exports"],w):(h=typeof globalThis<"u"?globalThis:h||self,w(h.yhkitUtils={}))})(this,function(h){"use strict";const A=Object.assign({unique(e){return e?Array.from(new Set(e)):[]},isExist(e,n){return!e||!n?!1:e.indexOf(n)!==-1},countOfAppear(e,n){let t=0;for(const o of e)o===n&&t++;return t},indexsOfAppear(e,n){let t=-1;const o=[];do t=e.indexOf(n,t+1),t!==-1&&o.push(t);while(t!==-1);return o},sort(e,n="asc"){return e?e.sort((t,o)=>n==="asc"?t>o?1:-1:t<o?1:-1):[]},shuffle(e){if(!e)return[];for(let n=e.length-1;n>0;n--){const t=Math.floor(Math.random()*(n+1));[e[n],e[t]]=[e[t],e[n]]}return e},getMaxValue(e){return e?Math.max(...e):0},getMinValue(e){return e?Math.min(...e):0},getMinValueAndIndex(e){if(e.length===0)return{value:0,index:0};const n={value:e[0],index:0};for(let t=1,o=e.length;t<o;t++){const r=e[t];n.value>r&&(n.value=r,n.index=t)}return n},getMaxValueAndIndex(e){return e.length===0?{value:0,index:0}:e.reduce((n,t,o)=>t<n.value?{value:t,index:o}:n,{value:e[0],index:0})}},{...Object.freeze(Object.defineProperty({__proto__:null,toEnumObj:e=>{if(!e||!e.length)return{};const n={};return e.forEach(t=>{const o=Object.assign({label:t.label,text:t.label},t);n[t?.value]=o}),n}},Symbol.toStringTag,{value:"Module"}))});class M{static BASE64_CHARS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";static toBlob(n,t="",o=512){const s=(n.split(",")[1]||n).replace(/-/g,"+").replace(/_/g,"/"),c="=".repeat((4-s.length%4)%4),u=s+c;try{const i=atob(u),d=[];for(let a=0;a<i.length;a+=o){const l=i.slice(a,a+o),f=new Array(l.length);for(let g=0;g<l.length;g++)f[g]=l.charCodeAt(g);const p=new Uint8Array(f);d.push(p)}return new Blob(d,{type:t})}catch(i){return console.error("Failed to convert base64 to blob:",i),null}}static toFile(n,t="file.txt",o="text/plain"){const s=n.replace(/^data:.+;base64,/,"").replace(/-/g,"+").replace(/_/g,"/"),c="=".repeat((4-s.length%4)%4),u=s+c,i=atob(u),d=[];for(let l=0;l<i.length;l+=512){const f=i.slice(l,l+512),p=new Array(f.length);for(let g=0;g<f.length;g++)p[g]=f.charCodeAt(g);d.push(new Uint8Array(p))}const a=new Blob(d,{type:o});return new File([a],t,{type:o})}static encode(n){if(!n)return"";const t=this._stringToUtf8Bytes(n);return this._bytesToBase64(t)}static decode(n){if(!n)return"";n=n.replace(/\s/g,"");const t=this._base64ToBytes(n);return this._utf8BytesToString(t)}static _stringToUtf8Bytes(n){const t=[];for(let o=0;o<n.length;o++){let r=n.charCodeAt(o);if(r<128)t.push(r);else if(r<2048)t.push(192|r>>6),t.push(128|r&63);else if(r<55296||r>=57344)t.push(224|r>>12),t.push(128|r>>6&63),t.push(128|r&63);else{o++;const s=r,c=n.charCodeAt(o);if(isNaN(c))throw new Error("代理对不完整");r=65536+((s&1023)<<10)+(c&1023),t.push(240|r>>18),t.push(128|r>>12&63),t.push(128|r>>6&63),t.push(128|r&63)}}return t}static _utf8BytesToString(n){let t="",o=0;for(;o<n.length;){const r=n[o++];if(r<128)t+=String.fromCharCode(r);else if(r>=192&&r<224){const s=n[o++]&63;t+=String.fromCharCode((r&31)<<6|s)}else if(r>=224&&r<240){const s=n[o++]&63,c=n[o++]&63;t+=String.fromCharCode((r&15)<<12|s<<6|c)}else if(r>=240&&r<248){const s=n[o++]&63,c=n[o++]&63,u=n[o++]&63,i=(r&7)<<18|s<<12|c<<6|u,d=Math.floor((i-65536)/1024)+55296,a=(i-65536)%1024+56320;t+=String.fromCharCode(d,a)}else t+="�"}return t}static _bytesToBase64(n){let t="",o=0;for(;o<n.length;){const r=n[o++],s=o<n.length,c=s?n[o++]:0,u=o<n.length,i=u?n[o++]:0,d=r>>2,a=(r&3)<<4|c>>4,l=(c&15)<<2|i>>6,f=i&63;s?u?t+=this.BASE64_CHARS.charAt(d)+this.BASE64_CHARS.charAt(a)+this.BASE64_CHARS.charAt(l)+this.BASE64_CHARS.charAt(f):t+=this.BASE64_CHARS.charAt(d)+this.BASE64_CHARS.charAt(a)+this.BASE64_CHARS.charAt(l)+"=":t+=this.BASE64_CHARS.charAt(d)+this.BASE64_CHARS.charAt(a)+"=="}return t}static _base64ToBytes(n){const t=n.length;let o=0;t>=2&&(n[t-1]==="="&&o++,n[t-2]==="="&&o++);const r=Math.floor(t*3/4)-o,s=new Array(r),c=new Array(256).fill(-1);for(let d=0;d<this.BASE64_CHARS.length;d++)c[this.BASE64_CHARS.charCodeAt(d)]=d;let u=0,i=0;for(;i<t;){const d=c[n.charCodeAt(i++)],a=c[n.charCodeAt(i++)],l=i<t?c[n.charCodeAt(i++)]:-1,f=i<t?c[n.charCodeAt(i++)]:-1;if(d===-1||a===-1)throw new Error("无效的 Base64 字符");const p=d<<2|a>>4;if(s[u++]=p,l!==-1){const g=(a&15)<<4|l>>2;if(s[u++]=g,f!==-1){const y=(l&3)<<6|f;s[u++]=y}}}return s}}const S={isEmptyString(e){return typeof e=="string"&&e.trim()===""},isNumber(e){return typeof e=="number"&&!isNaN(e)},isObject(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)},isEmptyObject(e){return e?Object.keys(e).length===0&&e.constructor===Object:!0},isBoolean(e){return typeof e=="boolean"},isArray(e){return Array.isArray(e)},isFunction(e){return typeof e=="function"},isPromise(e){return!!e&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"},isElement(e){return e instanceof Element},isPhone(e){return/^1[3-9]\d{9}$/.test(e)},isEmail(e){return/^[\w.-]+@[\w.-]+\.\w+$/.test(e)},isJSON(e){try{return JSON.parse(e),!0}catch{return!1}},isImageLoaded(e){return e.complete&&e.naturalWidth!==0},isInViewport(e){const n=e.getBoundingClientRect();return n.top>=0&&n.left>=0&&n.bottom<=window.innerHeight&&n.right<=window.innerWidth},isLeapYear(e){return e%4===0&&e%100!==0||e%400===0},isMobile(){return/Mobi|Android|iPhone/i.test(navigator.userAgent)}},U={getCookie(e){if(!e)return;const n=document.cookie.match(new RegExp("(^| )"+e+"=([^;]+)"));return n?decodeURIComponent(n[2]):null},setCookie(e,n,t=7){const o=new Date;o.setTime(o.getTime()+t*24*60*60*1e3),document.cookie=`${e}=${encodeURIComponent(n)};expires=${o.toUTCString()};path=/`},deleteCookie(e){this.setCookie(e,"",-1)}},E={getTimeString(e,n=!1){return n?new Date().toLocaleString(e,{hour12:!0}):new Date().toLocaleString("chinese",{hour12:!1})},diffDays(e,n){const t=new Date(e).getTime(),o=new Date(n).getTime();return t>o?Math.abs(Math.floor((t-o)/(24*3600*1e3))):Math.abs(Math.floor((o-t)/(24*3600*1e3)))},uniqueId(){return Date.now().toString(36)+Math.random().toString(36).substr(2,5)},getWhichDays(e,n,t){let o=t;for(let r=1;r<n;r++)switch(r){case 1:case 3:case 5:case 7:case 8:case 10:case 12:o+=31;break;case 2:S.isLeapYear(e)?o+=29:o+=28;break;default:o+=30;break}return o},getTimeStringAutoShort2(e,n){const t=new Date,o=new Date(e),r=t.getFullYear(),s=t.getMonth()+1,c=t.getDate(),u=o.getFullYear(),i=o.getMonth()+1,d=o.getDate();let a="";const l=n?" "+this.formatDate(o,"hh:mm"):"";if(r===u){const g=t.getTime()-e;if(s===i&&c===d)g<60*1e3?a="刚刚":a=this.formatDate(o,"hh:mm");else{const y=new Date;y.setDate(y.getDate()-1);const b=new Date;if(b.setDate(b.getDate()-2),i===y.getMonth()+1&&d===y.getDate())a="昨天"+l;else if(i===b.getMonth()+1&&d===b.getDate())a="前天"+l;else if(g/36e5<=7*24){const m=new Array(7);m[0]="星期日",m[1]="星期一",m[2]="星期二",m[3]="星期三",m[4]="星期四",m[5]="星期五",m[6]="星期六",a=m[o.getDay()]+l}else a=this.formatDate(o,"yyyy/M/d")+l}}else a=this.formatDate(o,"yyyy/M/d")+l;return a},formatDate(e,n){const t={"M+":e.getMonth()+1,"d+":e.getDate(),"h+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds()};/(y+)/.test(n)&&(n=n.replace(RegExp.$1,(e.getFullYear()+"").substr(4-RegExp.$1.length)));for(const o in t)new RegExp("("+o+")").test(n)&&(n=n.replace(RegExp.$1,RegExp.$1.length===1?t[o]:("00"+t[o]).substr((""+t[o]).length)));return n}},C={getOffsetTop(e){if(!e)throw new Error("Element is not provided");if(e instanceof SVGElement){const t=e.getBoundingClientRect(),o=window.pageYOffset||document.documentElement.scrollTop;return t.top+o}let n=0;for(;e;)n+=e.offsetTop,e=e.offsetParent;return n},getScrollValue(){const e={scrollLeft:0,scrollTop:0};return e.scrollLeft=document.body.scrollLeft||document.documentElement.scrollLeft,e.scrollTop=document.body.scrollTop||document.documentElement.scrollTop,e},getPageValue(e){e=e||window.event;const n=e.pageX||e.clientX+this.getScrollValue().scrollLeft,t=e.pageY||e.clientY+this.getScrollValue().scrollTop;return{pageX:n,pageY:t}},addEventListener(e,n,t){e.addEventListener?e.addEventListener(n,t):e.attachEvent?e.attachEvent("on"+n,t):e["on"+n]=t},getViewportWidth(){return window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth},getViewportHeight(){return window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight}},B={saveAsBlob(e,n){const t=document.createElement("a"),o=window.URL.createObjectURL(e);t.href=o,t.download=n,document.body.appendChild(t),t.click(),URL.revokeObjectURL(o),document.body.removeChild(t)},saveAsUrl(e,n){const t=document.createElement("a");t.href=e,t.download=n,document.body.appendChild(t),t.click(),URL.revokeObjectURL(e),document.body.removeChild(t)}},D={animate(e,n){let t=-1;const o=e.series[0].data.length;let r;r=setInterval(()=>{n.dispatchAction({type:"downplay",seriesIndex:0,dataIndex:t}),t=(t+1)%o,n.dispatchAction({type:"highlight",seriesIndex:0,dataIndex:t}),n.dispatchAction({type:"showTip",seriesIndex:0,dataIndex:t}),t>o&&(t=0)},2e3),n.on("mouseover",()=>{clearInterval(r),n.dispatchAction({type:"downplay",seriesIndex:0,dataIndex:t})})}},R={sortFromA2Z(e){return e?.length?e.sort((t,o)=>{const r=t.toUpperCase(),s=o.toUpperCase();return r<s?-1:r>s?1:0}):void 0}},v={degrees2Radians(e){return e*Math.PI/180},getDistance(e,n,t,o){const r=this.degrees2Radians(e),s=this.degrees2Radians(t),c=r-s,u=this.degrees2Radians(n)-this.degrees2Radians(o);let i=2*Math.asin(Math.sqrt(Math.pow(Math.sin(c/2),2)+Math.cos(r)*Math.cos(s)*Math.pow(Math.sin(u/2),2)));return i=i*6378.137,i=Math.round(i*1e4)/1e4,i=+i.toFixed(2),console.log("经纬度计算的距离为:"+i),i},calculateDistanceByHaversine(e,n,t="km"){const o=this,r=e.longitude??e.lng,s=e.latitude??e.lat,c=n.longitude??n.lng,u=n.latitude??n.lat;if(r===void 0||s===void 0||c===void 0||u===void 0)throw new Error("无效的坐标格式,缺少经纬度信息");const i=6371,d=o.degrees2Radians(s),a=o.degrees2Radians(u),l=o.degrees2Radians(u-s),f=o.degrees2Radians(c-r),p=Math.sin(l/2)*Math.sin(l/2)+Math.cos(d)*Math.cos(a)*Math.sin(f/2)*Math.sin(f/2),g=2*Math.atan2(Math.sqrt(p),Math.sqrt(1-p)),y=i*g;switch(t){case"m":return y*1e3;case"mi":return y*.621371;case"nmi":return y*.539957;default:return y}},calculateDistancesByHaversine(e,n="km",t=!1){if(e.length<2)return{segments:[],total:0};const o=[];let r=0;for(let s=0;s<e.length-1;s++){const c=this.calculateDistanceByHaversine(e[s],e[s+1],n);o.push(c),r+=c}if(t&&e.length>2){const s=this.calculateDistanceByHaversine(e[e.length-1],e[0],n);o.push(s),r+=s}return{segments:o,total:r}}};class x{static toStandardFormat(n){try{const t=typeof n=="string"?parseFloat(n):n;if(isNaN(t))throw new Error("输入不是有效的数字");if(!isFinite(t))throw new Error("输入是无穷大");return t.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}catch(t){return console.error("格式化失败:",t),"格式错误"}}static toChineseFormat(n){try{const t=typeof n=="string"?parseFloat(n):n;if(isNaN(t))throw new Error("输入不是有效的数字");if(t>9999999999999e-2||t<-9999999999999e-2)throw new Error("输入数字超出范围");const o=t<0,r=Math.abs(t),s=Math.floor(r),c=Math.round((r-s)*100),u=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],i=["","拾","佰","仟","万","拾","佰","仟","亿","拾","佰","仟"],d=["角","分"];let a="",l=s;if(l===0)a=u[0];else{let g=0;for(;l>0;){const y=l%10;y!==0?a=u[y]+i[g]+a:a.charAt(0)!==u[0]&&(a=u[y]+a),l=Math.floor(l/10),g++}a=a.replace(/零+/g,"零"),a=a.replace(/零+$/,"")}let f="";if(c>0){const g=Math.floor(c/10),y=c%10;g>0&&(f+=u[g]+d[0]),y>0&&(f+=u[y]+d[1])}else f="整";let p=(o?"负":"")+a+"圆"+f;return p==="零圆整"&&(p="零圆"),p}catch(t){return console.error("转换失败:",t),"格式错误"}}}const T={...Object.freeze(Object.defineProperty({__proto__:null,toLetter:e=>e>25||e<0?"":"ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e]},Symbol.toStringTag,{value:"Module"})),...Object.freeze(Object.defineProperty({__proto__:null,toMoney:e=>e.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")},Symbol.toStringTag,{value:"Module"})),isNumber(e){return typeof e=="number"&&!isNaN(e)}},_={isEmptyObject(e){return e?Object.keys(e).length===0&&e.constructor===Object:!0},copy(e,n){for(const t in e)n[t]=e[t]},deepCopy(e,n){for(const t in e){const o=e[t];o instanceof Object?(n[t]={},this.deepCopy(o,n[t])):o instanceof Array?(n[t]=[],this.deepCopy(o,n[t])):n[t]=e[t]}}},O={desensitize(e){return e?e.replace(/^(\d{3})\d{4}(\d{4})$/,"$1****$2")||e.slice(0,3)+"****"+e.slice(7):""}},L={color:function(){return`#${Math.random().toString(16).slice(2,8)}`},int(e,n){return Math.floor(Math.random()*(n-e+1))+e},uniqueId(){return Date.now().toString(36)+Math.random().toString(36).substr(2,5)}},j={mobile:/^1[3-9]\d{9}$/,email:/^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,chinese:/^[\u4e00-\u9fa5]+$/,english:/^[a-zA-Z]+$/,chineseStart:/^[\u4e00-\u9fa5]+\w*$/,integer:/^\d+$/,integerAndzero:/^(0|[1-9]+[0-9]*)$/,strongPassword:/^(?!.*[\s\p{C}])(?:(?=.*[A-Z])(?=.*[a-z])(?=.*[\d\W])|(?=.*\d)(?=.*[^\w\s])).{8,}$/u,decimal:/^0\.(0[1-9]|[1-9][0-9]*)$/},I={getLocal(e){return localStorage.getItem(e)},setLocal(e,n){localStorage.setItem(e,n)},removeLocal(e){localStorage.removeItem(e)},getSession(e){return sessionStorage.getItem(e)},setSession(e,n){sessionStorage.setItem(e,n)},removeSession(e){sessionStorage.removeItem(e)}},k={isExist(e,n){if(!e||!n)return!1;const t=e.split(",");return console.log("判断某元素是否在字符串中",t.indexOf(n)===-1),t.indexOf(n)!==-1},includes(e,n){return!e||!n?!1:e.includes(n)},isJSON(e){try{return JSON.parse(e),!0}catch{return!1}},indexsOfAppear(e,n){let t=-1;const o=[];do t=e.indexOf(n,t+1),t!==-1&&o.push(t);while(t!==-1);return o},getMaxTimesAndVal(e){const n=[0,""],t={};for(let s=0;s<e.length;s++){const c=e.charAt(s);t[c]?t[c]++:t[c]=1}let o=1;for(const s in t)o<t[s]&&(o=t[s]);const r=[];for(const s in t)o==t[s]&&r.push(s);return n[0]=o,n[1]=r.join(),n}},H=e=>{const t=new RegExp("[?&]"+e+"=([^&#]*)","i").exec(window.location.href);return t?decodeURIComponent(t[1]):null};function $(e){return new URLSearchParams(window.location.search).get(e)}const P={...Object.freeze(Object.defineProperty({__proto__:null,getQueryInfoByName:H,getQueryParam:$},Symbol.toStringTag,{value:"Module"})),getHost(){return window.location.host},getPath(){return window.location.pathname}},F={toList(e,n=2){console.log(e,n);const t={};for(let r=0;r<n;r++)t[r]=[];e.forEach((r,s)=>t[s%n].push(r));const o=[];for(const r in t)o.push(...t[r]);return o},jsLayout(e,n,t){const o=e.offsetWidth,r=n[0].offsetWidth,s=parseInt((o/r).toString()),c=(o-r*s)/(s-1),u=[];for(let i=0,d=n.length;i<d;i++){const a=n[i];if(i<s)a.style.left=(r+c)*i+"px",u[i]=a.offsetHeight;else{const{index:l,value:f}=A.getMinValueAndIndex(u);a.style.left=(r+c)*l+"px",a.style.top=f+t+"px",u[l]=a.offsetHeight+t+f}}}};h.Base64Utils=M,h.MoneyFormatter=x,h.arrayUtils=A,h.booleanUtils=S,h.cookieUtils=U,h.dateUtils=E,h.documentUtils=C,h.downloadUtils=B,h.echartsUtils=D,h.letterUtils=R,h.mapUtils=v,h.numberUtils=T,h.objectUtils=_,h.phoneUtils=O,h.randomUtils=L,h.regexpUtils=j,h.storageUtils=I,h.stringUtils=k,h.urlUtils=P,h.waterfallUtils=F,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -8,4 +8,10 @@ export declare const downloadUtils: {
|
|
|
8
8
|
* @param filename 文件名
|
|
9
9
|
*/
|
|
10
10
|
saveAsBlob(blob: Blob | MediaSource, filename: string): void;
|
|
11
|
+
/**
|
|
12
|
+
* 直接下载url
|
|
13
|
+
* @param url 下载url
|
|
14
|
+
* @param filename 文件名
|
|
15
|
+
*/
|
|
16
|
+
saveAsUrl(url: string, filename: string): void;
|
|
11
17
|
};
|