@yh-kit/utils 1.7.0 → 1.7.1
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
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const y = (e) => {
|
|
2
2
|
if (!e || !e.length) return {};
|
|
3
3
|
const n = {};
|
|
4
4
|
return e.forEach((t) => {
|
|
@@ -7,8 +7,8 @@ const m = (e) => {
|
|
|
7
7
|
}), n;
|
|
8
8
|
}, b = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
9
9
|
__proto__: null,
|
|
10
|
-
toEnumObj:
|
|
11
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
10
|
+
toEnumObj: y
|
|
11
|
+
}, Symbol.toStringTag, { value: "Module" })), m = Object.assign(
|
|
12
12
|
{
|
|
13
13
|
/**
|
|
14
14
|
* 数组去重
|
|
@@ -104,41 +104,35 @@ const m = (e) => {
|
|
|
104
104
|
* @returns 最小值和索引
|
|
105
105
|
*/
|
|
106
106
|
getMinValueAndIndex(e) {
|
|
107
|
-
if (e.length === 0) return {
|
|
107
|
+
if (e.length === 0) return { value: 0, index: 0 };
|
|
108
108
|
const n = {
|
|
109
109
|
/** 最小值 */
|
|
110
|
-
|
|
110
|
+
value: e[0],
|
|
111
111
|
/** 最小值索引 */
|
|
112
|
-
|
|
112
|
+
index: 0
|
|
113
113
|
};
|
|
114
114
|
for (let t = 1, r = e.length; t < r; t++) {
|
|
115
115
|
const o = e[t];
|
|
116
|
-
n.
|
|
116
|
+
n.value > o && (n.value = o, n.index = t);
|
|
117
117
|
}
|
|
118
118
|
return n;
|
|
119
119
|
},
|
|
120
120
|
/**
|
|
121
121
|
* 获取数组中的最大值和索引
|
|
122
|
-
* @param
|
|
122
|
+
* @param arr 数组
|
|
123
123
|
* @returns 最大值和索引
|
|
124
124
|
*/
|
|
125
125
|
getMaxValueAndIndex(e) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
};
|
|
131
|
-
for (let t = 1, r = e.length; t < r; t++) {
|
|
132
|
-
const o = e[t];
|
|
133
|
-
n.maxV < o && (n.maxV = o, n.maxI = t);
|
|
134
|
-
}
|
|
135
|
-
return n;
|
|
126
|
+
return e.length === 0 ? { value: 0, index: 0 } : e.reduce(
|
|
127
|
+
(n, t, r) => t < n.value ? { value: t, index: r } : n,
|
|
128
|
+
{ value: e[0], index: 0 }
|
|
129
|
+
);
|
|
136
130
|
}
|
|
137
131
|
},
|
|
138
132
|
{
|
|
139
133
|
...b
|
|
140
134
|
}
|
|
141
|
-
),
|
|
135
|
+
), E = {
|
|
142
136
|
/**
|
|
143
137
|
* 将Base64编码的字符串转换为Blob对象。
|
|
144
138
|
* Blob对象用于表示二进制大型对象,可以在浏览器环境中处理大文件或二进制数据。
|
|
@@ -151,15 +145,15 @@ const m = (e) => {
|
|
|
151
145
|
toBlob(e, n = "", t = 512) {
|
|
152
146
|
const o = (e.split(",")[1] || e).replace(/-/g, "+").replace(/_/g, "/"), s = "=".repeat((4 - o.length % 4) % 4), l = o + s;
|
|
153
147
|
try {
|
|
154
|
-
const c = atob(l),
|
|
148
|
+
const c = atob(l), i = [];
|
|
155
149
|
for (let g = 0; g < c.length; g += t) {
|
|
156
|
-
const
|
|
157
|
-
for (let d = 0; d <
|
|
158
|
-
u[d] =
|
|
150
|
+
const a = c.slice(g, g + t), u = new Array(a.length);
|
|
151
|
+
for (let d = 0; d < a.length; d++)
|
|
152
|
+
u[d] = a.charCodeAt(d);
|
|
159
153
|
const f = new Uint8Array(u);
|
|
160
|
-
|
|
154
|
+
i.push(f);
|
|
161
155
|
}
|
|
162
|
-
return new Blob(
|
|
156
|
+
return new Blob(i, { type: n });
|
|
163
157
|
} catch (c) {
|
|
164
158
|
return console.error("Failed to convert base64 to blob:", c), null;
|
|
165
159
|
}
|
|
@@ -175,14 +169,14 @@ const m = (e) => {
|
|
|
175
169
|
* @returns 返回一个File对象,包含解码后的数据。
|
|
176
170
|
*/
|
|
177
171
|
toFile(e, n = "file.txt", t = "text/plain") {
|
|
178
|
-
const o = e.replace(/^data:.+;base64,/, "").replace(/-/g, "+").replace(/_/g, "/"), s = "=".repeat((4 - o.length % 4) % 4), l = o + s, c = atob(l),
|
|
179
|
-
for (let
|
|
180
|
-
const u = c.slice(
|
|
172
|
+
const o = e.replace(/^data:.+;base64,/, "").replace(/-/g, "+").replace(/_/g, "/"), s = "=".repeat((4 - o.length % 4) % 4), l = o + s, c = atob(l), i = [];
|
|
173
|
+
for (let a = 0; a < c.length; a += 512) {
|
|
174
|
+
const u = c.slice(a, a + 512), f = new Array(u.length);
|
|
181
175
|
for (let d = 0; d < u.length; d++)
|
|
182
176
|
f[d] = u.charCodeAt(d);
|
|
183
|
-
|
|
177
|
+
i.push(new Uint8Array(f));
|
|
184
178
|
}
|
|
185
|
-
const g = new Blob(
|
|
179
|
+
const g = new Blob(i, { type: t });
|
|
186
180
|
return new File([g], n, { type: t });
|
|
187
181
|
}
|
|
188
182
|
}, w = {
|
|
@@ -329,7 +323,7 @@ const m = (e) => {
|
|
|
329
323
|
isMobile() {
|
|
330
324
|
return /Mobi|Android|iPhone/i.test(navigator.userAgent);
|
|
331
325
|
}
|
|
332
|
-
},
|
|
326
|
+
}, L = {
|
|
333
327
|
/**
|
|
334
328
|
* 通过传入的name获取cookie的值
|
|
335
329
|
* @param name cookie的name
|
|
@@ -415,7 +409,7 @@ const m = (e) => {
|
|
|
415
409
|
}
|
|
416
410
|
return r;
|
|
417
411
|
}
|
|
418
|
-
},
|
|
412
|
+
}, R = {
|
|
419
413
|
/**
|
|
420
414
|
* 获取元素相对于文档顶部的偏移量(距离)
|
|
421
415
|
* 处理了SVG元素的特殊情况。
|
|
@@ -472,7 +466,7 @@ const m = (e) => {
|
|
|
472
466
|
addEventListener(e, n, t) {
|
|
473
467
|
e.addEventListener ? e.addEventListener(n, t) : e.attachEvent ? e.attachEvent("on" + n, t) : e["on" + n] = t;
|
|
474
468
|
}
|
|
475
|
-
},
|
|
469
|
+
}, C = {
|
|
476
470
|
/**
|
|
477
471
|
* 将blob对象转化成文件并导出到本地
|
|
478
472
|
* @param blob blob对象
|
|
@@ -482,7 +476,7 @@ const m = (e) => {
|
|
|
482
476
|
const t = document.createElement("a"), r = window.URL.createObjectURL(e);
|
|
483
477
|
t.href = r, t.download = n, document.body.appendChild(t), t.click(), URL.revokeObjectURL(r), document.body.removeChild(t);
|
|
484
478
|
}
|
|
485
|
-
},
|
|
479
|
+
}, k = {
|
|
486
480
|
/**
|
|
487
481
|
* 将选中的字母数组从A-Z排序:用于试题选择答案的排序实例
|
|
488
482
|
* @param arr 字母数组
|
|
@@ -494,7 +488,7 @@ const m = (e) => {
|
|
|
494
488
|
return o < s ? -1 : o > s ? 1 : 0;
|
|
495
489
|
}) : void 0;
|
|
496
490
|
}
|
|
497
|
-
},
|
|
491
|
+
}, B = {
|
|
498
492
|
/**
|
|
499
493
|
* 角度(度数)转弧度
|
|
500
494
|
* 在数学和编程里,角度有两种常用单位,分别是度(°)和弧度(rad)。
|
|
@@ -516,12 +510,12 @@ const m = (e) => {
|
|
|
516
510
|
*/
|
|
517
511
|
getDistance(e, n, t, r) {
|
|
518
512
|
const o = this.degrees2Radians(e), s = this.degrees2Radians(t), l = o - s, c = this.degrees2Radians(n) - this.degrees2Radians(r);
|
|
519
|
-
let
|
|
513
|
+
let i = 2 * Math.asin(
|
|
520
514
|
Math.sqrt(
|
|
521
515
|
Math.pow(Math.sin(l / 2), 2) + Math.cos(o) * Math.cos(s) * Math.pow(Math.sin(c / 2), 2)
|
|
522
516
|
)
|
|
523
517
|
);
|
|
524
|
-
return
|
|
518
|
+
return i = i * 6378.137, i = Math.round(i * 1e4) / 1e4, i = +i.toFixed(2), console.log("经纬度计算的距离为:" + i), i;
|
|
525
519
|
},
|
|
526
520
|
/**
|
|
527
521
|
* 计算两个坐标点之间的距离(Haversine公式)
|
|
@@ -542,7 +536,7 @@ const m = (e) => {
|
|
|
542
536
|
const r = this, o = e.longitude ?? e.lng, s = e.latitude ?? e.lat, l = n.longitude ?? n.lng, c = n.latitude ?? n.lat;
|
|
543
537
|
if (o === void 0 || s === void 0 || l === void 0 || c === void 0)
|
|
544
538
|
throw new Error("无效的坐标格式,缺少经纬度信息");
|
|
545
|
-
const
|
|
539
|
+
const i = 6371, g = r.degrees2Radians(s), a = r.degrees2Radians(c), u = r.degrees2Radians(c - s), f = r.degrees2Radians(l - o), d = Math.sin(u / 2) * Math.sin(u / 2) + Math.cos(g) * Math.cos(a) * Math.sin(f / 2) * Math.sin(f / 2), p = 2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d)), h = i * p;
|
|
546
540
|
switch (t) {
|
|
547
541
|
case "m":
|
|
548
542
|
return h * 1e3;
|
|
@@ -580,7 +574,7 @@ const m = (e) => {
|
|
|
580
574
|
return { segments: r, total: o };
|
|
581
575
|
}
|
|
582
576
|
};
|
|
583
|
-
class
|
|
577
|
+
class I {
|
|
584
578
|
/**
|
|
585
579
|
* 转换为标准金额格式(带千分位和两位小数)
|
|
586
580
|
* @param num 要转换的数字
|
|
@@ -610,17 +604,17 @@ class B {
|
|
|
610
604
|
throw new Error("输入不是有效的数字");
|
|
611
605
|
if (t > 9999999999999e-2 || t < -9999999999999e-2)
|
|
612
606
|
throw new Error("输入数字超出范围");
|
|
613
|
-
const r = t < 0, o = Math.abs(t), s = Math.floor(o), l = Math.round((o - s) * 100), c = ["零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"],
|
|
614
|
-
let
|
|
607
|
+
const r = t < 0, o = Math.abs(t), s = Math.floor(o), l = Math.round((o - s) * 100), c = ["零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"], i = ["", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾", "佰", "仟"], g = ["角", "分"];
|
|
608
|
+
let a = "", u = s;
|
|
615
609
|
if (u === 0)
|
|
616
|
-
|
|
610
|
+
a = c[0];
|
|
617
611
|
else {
|
|
618
612
|
let p = 0;
|
|
619
613
|
for (; u > 0; ) {
|
|
620
614
|
const h = u % 10;
|
|
621
|
-
h !== 0 ?
|
|
615
|
+
h !== 0 ? a = c[h] + i[p] + a : a.charAt(0) !== c[0] && (a = c[h] + a), u = Math.floor(u / 10), p++;
|
|
622
616
|
}
|
|
623
|
-
|
|
617
|
+
a = a.replace(/零+/g, "零"), a = a.replace(/零+$/, "");
|
|
624
618
|
}
|
|
625
619
|
let f = "";
|
|
626
620
|
if (l > 0) {
|
|
@@ -628,7 +622,7 @@ class B {
|
|
|
628
622
|
p > 0 && (f += c[p] + g[0]), h > 0 && (f += c[h] + g[1]);
|
|
629
623
|
} else
|
|
630
624
|
f = "整";
|
|
631
|
-
let d = (r ? "负" : "") +
|
|
625
|
+
let d = (r ? "负" : "") + a + "圆" + f;
|
|
632
626
|
return d === "零圆整" && (d = "零圆"), d;
|
|
633
627
|
} catch (t) {
|
|
634
628
|
return console.error("转换失败:", t), "格式错误";
|
|
@@ -641,7 +635,7 @@ const M = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], x = /*
|
|
|
641
635
|
}, Symbol.toStringTag, { value: "Module" })), S = (e) => e.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","), O = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
642
636
|
__proto__: null,
|
|
643
637
|
toMoney: S
|
|
644
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
638
|
+
}, Symbol.toStringTag, { value: "Module" })), _ = {
|
|
645
639
|
...x,
|
|
646
640
|
...O,
|
|
647
641
|
/**
|
|
@@ -652,7 +646,7 @@ const M = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], x = /*
|
|
|
652
646
|
isNumber(e) {
|
|
653
647
|
return typeof e == "number" && !isNaN(e);
|
|
654
648
|
}
|
|
655
|
-
},
|
|
649
|
+
}, T = {
|
|
656
650
|
/**
|
|
657
651
|
* 判断对象是否为空
|
|
658
652
|
* @param obj 对象
|
|
@@ -683,7 +677,7 @@ const M = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], x = /*
|
|
|
683
677
|
r instanceof Object ? (n[t] = {}, this.deepCopy(r, n[t])) : r instanceof Array ? (n[t] = [], this.deepCopy(r, n[t])) : n[t] = e[t];
|
|
684
678
|
}
|
|
685
679
|
}
|
|
686
|
-
},
|
|
680
|
+
}, $ = {
|
|
687
681
|
/**
|
|
688
682
|
* 脱敏
|
|
689
683
|
* @param phone 电话号码/手机号码
|
|
@@ -692,7 +686,7 @@ const M = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], x = /*
|
|
|
692
686
|
desensitize(e) {
|
|
693
687
|
return e ? e.replace(/^(\d{3})\d{4}(\d{4})$/, "$1****$2") || e.slice(0, 3) + "****" + e.slice(7) : "";
|
|
694
688
|
}
|
|
695
|
-
},
|
|
689
|
+
}, N = {
|
|
696
690
|
/**
|
|
697
691
|
* 生成随机颜色
|
|
698
692
|
* @returns 随机颜色值
|
|
@@ -716,7 +710,7 @@ const M = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], x = /*
|
|
|
716
710
|
uniqueId() {
|
|
717
711
|
return Date.now().toString(36) + Math.random().toString(36).substr(2, 5);
|
|
718
712
|
}
|
|
719
|
-
},
|
|
713
|
+
}, P = {
|
|
720
714
|
/**
|
|
721
715
|
* 验证手机号
|
|
722
716
|
*/
|
|
@@ -753,7 +747,7 @@ const M = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], x = /*
|
|
|
753
747
|
* 验证0.01~0.99正则:最多两位小数。0.1、0.10、0.9、0.90
|
|
754
748
|
*/
|
|
755
749
|
decimal: /^0\.(0[1-9]|[1-9][0-9]*)$/
|
|
756
|
-
},
|
|
750
|
+
}, D = {
|
|
757
751
|
/**
|
|
758
752
|
* 通过key值获取 localStorage 中存储的某个值
|
|
759
753
|
* @param key 获取的key
|
|
@@ -800,7 +794,7 @@ const M = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], x = /*
|
|
|
800
794
|
removeSession(e) {
|
|
801
795
|
sessionStorage.removeItem(e);
|
|
802
796
|
}
|
|
803
|
-
},
|
|
797
|
+
}, F = {
|
|
804
798
|
/**
|
|
805
799
|
* 判断某元素是否在字符串中-比includes()方法更兼容,includes为ES6新增方法,IE不支持。小程序也不支持
|
|
806
800
|
* @param str 字符串
|
|
@@ -871,15 +865,15 @@ const M = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], x = /*
|
|
|
871
865
|
const t = new RegExp("[?&]" + e + "=([^&#]*)", "i").exec(window.location.href);
|
|
872
866
|
return t ? decodeURIComponent(t[1]) : null;
|
|
873
867
|
};
|
|
874
|
-
function
|
|
868
|
+
function v(e) {
|
|
875
869
|
return new URLSearchParams(window.location.search).get(e);
|
|
876
870
|
}
|
|
877
|
-
const
|
|
871
|
+
const U = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
878
872
|
__proto__: null,
|
|
879
873
|
getQueryInfoByName: A,
|
|
880
|
-
getQueryParam:
|
|
881
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
882
|
-
...
|
|
874
|
+
getQueryParam: v
|
|
875
|
+
}, Symbol.toStringTag, { value: "Module" })), V = {
|
|
876
|
+
...U,
|
|
883
877
|
/**
|
|
884
878
|
* 获取当前域名
|
|
885
879
|
* @returns 当前url链接的host信息
|
|
@@ -912,37 +906,43 @@ const E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
912
906
|
r.push(...t[o]);
|
|
913
907
|
return r;
|
|
914
908
|
},
|
|
909
|
+
/**
|
|
910
|
+
* js瀑布流布局
|
|
911
|
+
* @param itemBox 瀑布流容器
|
|
912
|
+
* @param items 瀑布流元素
|
|
913
|
+
* @param step 间距
|
|
914
|
+
*/
|
|
915
915
|
jsLayout(e, n, t) {
|
|
916
916
|
const r = e.offsetWidth, o = n[0].offsetWidth, s = parseInt((r / o).toString()), l = (r - o * s) / (s - 1), c = [];
|
|
917
|
-
for (let
|
|
918
|
-
const
|
|
919
|
-
if (
|
|
920
|
-
|
|
917
|
+
for (let i = 0, g = n.length; i < g; i++) {
|
|
918
|
+
const a = n[i];
|
|
919
|
+
if (i < s)
|
|
920
|
+
a.style.left = (o + l) * i + "px", c[i] = a.offsetHeight;
|
|
921
921
|
else {
|
|
922
|
-
const {
|
|
923
|
-
|
|
922
|
+
const { index: u, value: f } = m.getMinValueAndIndex(c);
|
|
923
|
+
a.style.left = (o + l) * u + "px", a.style.top = f + t + "px", c[u] = a.offsetHeight + t + f;
|
|
924
924
|
}
|
|
925
925
|
}
|
|
926
926
|
}
|
|
927
927
|
};
|
|
928
928
|
export {
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
929
|
+
I as MoneyFormatter,
|
|
930
|
+
m as arrayUtils,
|
|
931
|
+
E as base64Utils,
|
|
932
932
|
w as booleanUtils,
|
|
933
|
-
|
|
933
|
+
L as cookieUtils,
|
|
934
934
|
j as dateUtils,
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
935
|
+
R as documentUtils,
|
|
936
|
+
C as downloadUtils,
|
|
937
|
+
k as letterUtils,
|
|
938
|
+
B as mapUtils,
|
|
939
|
+
_ as numberUtils,
|
|
940
|
+
T as objectUtils,
|
|
941
|
+
$ as phoneUtils,
|
|
942
|
+
N as randomUtils,
|
|
943
|
+
P as regexpUtils,
|
|
944
|
+
D as storageUtils,
|
|
945
|
+
F as stringUtils,
|
|
946
|
+
V as urlUtils,
|
|
947
947
|
z as waterfallUtils
|
|
948
948
|
};
|
package/dist/utils.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(c,b){typeof exports=="object"&&typeof module<"u"?b(exports):typeof define=="function"&&define.amd?define(["exports"],b):(c=typeof globalThis<"u"?globalThis:c||self,b(c.yhkitUtils={}))})(this,function(c){"use strict";const p=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 r of e)r===n&&t++;return t},indexsOfAppear(e,n){let t=-1;const r=[];do t=e.indexOf(n,t+1),t!==-1&&r.push(t);while(t!==-1);return r},sort(e,n="asc"){return e?e.sort((t,r)=>n==="asc"?t>r?1:-1:t<r?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{minV:0,minI:0};const n={minV:e[0],minI:0};for(let t=1,r=e.length;t<r;t++){const o=e[t];n.minV>o&&(n.minV=o,n.minI=t)}return n},getMaxValueAndIndex(e){if(e.length===0)return{maxV:0,maxI:0};const n={maxV:e[0],maxI:0};for(let t=1,r=e.length;t<r;t++){const o=e[t];n.maxV<o&&(n.maxV=o,n.maxI=t)}return n}},{...Object.freeze(Object.defineProperty({__proto__:null,toEnumObj:e=>{if(!e||!e.length)return{};const n={};return e.forEach(t=>{const r=Object.assign({label:t.label,text:t.label},t);n[t==null?void 0:t.value]=r}),n}},Symbol.toStringTag,{value:"Module"}))}),M={toBlob(e,n="",t=512){const o=(e.split(",")[1]||e).replace(/-/g,"+").replace(/_/g,"/"),s="=".repeat((4-o.length%4)%4),u=o+s;try{const l=atob(u),a=[];for(let h=0;h<l.length;h+=t){const i=l.slice(h,h+t),d=new Array(i.length);for(let f=0;f<i.length;f++)d[f]=i.charCodeAt(f);const g=new Uint8Array(d);a.push(g)}return new Blob(a,{type:n})}catch(l){return console.error("Failed to convert base64 to blob:",l),null}},toFile(e,n="file.txt",t="text/plain"){const o=e.replace(/^data:.+;base64,/,"").replace(/-/g,"+").replace(/_/g,"/"),s="=".repeat((4-o.length%4)%4),u=o+s,l=atob(u),a=[];for(let i=0;i<l.length;i+=512){const d=l.slice(i,i+512),g=new Array(d.length);for(let f=0;f<d.length;f++)g[f]=d.charCodeAt(f);a.push(new Uint8Array(g))}const h=new Blob(a,{type:t});return new File([h],n,{type:t})}},w={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 r=new Date;r.setTime(r.getTime()+t*24*60*60*1e3),document.cookie=`${e}=${encodeURIComponent(n)};expires=${r.toUTCString()};path=/`},deleteCookie(e){this.setCookie(e,"",-1)}},S={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(),r=new Date(n).getTime();return t>r?Math.abs(Math.floor((t-r)/(24*3600*1e3))):Math.abs(Math.floor((r-t)/(24*3600*1e3)))},uniqueId(){return Date.now().toString(36)+Math.random().toString(36).substr(2,5)},getWhichDays(e,n,t){let r=t;for(let o=1;o<n;o++)switch(o){case 1:case 3:case 5:case 7:case 8:case 10:case 12:r+=31;break;case 2:w.isLeapYear(e)?r+=29:r+=28;break;default:r+=30;break}return r}},O={getOffsetTop(e){if(!e)throw new Error("Element is not provided");if(e instanceof SVGElement){const t=e.getBoundingClientRect(),r=window.pageYOffset||document.documentElement.scrollTop;return t.top+r}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}},A={saveAsBlob(e,n){const t=document.createElement("a"),r=window.URL.createObjectURL(e);t.href=r,t.download=n,document.body.appendChild(t),t.click(),URL.revokeObjectURL(r),document.body.removeChild(t)}},E={sortFromA2Z(e){return e!=null&&e.length?e.sort((t,r)=>{const o=t.toUpperCase(),s=r.toUpperCase();return o<s?-1:o>s?1:0}):void 0}},j={degrees2Radians(e){return e*Math.PI/180},getDistance(e,n,t,r){const o=this.degrees2Radians(e),s=this.degrees2Radians(t),u=o-s,l=this.degrees2Radians(n)-this.degrees2Radians(r);let a=2*Math.asin(Math.sqrt(Math.pow(Math.sin(u/2),2)+Math.cos(o)*Math.cos(s)*Math.pow(Math.sin(l/2),2)));return a=a*6378.137,a=Math.round(a*1e4)/1e4,a=+a.toFixed(2),console.log("经纬度计算的距离为:"+a),a},calculateDistanceByHaversine(e,n,t="km"){const r=this,o=e.longitude??e.lng,s=e.latitude??e.lat,u=n.longitude??n.lng,l=n.latitude??n.lat;if(o===void 0||s===void 0||u===void 0||l===void 0)throw new Error("无效的坐标格式,缺少经纬度信息");const a=6371,h=r.degrees2Radians(s),i=r.degrees2Radians(l),d=r.degrees2Radians(l-s),g=r.degrees2Radians(u-o),f=Math.sin(d/2)*Math.sin(d/2)+Math.cos(h)*Math.cos(i)*Math.sin(g/2)*Math.sin(g/2),y=2*Math.atan2(Math.sqrt(f),Math.sqrt(1-f)),m=a*y;switch(t){case"m":return m*1e3;case"mi":return m*.621371;case"nmi":return m*.539957;default:return m}},calculateDistancesByHaversine(e,n="km",t=!1){if(e.length<2)return{segments:[],total:0};const r=[];let o=0;for(let s=0;s<e.length-1;s++){const u=this.calculateDistanceByHaversine(e[s],e[s+1],n);r.push(u),o+=u}if(t&&e.length>2){const s=this.calculateDistanceByHaversine(e[e.length-1],e[0],n);r.push(s),o+=s}return{segments:r,total:o}}};class L{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 r=t<0,o=Math.abs(t),s=Math.floor(o),u=Math.round((o-s)*100),l=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],a=["","拾","佰","仟","万","拾","佰","仟","亿","拾","佰","仟"],h=["角","分"];let i="",d=s;if(d===0)i=l[0];else{let y=0;for(;d>0;){const m=d%10;m!==0?i=l[m]+a[y]+i:i.charAt(0)!==l[0]&&(i=l[m]+i),d=Math.floor(d/10),y++}i=i.replace(/零+/g,"零"),i=i.replace(/零+$/,"")}let g="";if(u>0){const y=Math.floor(u/10),m=u%10;y>0&&(g+=l[y]+h[0]),m>0&&(g+=l[m]+h[1])}else g="整";let f=(r?"负":"")+i+"圆"+g;return f==="零圆整"&&(f="零圆"),f}catch(t){return console.error("转换失败:",t),"格式错误"}}}const x={...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)}},I={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 r=e[t];r instanceof Object?(n[t]={},this.deepCopy(r,n[t])):r instanceof Array?(n[t]=[],this.deepCopy(r,n[t])):n[t]=e[t]}}},v={desensitize(e){return e?e.replace(/^(\d{3})\d{4}(\d{4})$/,"$1****$2")||e.slice(0,3)+"****"+e.slice(7):""}},R={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)}},k={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]*)$/},C={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)}},T={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 r=[];do t=e.indexOf(n,t+1),t!==-1&&r.push(t);while(t!==-1);return r},getMaxTimesAndVal(e){const n=[0,""],t={};for(let s=0;s<e.length;s++){const u=e.charAt(s);t[u]?t[u]++:t[u]=1}let r=1;for(const s in t)r<t[s]&&(r=t[s]);const o=[];for(const s in t)r==t[s]&&o.push(s);return n[0]=r,n[1]=o.join(),n}},B=e=>{const t=new RegExp("[?&]"+e+"=([^&#]*)","i").exec(window.location.href);return t?decodeURIComponent(t[1]):null};function V(e){return new URLSearchParams(window.location.search).get(e)}const _={...Object.freeze(Object.defineProperty({__proto__:null,getQueryInfoByName:B,getQueryParam:V},Symbol.toStringTag,{value:"Module"})),getHost(){return window.location.host},getPath(){return window.location.pathname}},$={toList(e,n=2){console.log(e,n);const t={};for(let o=0;o<n;o++)t[o]=[];e.forEach((o,s)=>t[s%n].push(o));const r=[];for(const o in t)r.push(...t[o]);return r},jsLayout(e,n,t){const r=e.offsetWidth,o=n[0].offsetWidth,s=parseInt((r/o).toString()),u=(r-o*s)/(s-1),l=[];for(let a=0,h=n.length;a<h;a++){const i=n[a];if(a<s)i.style.left=(o+u)*a+"px",l[a]=i.offsetHeight;else{const{minI:d,minV:g}=p.getMinValueAndIndex(l);i.style.left=(o+u)*d+"px",i.style.top=g+t+"px",l[d]=i.offsetHeight+t+g}}}};c.MoneyFormatter=L,c.arrayUtils=p,c.base64Utils=M,c.booleanUtils=w,c.cookieUtils=U,c.dateUtils=S,c.documentUtils=O,c.downloadUtils=A,c.letterUtils=E,c.mapUtils=j,c.numberUtils=x,c.objectUtils=I,c.phoneUtils=v,c.randomUtils=R,c.regexUtils=k,c.storageUtils=C,c.stringUtils=T,c.urlUtils=_,c.waterfallUtils=$,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(l,b){typeof exports=="object"&&typeof module<"u"?b(exports):typeof define=="function"&&define.amd?define(["exports"],b):(l=typeof globalThis<"u"?globalThis:l||self,b(l.yhkitUtils={}))})(this,function(l){"use strict";const m=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 r of e)r===n&&t++;return t},indexsOfAppear(e,n){let t=-1;const r=[];do t=e.indexOf(n,t+1),t!==-1&&r.push(t);while(t!==-1);return r},sort(e,n="asc"){return e?e.sort((t,r)=>n==="asc"?t>r?1:-1:t<r?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,r=e.length;t<r;t++){const o=e[t];n.value>o&&(n.value=o,n.index=t)}return n},getMaxValueAndIndex(e){return e.length===0?{value:0,index:0}:e.reduce((n,t,r)=>t<n.value?{value:t,index:r}: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 r=Object.assign({label:t.label,text:t.label},t);n[t==null?void 0:t.value]=r}),n}},Symbol.toStringTag,{value:"Module"}))}),M={toBlob(e,n="",t=512){const o=(e.split(",")[1]||e).replace(/-/g,"+").replace(/_/g,"/"),s="=".repeat((4-o.length%4)%4),u=o+s;try{const c=atob(u),a=[];for(let h=0;h<c.length;h+=t){const i=c.slice(h,h+t),d=new Array(i.length);for(let f=0;f<i.length;f++)d[f]=i.charCodeAt(f);const g=new Uint8Array(d);a.push(g)}return new Blob(a,{type:n})}catch(c){return console.error("Failed to convert base64 to blob:",c),null}},toFile(e,n="file.txt",t="text/plain"){const o=e.replace(/^data:.+;base64,/,"").replace(/-/g,"+").replace(/_/g,"/"),s="=".repeat((4-o.length%4)%4),u=o+s,c=atob(u),a=[];for(let i=0;i<c.length;i+=512){const d=c.slice(i,i+512),g=new Array(d.length);for(let f=0;f<d.length;f++)g[f]=d.charCodeAt(f);a.push(new Uint8Array(g))}const h=new Blob(a,{type:t});return new File([h],n,{type:t})}},w={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 r=new Date;r.setTime(r.getTime()+t*24*60*60*1e3),document.cookie=`${e}=${encodeURIComponent(n)};expires=${r.toUTCString()};path=/`},deleteCookie(e){this.setCookie(e,"",-1)}},S={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(),r=new Date(n).getTime();return t>r?Math.abs(Math.floor((t-r)/(24*3600*1e3))):Math.abs(Math.floor((r-t)/(24*3600*1e3)))},uniqueId(){return Date.now().toString(36)+Math.random().toString(36).substr(2,5)},getWhichDays(e,n,t){let r=t;for(let o=1;o<n;o++)switch(o){case 1:case 3:case 5:case 7:case 8:case 10:case 12:r+=31;break;case 2:w.isLeapYear(e)?r+=29:r+=28;break;default:r+=30;break}return r}},O={getOffsetTop(e){if(!e)throw new Error("Element is not provided");if(e instanceof SVGElement){const t=e.getBoundingClientRect(),r=window.pageYOffset||document.documentElement.scrollTop;return t.top+r}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}},v={saveAsBlob(e,n){const t=document.createElement("a"),r=window.URL.createObjectURL(e);t.href=r,t.download=n,document.body.appendChild(t),t.click(),URL.revokeObjectURL(r),document.body.removeChild(t)}},A={sortFromA2Z(e){return e!=null&&e.length?e.sort((t,r)=>{const o=t.toUpperCase(),s=r.toUpperCase();return o<s?-1:o>s?1:0}):void 0}},E={degrees2Radians(e){return e*Math.PI/180},getDistance(e,n,t,r){const o=this.degrees2Radians(e),s=this.degrees2Radians(t),u=o-s,c=this.degrees2Radians(n)-this.degrees2Radians(r);let a=2*Math.asin(Math.sqrt(Math.pow(Math.sin(u/2),2)+Math.cos(o)*Math.cos(s)*Math.pow(Math.sin(c/2),2)));return a=a*6378.137,a=Math.round(a*1e4)/1e4,a=+a.toFixed(2),console.log("经纬度计算的距离为:"+a),a},calculateDistanceByHaversine(e,n,t="km"){const r=this,o=e.longitude??e.lng,s=e.latitude??e.lat,u=n.longitude??n.lng,c=n.latitude??n.lat;if(o===void 0||s===void 0||u===void 0||c===void 0)throw new Error("无效的坐标格式,缺少经纬度信息");const a=6371,h=r.degrees2Radians(s),i=r.degrees2Radians(c),d=r.degrees2Radians(c-s),g=r.degrees2Radians(u-o),f=Math.sin(d/2)*Math.sin(d/2)+Math.cos(h)*Math.cos(i)*Math.sin(g/2)*Math.sin(g/2),p=2*Math.atan2(Math.sqrt(f),Math.sqrt(1-f)),y=a*p;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 r=[];let o=0;for(let s=0;s<e.length-1;s++){const u=this.calculateDistanceByHaversine(e[s],e[s+1],n);r.push(u),o+=u}if(t&&e.length>2){const s=this.calculateDistanceByHaversine(e[e.length-1],e[0],n);r.push(s),o+=s}return{segments:r,total:o}}};class j{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 r=t<0,o=Math.abs(t),s=Math.floor(o),u=Math.round((o-s)*100),c=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],a=["","拾","佰","仟","万","拾","佰","仟","亿","拾","佰","仟"],h=["角","分"];let i="",d=s;if(d===0)i=c[0];else{let p=0;for(;d>0;){const y=d%10;y!==0?i=c[y]+a[p]+i:i.charAt(0)!==c[0]&&(i=c[y]+i),d=Math.floor(d/10),p++}i=i.replace(/零+/g,"零"),i=i.replace(/零+$/,"")}let g="";if(u>0){const p=Math.floor(u/10),y=u%10;p>0&&(g+=c[p]+h[0]),y>0&&(g+=c[y]+h[1])}else g="整";let f=(r?"负":"")+i+"圆"+g;return f==="零圆整"&&(f="零圆"),f}catch(t){return console.error("转换失败:",t),"格式错误"}}}const L={...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)}},x={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 r=e[t];r instanceof Object?(n[t]={},this.deepCopy(r,n[t])):r instanceof Array?(n[t]=[],this.deepCopy(r,n[t])):n[t]=e[t]}}},R={desensitize(e){return e?e.replace(/^(\d{3})\d{4}(\d{4})$/,"$1****$2")||e.slice(0,3)+"****"+e.slice(7):""}},k={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)}},C={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]*)$/},T={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)}},B={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 r=[];do t=e.indexOf(n,t+1),t!==-1&&r.push(t);while(t!==-1);return r},getMaxTimesAndVal(e){const n=[0,""],t={};for(let s=0;s<e.length;s++){const u=e.charAt(s);t[u]?t[u]++:t[u]=1}let r=1;for(const s in t)r<t[s]&&(r=t[s]);const o=[];for(const s in t)r==t[s]&&o.push(s);return n[0]=r,n[1]=o.join(),n}},I=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 $={...Object.freeze(Object.defineProperty({__proto__:null,getQueryInfoByName:I,getQueryParam:_},Symbol.toStringTag,{value:"Module"})),getHost(){return window.location.host},getPath(){return window.location.pathname}},P={toList(e,n=2){console.log(e,n);const t={};for(let o=0;o<n;o++)t[o]=[];e.forEach((o,s)=>t[s%n].push(o));const r=[];for(const o in t)r.push(...t[o]);return r},jsLayout(e,n,t){const r=e.offsetWidth,o=n[0].offsetWidth,s=parseInt((r/o).toString()),u=(r-o*s)/(s-1),c=[];for(let a=0,h=n.length;a<h;a++){const i=n[a];if(a<s)i.style.left=(o+u)*a+"px",c[a]=i.offsetHeight;else{const{index:d,value:g}=m.getMinValueAndIndex(c);i.style.left=(o+u)*d+"px",i.style.top=g+t+"px",c[d]=i.offsetHeight+t+g}}}};l.MoneyFormatter=j,l.arrayUtils=m,l.base64Utils=M,l.booleanUtils=w,l.cookieUtils=U,l.dateUtils=S,l.documentUtils=O,l.downloadUtils=v,l.letterUtils=A,l.mapUtils=E,l.numberUtils=L,l.objectUtils=x,l.phoneUtils=R,l.randomUtils=k,l.regexpUtils=C,l.storageUtils=T,l.stringUtils=B,l.urlUtils=$,l.waterfallUtils=P,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -66,17 +66,17 @@ export declare const arrayUtils: {
|
|
|
66
66
|
* @returns 最小值和索引
|
|
67
67
|
*/
|
|
68
68
|
getMinValueAndIndex(array: number[]): {
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
value: number;
|
|
70
|
+
index: number;
|
|
71
71
|
};
|
|
72
72
|
/**
|
|
73
73
|
* 获取数组中的最大值和索引
|
|
74
|
-
* @param
|
|
74
|
+
* @param arr 数组
|
|
75
75
|
* @returns 最大值和索引
|
|
76
76
|
*/
|
|
77
|
-
getMaxValueAndIndex(
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
getMaxValueAndIndex(arr: number[]): {
|
|
78
|
+
value: number;
|
|
79
|
+
index: number;
|
|
80
80
|
};
|
|
81
81
|
} & {
|
|
82
82
|
toEnumObj: (arr: import("@yh-kit/types").IOptionItem[]) => import("@yh-kit/types").TValueEnum;
|
|
@@ -9,5 +9,11 @@ export declare const waterfallUtils: {
|
|
|
9
9
|
* @returns 适合瀑布流布局的数组
|
|
10
10
|
*/
|
|
11
11
|
toList<T>(list: T[], columnsNum?: number): any[];
|
|
12
|
+
/**
|
|
13
|
+
* js瀑布流布局
|
|
14
|
+
* @param itemBox 瀑布流容器
|
|
15
|
+
* @param items 瀑布流元素
|
|
16
|
+
* @param step 间距
|
|
17
|
+
*/
|
|
12
18
|
jsLayout(itemBox: HTMLElement, items: HTMLElement[], step: number): void;
|
|
13
19
|
};
|