@yh-kit/utils 1.13.0 → 1.14.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/README.md CHANGED
@@ -8,8 +8,38 @@
8
8
  npm i @yh-kit/utils
9
9
  ```
10
10
 
11
+ ## 包含的工具函数
12
+
13
+ 此库包含以下工具函数,及其函数名如下:
14
+
15
+ | 函数对象名 | 描述 | 函数实现方式 |
16
+ | :------ | :------ | :------ |
17
+ | arrayUtils | 数组相关操作工具函数 | js对象函数 |
18
+ | Base64Utils | Base64 相关操作工具函数 | class类 |
19
+ | booleanUtils | 布尔值相关操作工具函数 | js对象函数 |
20
+ | cookieUtils | Cookie 相关操作工具函数 | js对象函数 |
21
+ | dateUtils | 日期相关操作工具函数 | js对象函数 |
22
+ | documentUtils | 文档相关操作工具函数 | js对象函数 |
23
+ | downloadUtils | 下载相关操作工具函数 | js对象函数 |
24
+ | echartsUtils | Echarts 相关操作工具函数 | js对象函数 |
25
+ | letterUtils | 字母相关操作工具函数 | js对象函数 |
26
+ | mapUtils | 地图相关操作工具函数 | js对象函数 |
27
+ | MoneyFormatter | 金额格式化工具函数 | class类 |
28
+ | nameUtils | 姓名相关操作工具函数 | namespace |
29
+ | numberUtils | 数字相关操作工具函数 | js对象函数 |
30
+ | objectUtils | 对象相关操作工具函数 | js对象函数 |
31
+ | phoneUtils | 手机号相关操作工具函数 | js对象函数 |
32
+ | randomUtils | 随机数相关操作工具函数 | js对象函数 |
33
+ | regexpUtils | 常用正则表达式 | js对象函数 |
34
+ | storageUtils | 本地存储相关操作工具函数 | js对象函数 |
35
+ | stringUtils | 字符串相关操作工具函数 | js对象函数 |
36
+ | urlUtils | URL 相关操作工具函数 | js对象函数 |
37
+ | waterfallUtils | 瀑布流相关操作工具函数 | js对象函数 |
38
+
11
39
  ## 使用
12
40
 
41
+ 你可以通过以下方式引入库中的工具函数并使用它们:
42
+
13
43
  ```ts
14
44
  import { arrayUtils, numberUtils, urlUtils } from "@yh-kit/utils";
15
45
 
package/dist/utils.js CHANGED
@@ -133,7 +133,7 @@ const w = (e, n = "value") => {
133
133
  ...b
134
134
  }
135
135
  );
136
- class U {
136
+ class _ {
137
137
  /** Base64 编码表 */
138
138
  static BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
139
139
  /**
@@ -146,17 +146,17 @@ class U {
146
146
  * @returns 返回转换后的Blob对象,如果转换失败,则返回null。
147
147
  */
148
148
  static toBlob(n, t = "", r = 512) {
149
- const s = (n.split(",")[1] || n).replace(/-/g, "+").replace(/_/g, "/"), a = "=".repeat((4 - s.length % 4) % 4), u = s + a;
149
+ const s = (n.split(",")[1] || n).replace(/-/g, "+").replace(/_/g, "/"), c = "=".repeat((4 - s.length % 4) % 4), l = s + c;
150
150
  try {
151
- const i = atob(u), d = [];
152
- for (let c = 0; c < i.length; c += r) {
153
- const l = i.slice(c, c + r), h = new Array(l.length);
154
- for (let f = 0; f < l.length; f++)
155
- h[f] = l.charCodeAt(f);
156
- const p = new Uint8Array(h);
157
- d.push(p);
151
+ const i = atob(l), h = [];
152
+ for (let a = 0; a < i.length; a += r) {
153
+ const u = i.slice(a, a + r), d = new Array(u.length);
154
+ for (let f = 0; f < u.length; f++)
155
+ d[f] = u.charCodeAt(f);
156
+ const p = new Uint8Array(d);
157
+ h.push(p);
158
158
  }
159
- return new Blob(d, { type: t });
159
+ return new Blob(h, { type: t });
160
160
  } catch (i) {
161
161
  return console.error("Failed to convert base64 to blob:", i), null;
162
162
  }
@@ -172,15 +172,15 @@ class U {
172
172
  * @returns 返回一个File对象,包含解码后的数据。
173
173
  */
174
174
  static toFile(n, t = "file.txt", r = "text/plain") {
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
- for (let l = 0; l < i.length; l += 512) {
177
- const h = i.slice(l, l + 512), p = new Array(h.length);
178
- for (let f = 0; f < h.length; f++)
179
- p[f] = h.charCodeAt(f);
180
- d.push(new Uint8Array(p));
175
+ const s = n.replace(/^data:.+;base64,/, "").replace(/-/g, "+").replace(/_/g, "/"), c = "=".repeat((4 - s.length % 4) % 4), l = s + c, i = atob(l), h = [];
176
+ for (let u = 0; u < i.length; u += 512) {
177
+ const d = i.slice(u, u + 512), p = new Array(d.length);
178
+ for (let f = 0; f < d.length; f++)
179
+ p[f] = d.charCodeAt(f);
180
+ h.push(new Uint8Array(p));
181
181
  }
182
- const c = new Blob(d, { type: r });
183
- return new File([c], t, { type: r });
182
+ const a = new Blob(h, { type: r });
183
+ return new File([a], t, { type: r });
184
184
  }
185
185
  /**
186
186
  * base64加密 -- 普通字符串转 Base64 编码
@@ -218,10 +218,10 @@ class U {
218
218
  t.push(224 | o >> 12), t.push(128 | o >> 6 & 63), t.push(128 | o & 63);
219
219
  else {
220
220
  r++;
221
- const s = o, a = n.charCodeAt(r);
222
- if (isNaN(a))
221
+ const s = o, c = n.charCodeAt(r);
222
+ if (isNaN(c))
223
223
  throw new Error("代理对不完整");
224
- o = 65536 + ((s & 1023) << 10) + (a & 1023), t.push(240 | o >> 18), t.push(128 | o >> 12 & 63), t.push(128 | o >> 6 & 63), t.push(128 | o & 63);
224
+ o = 65536 + ((s & 1023) << 10) + (c & 1023), t.push(240 | o >> 18), t.push(128 | o >> 12 & 63), t.push(128 | o >> 6 & 63), t.push(128 | o & 63);
225
225
  }
226
226
  }
227
227
  return t;
@@ -239,11 +239,11 @@ class U {
239
239
  const s = n[r++] & 63;
240
240
  t += String.fromCharCode((o & 31) << 6 | s);
241
241
  } else if (o >= 224 && o < 240) {
242
- const s = n[r++] & 63, a = n[r++] & 63;
243
- t += String.fromCharCode((o & 15) << 12 | s << 6 | a);
242
+ const s = n[r++] & 63, c = n[r++] & 63;
243
+ t += String.fromCharCode((o & 15) << 12 | s << 6 | c);
244
244
  } else if (o >= 240 && o < 248) {
245
- const s = n[r++] & 63, a = n[r++] & 63, u = n[r++] & 63, i = (o & 7) << 18 | s << 12 | a << 6 | u, d = Math.floor((i - 65536) / 1024) + 55296, c = (i - 65536) % 1024 + 56320;
246
- t += String.fromCharCode(d, c);
245
+ const s = n[r++] & 63, c = n[r++] & 63, l = n[r++] & 63, i = (o & 7) << 18 | s << 12 | c << 6 | l, h = Math.floor((i - 65536) / 1024) + 55296, a = (i - 65536) % 1024 + 56320;
246
+ t += String.fromCharCode(h, a);
247
247
  } else
248
248
  t += "�";
249
249
  }
@@ -255,8 +255,8 @@ class U {
255
255
  static _bytesToBase64(n) {
256
256
  let t = "", r = 0;
257
257
  for (; r < n.length; ) {
258
- const o = n[r++], s = r < n.length, a = s ? n[r++] : 0, u = r < n.length, i = u ? n[r++] : 0, d = o >> 2, c = (o & 3) << 4 | a >> 4, l = (a & 15) << 2 | i >> 6, h = i & 63;
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) + "==";
258
+ const o = n[r++], s = r < n.length, c = s ? n[r++] : 0, l = r < n.length, i = l ? n[r++] : 0, h = o >> 2, a = (o & 3) << 4 | c >> 4, u = (c & 15) << 2 | i >> 6, d = i & 63;
259
+ s ? l ? t += this.BASE64_CHARS.charAt(h) + this.BASE64_CHARS.charAt(a) + this.BASE64_CHARS.charAt(u) + this.BASE64_CHARS.charAt(d) : t += this.BASE64_CHARS.charAt(h) + this.BASE64_CHARS.charAt(a) + this.BASE64_CHARS.charAt(u) + "=" : t += this.BASE64_CHARS.charAt(h) + this.BASE64_CHARS.charAt(a) + "==";
260
260
  }
261
261
  return t;
262
262
  }
@@ -267,20 +267,20 @@ class U {
267
267
  const t = n.length;
268
268
  let r = 0;
269
269
  t >= 2 && (n[t - 1] === "=" && r++, n[t - 2] === "=" && r++);
270
- const o = Math.floor(t * 3 / 4) - r, s = new Array(o), a = new Array(256).fill(-1);
271
- for (let d = 0; d < this.BASE64_CHARS.length; d++)
272
- a[this.BASE64_CHARS.charCodeAt(d)] = d;
273
- let u = 0, i = 0;
270
+ const o = Math.floor(t * 3 / 4) - r, s = new Array(o), c = new Array(256).fill(-1);
271
+ for (let h = 0; h < this.BASE64_CHARS.length; h++)
272
+ c[this.BASE64_CHARS.charCodeAt(h)] = h;
273
+ let l = 0, i = 0;
274
274
  for (; i < t; ) {
275
- const d = a[n.charCodeAt(i++)], c = a[n.charCodeAt(i++)], l = i < t ? a[n.charCodeAt(i++)] : -1, h = i < t ? a[n.charCodeAt(i++)] : -1;
276
- if (d === -1 || c === -1)
275
+ const h = c[n.charCodeAt(i++)], a = c[n.charCodeAt(i++)], u = i < t ? c[n.charCodeAt(i++)] : -1, d = i < t ? c[n.charCodeAt(i++)] : -1;
276
+ if (h === -1 || a === -1)
277
277
  throw new Error("无效的 Base64 字符");
278
- const p = d << 2 | c >> 4;
279
- if (s[u++] = p, l !== -1) {
280
- const f = (c & 15) << 4 | l >> 2;
281
- if (s[u++] = f, h !== -1) {
282
- const g = (l & 3) << 6 | h;
283
- s[u++] = g;
278
+ const p = h << 2 | a >> 4;
279
+ if (s[l++] = p, u !== -1) {
280
+ const f = (a & 15) << 4 | u >> 2;
281
+ if (s[l++] = f, d !== -1) {
282
+ const g = (u & 3) << 6 | d;
283
+ s[l++] = g;
284
284
  }
285
285
  }
286
286
  }
@@ -461,7 +461,7 @@ const S = {
461
461
  deleteCookie(e) {
462
462
  this.setCookie(e, "", -1);
463
463
  }
464
- }, T = {
464
+ }, L = {
465
465
  /**
466
466
  * 获取当前时间字符串
467
467
  * @param locales 区域设置。如:'zh-CN','en-US',"chinese"。默认'zh-CN'。
@@ -524,29 +524,29 @@ const S = {
524
524
  * @returns 时间字符串
525
525
  */
526
526
  getTimeStringAutoShort2(e, n) {
527
- const t = /* @__PURE__ */ new Date(), r = new Date(e), o = t.getFullYear(), s = t.getMonth() + 1, a = t.getDate(), u = r.getFullYear(), i = r.getMonth() + 1, d = r.getDate();
528
- let c = "";
529
- const l = n ? " " + this.formatDate(r, "hh:mm") : "";
530
- if (o === u) {
527
+ const t = /* @__PURE__ */ new Date(), r = new Date(e), o = t.getFullYear(), s = t.getMonth() + 1, c = t.getDate(), l = r.getFullYear(), i = r.getMonth() + 1, h = r.getDate();
528
+ let a = "";
529
+ const u = n ? " " + this.formatDate(r, "hh:mm") : "";
530
+ if (o === l) {
531
531
  const f = t.getTime() - e;
532
- if (s === i && a === d)
533
- f < 60 * 1e3 ? c = "刚刚" : c = this.formatDate(r, "hh:mm");
532
+ if (s === i && c === h)
533
+ f < 60 * 1e3 ? a = "刚刚" : a = this.formatDate(r, "hh:mm");
534
534
  else {
535
535
  const g = /* @__PURE__ */ new Date();
536
536
  g.setDate(g.getDate() - 1);
537
537
  const m = /* @__PURE__ */ new Date();
538
- if (m.setDate(m.getDate() - 2), i === g.getMonth() + 1 && d === g.getDate())
539
- c = "昨天" + l;
540
- else if (i === m.getMonth() + 1 && d === m.getDate())
541
- c = "前天" + l;
538
+ if (m.setDate(m.getDate() - 2), i === g.getMonth() + 1 && h === g.getDate())
539
+ a = "昨天" + u;
540
+ else if (i === m.getMonth() + 1 && h === m.getDate())
541
+ a = "前天" + u;
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[r.getDay()] + l;
545
- } else c = this.formatDate(r, "yyyy/M/d") + l;
544
+ y[0] = "星期日", y[1] = "星期一", y[2] = "星期二", y[3] = "星期三", y[4] = "星期四", y[5] = "星期五", y[6] = "星期六", a = y[r.getDay()] + u;
545
+ } else a = this.formatDate(r, "yyyy/M/d") + u;
546
546
  }
547
547
  } else
548
- c = this.formatDate(r, "yyyy/M/d") + l;
549
- return c;
548
+ a = this.formatDate(r, "yyyy/M/d") + u;
549
+ return a;
550
550
  },
551
551
  /**
552
552
  * 格式化日期
@@ -576,7 +576,7 @@ const S = {
576
576
  new RegExp("(" + r + ")").test(n) && (n = n.replace(RegExp.$1, RegExp.$1.length === 1 ? t[r] : ("00" + t[r]).substr(("" + t[r]).length)));
577
577
  return n;
578
578
  }
579
- }, L = {
579
+ }, T = {
580
580
  /**
581
581
  * 获取元素相对于文档顶部的偏移量(距离)
582
582
  * 处理了SVG元素的特殊情况。
@@ -710,7 +710,7 @@ const S = {
710
710
  return o < s ? -1 : o > s ? 1 : 0;
711
711
  }) : void 0;
712
712
  }
713
- }, j = {
713
+ }, $ = {
714
714
  /**
715
715
  * 角度(度数)转弧度
716
716
  * 在数学和编程里,角度有两种常用单位,分别是度(°)和弧度(rad)。
@@ -731,10 +731,10 @@ const S = {
731
731
  * @returns 距离值 单位:km
732
732
  */
733
733
  getDistance(e, n, t, r) {
734
- const o = this.degrees2Radians(e), s = this.degrees2Radians(t), a = o - s, u = this.degrees2Radians(n) - this.degrees2Radians(r);
734
+ const o = this.degrees2Radians(e), s = this.degrees2Radians(t), c = o - s, l = this.degrees2Radians(n) - this.degrees2Radians(r);
735
735
  let i = 2 * Math.asin(
736
736
  Math.sqrt(
737
- Math.pow(Math.sin(a / 2), 2) + Math.cos(o) * Math.cos(s) * Math.pow(Math.sin(u / 2), 2)
737
+ Math.pow(Math.sin(c / 2), 2) + Math.cos(o) * Math.cos(s) * Math.pow(Math.sin(l / 2), 2)
738
738
  )
739
739
  );
740
740
  return i = i * 6378.137, i = Math.round(i * 1e4) / 1e4, i = +i.toFixed(2), console.log("经纬度计算的距离为:" + i), i;
@@ -755,10 +755,10 @@ const S = {
755
755
  * @returns 距离值
756
756
  */
757
757
  calculateDistanceByHaversine(e, n, t = "km") {
758
- const r = this, o = e.longitude ?? e.lng, s = e.latitude ?? e.lat, a = n.longitude ?? n.lng, u = n.latitude ?? n.lat;
759
- if (o === void 0 || s === void 0 || a === void 0 || u === void 0)
758
+ const r = this, o = e.longitude ?? e.lng, s = e.latitude ?? e.lat, c = n.longitude ?? n.lng, l = n.latitude ?? n.lat;
759
+ if (o === void 0 || s === void 0 || c === void 0 || l === void 0)
760
760
  throw new Error("无效的坐标格式,缺少经纬度信息");
761
- const i = 6371, d = r.degrees2Radians(s), c = r.degrees2Radians(u), l = r.degrees2Radians(u - s), h = r.degrees2Radians(a - o), 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;
761
+ const i = 6371, h = r.degrees2Radians(s), a = r.degrees2Radians(l), u = r.degrees2Radians(l - s), d = r.degrees2Radians(c - o), p = Math.sin(u / 2) * Math.sin(u / 2) + Math.cos(h) * Math.cos(a) * Math.sin(d / 2) * Math.sin(d / 2), f = 2 * Math.atan2(Math.sqrt(p), Math.sqrt(1 - p)), g = i * f;
762
762
  switch (t) {
763
763
  case "m":
764
764
  return g * 1e3;
@@ -786,8 +786,8 @@ const S = {
786
786
  const r = [];
787
787
  let o = 0;
788
788
  for (let s = 0; s < e.length - 1; s++) {
789
- const a = this.calculateDistanceByHaversine(e[s], e[s + 1], n);
790
- r.push(a), o += a;
789
+ const c = this.calculateDistanceByHaversine(e[s], e[s + 1], n);
790
+ r.push(c), o += c;
791
791
  }
792
792
  if (t && e.length > 2) {
793
793
  const s = this.calculateDistanceByHaversine(e[e.length - 1], e[0], n);
@@ -796,7 +796,7 @@ const S = {
796
796
  return { segments: r, total: o };
797
797
  }
798
798
  };
799
- class $ {
799
+ class j {
800
800
  /**
801
801
  * 转换为标准金额格式(带千分位和两位小数)
802
802
  * @param num 要转换的数字
@@ -826,38 +826,81 @@ class $ {
826
826
  throw new Error("输入不是有效的数字");
827
827
  if (t > 9999999999999e-2 || t < -9999999999999e-2)
828
828
  throw new Error("输入数字超出范围");
829
- const r = t < 0, o = Math.abs(t), s = Math.floor(o), a = Math.round((o - s) * 100), u = ["零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"], i = ["", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾", "佰", "仟"], d = ["角", "分"];
830
- let c = "", l = s;
831
- if (l === 0)
832
- c = u[0];
829
+ const r = t < 0, o = Math.abs(t), s = Math.floor(o), c = Math.round((o - s) * 100), l = ["零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"], i = ["", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾", "佰", "仟"], h = ["角", "分"];
830
+ let a = "", u = s;
831
+ if (u === 0)
832
+ a = l[0];
833
833
  else {
834
834
  let f = 0;
835
- for (; l > 0; ) {
836
- const g = l % 10;
837
- g !== 0 ? c = u[g] + i[f] + c : c.charAt(0) !== u[0] && (c = u[g] + c), l = Math.floor(l / 10), f++;
835
+ for (; u > 0; ) {
836
+ const g = u % 10;
837
+ g !== 0 ? a = l[g] + i[f] + a : a.charAt(0) !== l[0] && (a = l[g] + a), u = Math.floor(u / 10), f++;
838
838
  }
839
- c = c.replace(/零+/g, "零"), c = c.replace(/零+$/, "");
839
+ a = a.replace(/零+/g, "零"), a = a.replace(/零+$/, "");
840
840
  }
841
- let h = "";
842
- if (a > 0) {
843
- const f = Math.floor(a / 10), g = a % 10;
844
- f > 0 && (h += u[f] + d[0]), g > 0 && (h += u[g] + d[1]);
841
+ let d = "";
842
+ if (c > 0) {
843
+ const f = Math.floor(c / 10), g = c % 10;
844
+ f > 0 && (d += l[f] + h[0]), g > 0 && (d += l[g] + h[1]);
845
845
  } else
846
- h = "整";
847
- let p = (r ? "负" : "") + c + "圆" + h;
846
+ d = "整";
847
+ let p = (r ? "负" : "") + a + "圆" + d;
848
848
  return p === "零圆整" && (p = "零圆"), p;
849
849
  } catch (t) {
850
850
  return console.error("转换失败:", t), "格式错误";
851
851
  }
852
852
  }
853
853
  }
854
- const M = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], x = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
854
+ const N = {
855
+ /**
856
+ * 中文姓名脱敏
857
+ * @param name 姓名
858
+ * @param options 脱敏选项
859
+ * @returns 脱敏后的姓名
860
+ */
861
+ desensitizeChineseName(e, n = {}) {
862
+ const { keepLength: t = 1, keepLast: r = !1 } = n;
863
+ if (!e || e.length === 0 || e.trim().length === 0)
864
+ throw new Error("姓名不能为空");
865
+ if (typeof e != "string")
866
+ throw new Error("姓名必须是字符串");
867
+ if (e.length <= 1)
868
+ return e;
869
+ const o = [
870
+ "欧阳",
871
+ "司马",
872
+ "上官",
873
+ "东方",
874
+ "独孤",
875
+ "南宫",
876
+ "闻人",
877
+ "夏侯",
878
+ "诸葛",
879
+ "尉迟",
880
+ "公孙",
881
+ "长孙",
882
+ "宇文",
883
+ "司徒",
884
+ "慕容"
885
+ ];
886
+ n.compoundSurname && n.compoundSurname.trim().length > 0 && !o.includes(n.compoundSurname) && o.push(n.compoundSurname);
887
+ let s = "";
888
+ o.some((l) => e.startsWith(l)) ? s = o.find((l) => e.startsWith(l)) || "" : s = e[0] || "";
889
+ const c = Math.max(t, s.length);
890
+ if (c >= e.length) return e;
891
+ if (r && e.length > 2) {
892
+ const l = e.slice(0, c), i = e.slice(-1), h = e.length - c - 1;
893
+ return `${l}${"*".repeat(h)}${i}`;
894
+ }
895
+ return `${e.slice(0, c)}${"*".repeat(e.length - c)}`;
896
+ }
897
+ }, M = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], x = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
855
898
  __proto__: null,
856
899
  toLetter: M
857
900
  }, Symbol.toStringTag, { value: "Module" })), E = (e) => e.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","), C = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
858
901
  __proto__: null,
859
902
  toMoney: E
860
- }, Symbol.toStringTag, { value: "Module" })), N = {
903
+ }, Symbol.toStringTag, { value: "Module" })), P = {
861
904
  ...x,
862
905
  ...C,
863
906
  /**
@@ -868,14 +911,14 @@ const M = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], x = /*
868
911
  isNumber(e) {
869
912
  return typeof e == "number" && !isNaN(e);
870
913
  }
871
- }, P = {
914
+ }, F = {
872
915
  /**
873
916
  * 判断对象是否为空
874
917
  * @param obj 对象
875
918
  * @returns 是否为空。true 为空;false 不为空
876
919
  */
877
920
  isEmptyObject(e) {
878
- return e ? Object.keys(e).length === 0 && e.constructor === Object : !0;
921
+ return !e || JSON.stringify(e) === "{}" ? !0 : Object.keys(e).length === 0 && e.constructor === Object;
879
922
  },
880
923
  /**
881
924
  * 复制对象【对象的浅拷贝 把obj1的成员,复制给obj2】
@@ -899,7 +942,7 @@ const M = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], x = /*
899
942
  r instanceof Object ? (n[t] = {}, this.deepCopy(r, n[t])) : r instanceof Array ? (n[t] = [], this.deepCopy(r, n[t])) : n[t] = e[t];
900
943
  }
901
944
  }
902
- }, F = {
945
+ }, V = {
903
946
  /**
904
947
  * 脱敏
905
948
  * @param phone 电话号码/手机号码
@@ -908,7 +951,7 @@ const M = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], x = /*
908
951
  desensitize(e) {
909
952
  return e ? e.replace(/^(\d{3})\d{4}(\d{4})$/, "$1****$2") || e.slice(0, 3) + "****" + e.slice(7) : "";
910
953
  }
911
- }, V = {
954
+ }, W = {
912
955
  /**
913
956
  * 生成随机颜色
914
957
  * @returns 随机颜色值
@@ -932,7 +975,7 @@ const M = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], x = /*
932
975
  uniqueId() {
933
976
  return Date.now().toString(36) + Math.random().toString(36).substr(2, 5);
934
977
  }
935
- }, W = {
978
+ }, Y = {
936
979
  /**
937
980
  * 验证手机号
938
981
  */
@@ -969,7 +1012,7 @@ const M = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], x = /*
969
1012
  * 验证0.01~0.99正则:最多两位小数。0.1、0.10、0.9、0.90
970
1013
  */
971
1014
  decimal: /^0\.(0[1-9]|[1-9][0-9]*)$/
972
- }, Y = {
1015
+ }, z = {
973
1016
  /**
974
1017
  * 通过key值获取 localStorage 中存储的某个值
975
1018
  * @param key 获取的key
@@ -1016,7 +1059,7 @@ const M = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], x = /*
1016
1059
  removeSession(e) {
1017
1060
  sessionStorage.removeItem(e);
1018
1061
  }
1019
- }, z = {
1062
+ }, q = {
1020
1063
  /**
1021
1064
  * 判断某元素是否在字符串中-比includes()方法更兼容,includes为ES6新增方法,IE不支持。小程序也不支持
1022
1065
  * @param str 字符串
@@ -1072,8 +1115,8 @@ const M = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], x = /*
1072
1115
  getMaxTimesAndVal(e) {
1073
1116
  const n = [0, ""], t = {};
1074
1117
  for (let s = 0; s < e.length; s++) {
1075
- const a = e.charAt(s);
1076
- t[a] ? t[a]++ : t[a] = 1;
1118
+ const c = e.charAt(s);
1119
+ t[c] ? t[c]++ : t[c] = 1;
1077
1120
  }
1078
1121
  let r = 1;
1079
1122
  for (const s in t)
@@ -1093,11 +1136,11 @@ const M = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], x = /*
1093
1136
  mask(e, n, t) {
1094
1137
  if (!e)
1095
1138
  throw new Error("字符串为空");
1096
- if (!n || !t)
1139
+ if (typeof n != "number" || typeof t != "number")
1097
1140
  throw new Error("开始位置或结束位置为空");
1098
1141
  if (n < 0 || t > e.length || n > t)
1099
1142
  throw new Error("开始位置小于0或结束位置超出字符串长度或开始位置大于结束位置");
1100
- return e.slice(0, n) + "****" + e.slice(t);
1143
+ return e.slice(0, n) + "*".repeat(t - n + 1) + e.slice(t);
1101
1144
  }
1102
1145
  }, B = (e) => {
1103
1146
  const t = new RegExp("[?&]" + e + "=([^&#]*)", "i").exec(window.location.href);
@@ -1110,7 +1153,7 @@ const R = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1110
1153
  __proto__: null,
1111
1154
  getQueryInfoByName: B,
1112
1155
  getQueryParam: D
1113
- }, Symbol.toStringTag, { value: "Module" })), q = {
1156
+ }, Symbol.toStringTag, { value: "Module" })), Z = {
1114
1157
  ...R,
1115
1158
  /**
1116
1159
  * 获取当前域名
@@ -1126,7 +1169,7 @@ const R = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1126
1169
  getPath() {
1127
1170
  return window.location.pathname;
1128
1171
  }
1129
- }, Z = {
1172
+ }, J = {
1130
1173
  /**
1131
1174
  * 处理瀑布流数据,使其竖向瀑布流布局呈现横向瀑布流的展现形式。适用于 column-gap: 20rpx; column-count: 2; 布局的瀑布流
1132
1175
  * @param list 瀑布流数据-数组
@@ -1151,37 +1194,38 @@ const R = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1151
1194
  * @param step 间距
1152
1195
  */
1153
1196
  jsLayout(e, n, t) {
1154
- const r = e.offsetWidth, o = n[0].offsetWidth, s = parseInt((r / o).toString()), a = (r - o * s) / (s - 1), u = [];
1155
- for (let i = 0, d = n.length; i < d; i++) {
1156
- const c = n[i];
1197
+ const r = e.offsetWidth, o = n[0].offsetWidth, s = parseInt((r / o).toString()), c = (r - o * s) / (s - 1), l = [];
1198
+ for (let i = 0, h = n.length; i < h; i++) {
1199
+ const a = n[i];
1157
1200
  if (i < s)
1158
- c.style.left = (o + a) * i + "px", u[i] = c.offsetHeight;
1201
+ a.style.left = (o + c) * i + "px", l[i] = a.offsetHeight;
1159
1202
  else {
1160
- const { index: l, value: h } = A.getMinValueAndIndex(u);
1161
- c.style.left = (o + a) * l + "px", c.style.top = h + t + "px", u[l] = c.offsetHeight + t + h;
1203
+ const { index: u, value: d } = A.getMinValueAndIndex(l);
1204
+ a.style.left = (o + c) * u + "px", a.style.top = d + t + "px", l[u] = a.offsetHeight + t + d;
1162
1205
  }
1163
1206
  }
1164
1207
  }
1165
1208
  };
1166
1209
  export {
1167
- U as Base64Utils,
1168
- $ as MoneyFormatter,
1210
+ _ as Base64Utils,
1211
+ j as MoneyFormatter,
1169
1212
  A as arrayUtils,
1170
1213
  S as booleanUtils,
1171
1214
  O as cookieUtils,
1172
- T as dateUtils,
1173
- L as documentUtils,
1215
+ L as dateUtils,
1216
+ T as documentUtils,
1174
1217
  I as downloadUtils,
1175
1218
  k as echartsUtils,
1176
1219
  H as letterUtils,
1177
- j as mapUtils,
1178
- N as numberUtils,
1179
- P as objectUtils,
1180
- F as phoneUtils,
1181
- V as randomUtils,
1182
- W as regexpUtils,
1183
- Y as storageUtils,
1184
- z as stringUtils,
1185
- q as urlUtils,
1186
- Z as waterfallUtils
1220
+ $ as mapUtils,
1221
+ N as nameUtils,
1222
+ P as numberUtils,
1223
+ F as objectUtils,
1224
+ V as phoneUtils,
1225
+ W as randomUtils,
1226
+ Y as regexpUtils,
1227
+ z as storageUtils,
1228
+ q as stringUtils,
1229
+ Z as urlUtils,
1230
+ J as waterfallUtils
1187
1231
  };
@@ -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,n="value")=>{if(!e||!e.length)return{};const t={};return e.forEach(o=>{const r=Object.assign({label:o.label,text:o.label},o);t[o[n]]=r}),t}},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,"/"),a="=".repeat((4-s.length%4)%4),u=s+a;try{const i=atob(u),d=[];for(let c=0;c<i.length;c+=o){const l=i.slice(c,c+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,"/"),a="=".repeat((4-s.length%4)%4),u=s+a,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 c=new Blob(d,{type:o});return new File([c],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,a=n.charCodeAt(o);if(isNaN(a))throw new Error("代理对不完整");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)}}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,a=n[o++]&63;t+=String.fromCharCode((r&15)<<12|s<<6|a)}else if(r>=240&&r<248){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;t+=String.fromCharCode(d,c)}else t+="�"}return t}static _bytesToBase64(n){let t="",o=0;for(;o<n.length;){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,f=i&63;s?u?t+=this.BASE64_CHARS.charAt(d)+this.BASE64_CHARS.charAt(c)+this.BASE64_CHARS.charAt(l)+this.BASE64_CHARS.charAt(f):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)+"=="}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),a=new Array(256).fill(-1);for(let d=0;d<this.BASE64_CHARS.length;d++)a[this.BASE64_CHARS.charCodeAt(d)]=d;let u=0,i=0;for(;i<t;){const d=a[n.charCodeAt(i++)],c=a[n.charCodeAt(i++)],l=i<t?a[n.charCodeAt(i++)]:-1,f=i<t?a[n.charCodeAt(i++)]:-1;if(d===-1||c===-1)throw new Error("无效的 Base64 字符");const p=d<<2|c>>4;if(s[u++]=p,l!==-1){const g=(c&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,a=t.getDate(),u=o.getFullYear(),i=o.getMonth()+1,d=o.getDate();let c="";const l=n?" "+this.formatDate(o,"hh:mm"):"";if(r===u){const g=t.getTime()-e;if(s===i&&a===d)g<60*1e3?c="刚刚":c=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())c="昨天"+l;else if(i===b.getMonth()+1&&d===b.getDate())c="前天"+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]="星期六",c=m[o.getDay()]+l}else c=this.formatDate(o,"yyyy/M/d")+l}}else c=this.formatDate(o,"yyyy/M/d")+l;return c},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),a=r-s,u=this.degrees2Radians(n)-this.degrees2Radians(o);let i=2*Math.asin(Math.sqrt(Math.pow(Math.sin(a/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,a=n.longitude??n.lng,u=n.latitude??n.lat;if(r===void 0||s===void 0||a===void 0||u===void 0)throw new Error("无效的坐标格式,缺少经纬度信息");const i=6371,d=o.degrees2Radians(s),c=o.degrees2Radians(u),l=o.degrees2Radians(u-s),f=o.degrees2Radians(a-r),p=Math.sin(l/2)*Math.sin(l/2)+Math.cos(d)*Math.cos(c)*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 a=this.calculateDistanceByHaversine(e[s],e[s+1],n);o.push(a),r+=a}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),a=Math.round((r-s)*100),u=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],i=["","拾","佰","仟","万","拾","佰","仟","亿","拾","佰","仟"],d=["角","分"];let c="",l=s;if(l===0)c=u[0];else{let g=0;for(;l>0;){const y=l%10;y!==0?c=u[y]+i[g]+c:c.charAt(0)!==u[0]&&(c=u[y]+c),l=Math.floor(l/10),g++}c=c.replace(/零+/g,"零"),c=c.replace(/零+$/,"")}let f="";if(a>0){const g=Math.floor(a/10),y=a%10;g>0&&(f+=u[g]+d[0]),y>0&&(f+=u[y]+d[1])}else f="整";let p=(o?"负":"")+c+"圆"+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 a=e.charAt(s);t[a]?t[a]++:t[a]=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},mask(e,n,t){if(!e)throw new Error("字符串为空");if(!n||!t)throw new Error("开始位置或结束位置为空");if(n<0||t>e.length||n>t)throw new Error("开始位置小于0或结束位置超出字符串长度或开始位置大于结束位置");return e.slice(0,n)+"****"+e.slice(t)}},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()),a=(o-r*s)/(s-1),u=[];for(let i=0,d=n.length;i<d;i++){const c=n[i];if(i<s)c.style.left=(r+a)*i+"px",u[i]=c.offsetHeight;else{const{index:l,value:f}=A.getMinValueAndIndex(u);c.style.left=(r+a)*l+"px",c.style.top=f+t+"px",u[l]=c.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"})});
1
+ (function(d,w){typeof exports=="object"&&typeof module<"u"?w(exports):typeof define=="function"&&define.amd?define(["exports"],w):(d=typeof globalThis<"u"?globalThis:d||self,w(d.yhkitUtils={}))})(this,function(d){"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 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,n="value")=>{if(!e||!e.length)return{};const t={};return e.forEach(r=>{const o=Object.assign({label:r.label,text:r.label},r);t[r[n]]=o}),t}},Symbol.toStringTag,{value:"Module"}))});class M{static BASE64_CHARS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";static toBlob(n,t="",r=512){const s=(n.split(",")[1]||n).replace(/-/g,"+").replace(/_/g,"/"),c="=".repeat((4-s.length%4)%4),l=s+c;try{const i=atob(l),h=[];for(let a=0;a<i.length;a+=r){const u=i.slice(a,a+r),f=new Array(u.length);for(let g=0;g<u.length;g++)f[g]=u.charCodeAt(g);const y=new Uint8Array(f);h.push(y)}return new Blob(h,{type:t})}catch(i){return console.error("Failed to convert base64 to blob:",i),null}}static toFile(n,t="file.txt",r="text/plain"){const s=n.replace(/^data:.+;base64,/,"").replace(/-/g,"+").replace(/_/g,"/"),c="=".repeat((4-s.length%4)%4),l=s+c,i=atob(l),h=[];for(let u=0;u<i.length;u+=512){const f=i.slice(u,u+512),y=new Array(f.length);for(let g=0;g<f.length;g++)y[g]=f.charCodeAt(g);h.push(new Uint8Array(y))}const a=new Blob(h,{type:r});return new File([a],t,{type:r})}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 r=0;r<n.length;r++){let o=n.charCodeAt(r);if(o<128)t.push(o);else if(o<2048)t.push(192|o>>6),t.push(128|o&63);else if(o<55296||o>=57344)t.push(224|o>>12),t.push(128|o>>6&63),t.push(128|o&63);else{r++;const s=o,c=n.charCodeAt(r);if(isNaN(c))throw new Error("代理对不完整");o=65536+((s&1023)<<10)+(c&1023),t.push(240|o>>18),t.push(128|o>>12&63),t.push(128|o>>6&63),t.push(128|o&63)}}return t}static _utf8BytesToString(n){let t="",r=0;for(;r<n.length;){const o=n[r++];if(o<128)t+=String.fromCharCode(o);else if(o>=192&&o<224){const s=n[r++]&63;t+=String.fromCharCode((o&31)<<6|s)}else if(o>=224&&o<240){const s=n[r++]&63,c=n[r++]&63;t+=String.fromCharCode((o&15)<<12|s<<6|c)}else if(o>=240&&o<248){const s=n[r++]&63,c=n[r++]&63,l=n[r++]&63,i=(o&7)<<18|s<<12|c<<6|l,h=Math.floor((i-65536)/1024)+55296,a=(i-65536)%1024+56320;t+=String.fromCharCode(h,a)}else t+="�"}return t}static _bytesToBase64(n){let t="",r=0;for(;r<n.length;){const o=n[r++],s=r<n.length,c=s?n[r++]:0,l=r<n.length,i=l?n[r++]:0,h=o>>2,a=(o&3)<<4|c>>4,u=(c&15)<<2|i>>6,f=i&63;s?l?t+=this.BASE64_CHARS.charAt(h)+this.BASE64_CHARS.charAt(a)+this.BASE64_CHARS.charAt(u)+this.BASE64_CHARS.charAt(f):t+=this.BASE64_CHARS.charAt(h)+this.BASE64_CHARS.charAt(a)+this.BASE64_CHARS.charAt(u)+"=":t+=this.BASE64_CHARS.charAt(h)+this.BASE64_CHARS.charAt(a)+"=="}return t}static _base64ToBytes(n){const t=n.length;let r=0;t>=2&&(n[t-1]==="="&&r++,n[t-2]==="="&&r++);const o=Math.floor(t*3/4)-r,s=new Array(o),c=new Array(256).fill(-1);for(let h=0;h<this.BASE64_CHARS.length;h++)c[this.BASE64_CHARS.charCodeAt(h)]=h;let l=0,i=0;for(;i<t;){const h=c[n.charCodeAt(i++)],a=c[n.charCodeAt(i++)],u=i<t?c[n.charCodeAt(i++)]:-1,f=i<t?c[n.charCodeAt(i++)]:-1;if(h===-1||a===-1)throw new Error("无效的 Base64 字符");const y=h<<2|a>>4;if(s[l++]=y,u!==-1){const g=(a&15)<<4|u>>2;if(s[l++]=g,f!==-1){const p=(u&3)<<6|f;s[l++]=p}}}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 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)}},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(),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:S.isLeapYear(e)?r+=29:r+=28;break;default:r+=30;break}return r},getTimeStringAutoShort2(e,n){const t=new Date,r=new Date(e),o=t.getFullYear(),s=t.getMonth()+1,c=t.getDate(),l=r.getFullYear(),i=r.getMonth()+1,h=r.getDate();let a="";const u=n?" "+this.formatDate(r,"hh:mm"):"";if(o===l){const g=t.getTime()-e;if(s===i&&c===h)g<60*1e3?a="刚刚":a=this.formatDate(r,"hh:mm");else{const p=new Date;p.setDate(p.getDate()-1);const b=new Date;if(b.setDate(b.getDate()-2),i===p.getMonth()+1&&h===p.getDate())a="昨天"+u;else if(i===b.getMonth()+1&&h===b.getDate())a="前天"+u;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[r.getDay()]+u}else a=this.formatDate(r,"yyyy/M/d")+u}}else a=this.formatDate(r,"yyyy/M/d")+u;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 r in t)new RegExp("("+r+")").test(n)&&(n=n.replace(RegExp.$1,RegExp.$1.length===1?t[r]:("00"+t[r]).substr((""+t[r]).length)));return n}},C={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},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"),r=window.URL.createObjectURL(e);t.href=r,t.download=n,document.body.appendChild(t),t.click(),URL.revokeObjectURL(r),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 r=e.series[0].data.length;let o;o=setInterval(()=>{n.dispatchAction({type:"downplay",seriesIndex:0,dataIndex:t}),t=(t+1)%r,n.dispatchAction({type:"highlight",seriesIndex:0,dataIndex:t}),n.dispatchAction({type:"showTip",seriesIndex:0,dataIndex:t}),t>r&&(t=0)},2e3),n.on("mouseover",()=>{clearInterval(o),n.dispatchAction({type:"downplay",seriesIndex:0,dataIndex:t})})}},R={sortFromA2Z(e){return e?.length?e.sort((t,r)=>{const o=t.toUpperCase(),s=r.toUpperCase();return o<s?-1:o>s?1:0}):void 0}},v={degrees2Radians(e){return e*Math.PI/180},getDistance(e,n,t,r){const o=this.degrees2Radians(e),s=this.degrees2Radians(t),c=o-s,l=this.degrees2Radians(n)-this.degrees2Radians(r);let i=2*Math.asin(Math.sqrt(Math.pow(Math.sin(c/2),2)+Math.cos(o)*Math.cos(s)*Math.pow(Math.sin(l/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 r=this,o=e.longitude??e.lng,s=e.latitude??e.lat,c=n.longitude??n.lng,l=n.latitude??n.lat;if(o===void 0||s===void 0||c===void 0||l===void 0)throw new Error("无效的坐标格式,缺少经纬度信息");const i=6371,h=r.degrees2Radians(s),a=r.degrees2Radians(l),u=r.degrees2Radians(l-s),f=r.degrees2Radians(c-o),y=Math.sin(u/2)*Math.sin(u/2)+Math.cos(h)*Math.cos(a)*Math.sin(f/2)*Math.sin(f/2),g=2*Math.atan2(Math.sqrt(y),Math.sqrt(1-y)),p=i*g;switch(t){case"m":return p*1e3;case"mi":return p*.621371;case"nmi":return p*.539957;default:return p}},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 c=this.calculateDistanceByHaversine(e[s],e[s+1],n);r.push(c),o+=c}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 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 r=t<0,o=Math.abs(t),s=Math.floor(o),c=Math.round((o-s)*100),l=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],i=["","拾","佰","仟","万","拾","佰","仟","亿","拾","佰","仟"],h=["角","分"];let a="",u=s;if(u===0)a=l[0];else{let g=0;for(;u>0;){const p=u%10;p!==0?a=l[p]+i[g]+a:a.charAt(0)!==l[0]&&(a=l[p]+a),u=Math.floor(u/10),g++}a=a.replace(/零+/g,"零"),a=a.replace(/零+$/,"")}let f="";if(c>0){const g=Math.floor(c/10),p=c%10;g>0&&(f+=l[g]+h[0]),p>0&&(f+=l[p]+h[1])}else f="整";let y=(r?"负":"")+a+"圆"+f;return y==="零圆整"&&(y="零圆"),y}catch(t){return console.error("转换失败:",t),"格式错误"}}}const O={desensitizeChineseName(e,n={}){const{keepLength:t=1,keepLast:r=!1}=n;if(!e||e.length===0||e.trim().length===0)throw new Error("姓名不能为空");if(typeof e!="string")throw new Error("姓名必须是字符串");if(e.length<=1)return e;const o=["欧阳","司马","上官","东方","独孤","南宫","闻人","夏侯","诸葛","尉迟","公孙","长孙","宇文","司徒","慕容"];n.compoundSurname&&n.compoundSurname.trim().length>0&&!o.includes(n.compoundSurname)&&o.push(n.compoundSurname);let s="";o.some(l=>e.startsWith(l))?s=o.find(l=>e.startsWith(l))||"":s=e[0]||"";const c=Math.max(t,s.length);if(c>=e.length)return e;if(r&&e.length>2){const l=e.slice(0,c),i=e.slice(-1),h=e.length-c-1;return`${l}${"*".repeat(h)}${i}`}return`${e.slice(0,c)}${"*".repeat(e.length-c)}`}},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||JSON.stringify(e)==="{}"?!0:Object.keys(e).length===0&&e.constructor===Object},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]}}},L={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)}},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 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 c=e.charAt(s);t[c]?t[c]++:t[c]=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},mask(e,n,t){if(!e)throw new Error("字符串为空");if(typeof n!="number"||typeof t!="number")throw new Error("开始位置或结束位置为空");if(n<0||t>e.length||n>t)throw new Error("开始位置小于0或结束位置超出字符串长度或开始位置大于结束位置");return e.slice(0,n)+"*".repeat(t-n+1)+e.slice(t)}},$=e=>{const t=new RegExp("[?&]"+e+"=([^&#]*)","i").exec(window.location.href);return t?decodeURIComponent(t[1]):null};function N(e){return new URLSearchParams(window.location.search).get(e)}const P={...Object.freeze(Object.defineProperty({__proto__:null,getQueryInfoByName:$,getQueryParam:N},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 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()),c=(r-o*s)/(s-1),l=[];for(let i=0,h=n.length;i<h;i++){const a=n[i];if(i<s)a.style.left=(o+c)*i+"px",l[i]=a.offsetHeight;else{const{index:u,value:f}=A.getMinValueAndIndex(l);a.style.left=(o+c)*u+"px",a.style.top=f+t+"px",l[u]=a.offsetHeight+t+f}}}};d.Base64Utils=M,d.MoneyFormatter=x,d.arrayUtils=A,d.booleanUtils=S,d.cookieUtils=U,d.dateUtils=E,d.documentUtils=C,d.downloadUtils=B,d.echartsUtils=D,d.letterUtils=R,d.mapUtils=v,d.nameUtils=O,d.numberUtils=T,d.objectUtils=_,d.phoneUtils=L,d.randomUtils=k,d.regexpUtils=I,d.storageUtils=j,d.stringUtils=H,d.urlUtils=P,d.waterfallUtils=F,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@yh-kit/utils",
3
3
  "private": false,
4
- "version": "1.13.0",
4
+ "version": "1.14.1",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist",
@@ -9,6 +9,7 @@ export * from "./echarts";
9
9
  export * from "./letter";
10
10
  export * from "./map";
11
11
  export * from "./money";
12
+ export * from "./name";
12
13
  export * from "./number";
13
14
  export * from "./object";
14
15
  export * from "./phone";
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 数组相关操作工具函数
2
+ * 字母相关操作工具函数
3
3
  */
4
4
  export declare const letterUtils: {
5
5
  /**
@@ -0,0 +1,11 @@
1
+ import { IChineseNameMaskOptions } from "./typing";
2
+ /** 姓名相关操作工具函数 */
3
+ export declare const nameUtils: {
4
+ /**
5
+ * 中文姓名脱敏
6
+ * @param name 姓名
7
+ * @param options 脱敏选项
8
+ * @returns 脱敏后的姓名
9
+ */
10
+ desensitizeChineseName(name: string, options?: IChineseNameMaskOptions): string;
11
+ };
@@ -0,0 +1,9 @@
1
+ /** 姓名脱敏选项 */
2
+ export interface IChineseNameMaskOptions {
3
+ /** 复姓(常见复姓列表,可根据需求扩展) */
4
+ compoundSurname?: string;
5
+ /** 保留字符数(默认1位,复姓会自动保留完整) */
6
+ keepLength?: number;
7
+ /** 是否保留最后一个字符,仅3字及以上有效 */
8
+ keepLast?: boolean;
9
+ }