@yh-kit/utils 1.6.1 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/utils.js CHANGED
@@ -1,14 +1,14 @@
1
- const y = (e) => {
1
+ const m = (e) => {
2
2
  if (!e || !e.length) return {};
3
- const r = {};
3
+ const n = {};
4
4
  return e.forEach((t) => {
5
- const n = Object.assign({ label: t.label, text: t.label }, t);
6
- r[t == null ? void 0 : t.value] = n;
7
- }), r;
5
+ const r = Object.assign({ label: t.label, text: t.label }, t);
6
+ n[t == null ? void 0 : t.value] = r;
7
+ }), n;
8
8
  }, b = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9
9
  __proto__: null,
10
- toEnumObj: y
11
- }, Symbol.toStringTag, { value: "Module" })), L = Object.assign(
10
+ toEnumObj: m
11
+ }, Symbol.toStringTag, { value: "Module" })), y = Object.assign(
12
12
  {
13
13
  /**
14
14
  * 数组去重
@@ -24,8 +24,8 @@ const y = (e) => {
24
24
  * @param element 查询元素
25
25
  * @returns 是否存在。true 存在;false 不存在
26
26
  */
27
- isExist(e, r) {
28
- return !e || !r ? !1 : e.indexOf(r) !== -1;
27
+ isExist(e, n) {
28
+ return !e || !n ? !1 : e.indexOf(n) !== -1;
29
29
  },
30
30
  /**
31
31
  * 统计数组中某元素出现的次数:对于大型数组,手动循环的性能略优于 filter 和 reduce。
@@ -33,10 +33,10 @@ const y = (e) => {
33
33
  * @param target 目标元素
34
34
  * @returns 出现次数
35
35
  */
36
- countOfAppear(e, r) {
36
+ countOfAppear(e, n) {
37
37
  let t = 0;
38
- for (const n of e)
39
- n === r && t++;
38
+ for (const r of e)
39
+ r === n && t++;
40
40
  return t;
41
41
  },
42
42
  /**
@@ -45,13 +45,13 @@ const y = (e) => {
45
45
  * @param element 元素
46
46
  * @returns 位置数组
47
47
  */
48
- indexsOfAppear(e, r) {
48
+ indexsOfAppear(e, n) {
49
49
  let t = -1;
50
- const n = [];
50
+ const r = [];
51
51
  do
52
- t = e.indexOf(r, t + 1), t !== -1 && n.push(t);
52
+ t = e.indexOf(n, t + 1), t !== -1 && r.push(t);
53
53
  while (t !== -1);
54
- return n;
54
+ return r;
55
55
  },
56
56
  /**
57
57
  * 数组排序-默认升序
@@ -59,8 +59,8 @@ const y = (e) => {
59
59
  * @param order 排序方式:asc 升序;desc 降序
60
60
  * @returns 排序后的数组
61
61
  */
62
- sort(e, r = "asc") {
63
- return e ? e.sort((t, n) => r === "asc" ? t > n ? 1 : -1 : t < n ? 1 : -1) : [];
62
+ sort(e, n = "asc") {
63
+ return e ? e.sort((t, r) => n === "asc" ? t > r ? 1 : -1 : t < r ? 1 : -1) : [];
64
64
  },
65
65
  /**
66
66
  * 数组乱序(洗牌算法)
@@ -76,9 +76,9 @@ const y = (e) => {
76
76
  shuffle(e) {
77
77
  if (!e)
78
78
  return [];
79
- for (let r = e.length - 1; r > 0; r--) {
80
- const t = Math.floor(Math.random() * (r + 1));
81
- [e[r], e[t]] = [e[t], e[r]];
79
+ for (let n = e.length - 1; n > 0; n--) {
80
+ const t = Math.floor(Math.random() * (n + 1));
81
+ [e[n], e[t]] = [e[t], e[n]];
82
82
  }
83
83
  return e;
84
84
  },
@@ -97,12 +97,48 @@ const y = (e) => {
97
97
  */
98
98
  getMinValue(e) {
99
99
  return e ? Math.min(...e) : 0;
100
+ },
101
+ /**
102
+ * 获取数组中的最小值和索引
103
+ * @param array 数组
104
+ * @returns 最小值和索引
105
+ */
106
+ getMinValueAndIndex(e) {
107
+ if (e.length === 0) return { minV: 0, minI: 0 };
108
+ const n = {
109
+ /** 最小值 */
110
+ minV: e[0],
111
+ /** 最小值索引 */
112
+ minI: 0
113
+ };
114
+ for (let t = 1, r = e.length; t < r; t++) {
115
+ const o = e[t];
116
+ n.minV > o && (n.minV = o, n.minI = t);
117
+ }
118
+ return n;
119
+ },
120
+ /**
121
+ * 获取数组中的最大值和索引
122
+ * @param array 数组
123
+ * @returns 最大值和索引
124
+ */
125
+ getMaxValueAndIndex(e) {
126
+ if (e.length === 0) return { maxV: 0, maxI: 0 };
127
+ const n = {
128
+ maxV: e[0],
129
+ maxI: 0
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;
100
136
  }
101
137
  },
102
138
  {
103
139
  ...b
104
140
  }
105
- ), A = {
141
+ ), L = {
106
142
  /**
107
143
  * 将Base64编码的字符串转换为Blob对象。
108
144
  * Blob对象用于表示二进制大型对象,可以在浏览器环境中处理大文件或二进制数据。
@@ -112,20 +148,20 @@ const y = (e) => {
112
148
  * @param sliceSize 可选参数,表示分片大小,默认为512字节。用于控制每次处理的Base64字符串长度,以优化大文件的处理。
113
149
  * @returns 返回转换后的Blob对象,如果转换失败,则返回null。
114
150
  */
115
- toBlob(e, r = "", t = 512) {
116
- const o = (e.split(",")[1] || e).replace(/-/g, "+").replace(/_/g, "/"), s = "=".repeat((4 - o.length % 4) % 4), c = o + s;
151
+ toBlob(e, n = "", t = 512) {
152
+ const o = (e.split(",")[1] || e).replace(/-/g, "+").replace(/_/g, "/"), s = "=".repeat((4 - o.length % 4) % 4), l = o + s;
117
153
  try {
118
- const i = atob(c), l = [];
119
- for (let h = 0; h < i.length; h += t) {
120
- const a = i.slice(h, h + t), d = new Array(a.length);
121
- for (let u = 0; u < a.length; u++)
122
- d[u] = a.charCodeAt(u);
123
- const f = new Uint8Array(d);
124
- l.push(f);
154
+ const c = atob(l), a = [];
155
+ for (let g = 0; g < c.length; g += t) {
156
+ const i = c.slice(g, g + t), u = new Array(i.length);
157
+ for (let d = 0; d < i.length; d++)
158
+ u[d] = i.charCodeAt(d);
159
+ const f = new Uint8Array(u);
160
+ a.push(f);
125
161
  }
126
- return new Blob(l, { type: r });
127
- } catch (i) {
128
- return console.error("Failed to convert base64 to blob:", i), null;
162
+ return new Blob(a, { type: n });
163
+ } catch (c) {
164
+ return console.error("Failed to convert base64 to blob:", c), null;
129
165
  }
130
166
  },
131
167
  /**
@@ -138,18 +174,18 @@ const y = (e) => {
138
174
  * @param mimeType MIME类型,默认为"text/plain"。
139
175
  * @returns 返回一个File对象,包含解码后的数据。
140
176
  */
141
- toFile(e, r = "file.txt", t = "text/plain") {
142
- const o = e.replace(/^data:.+;base64,/, "").replace(/-/g, "+").replace(/_/g, "/"), s = "=".repeat((4 - o.length % 4) % 4), c = o + s, i = atob(c), l = [];
143
- for (let a = 0; a < i.length; a += 512) {
144
- const d = i.slice(a, a + 512), f = new Array(d.length);
145
- for (let u = 0; u < d.length; u++)
146
- f[u] = d.charCodeAt(u);
147
- l.push(new Uint8Array(f));
177
+ 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), a = [];
179
+ for (let i = 0; i < c.length; i += 512) {
180
+ const u = c.slice(i, i + 512), f = new Array(u.length);
181
+ for (let d = 0; d < u.length; d++)
182
+ f[d] = u.charCodeAt(d);
183
+ a.push(new Uint8Array(f));
148
184
  }
149
- const h = new Blob(l, { type: t });
150
- return new File([h], r, { type: t });
185
+ const g = new Blob(a, { type: t });
186
+ return new File([g], n, { type: t });
151
187
  }
152
- }, m = {
188
+ }, w = {
153
189
  /**
154
190
  * 检查是否为空字符串
155
191
  * @param str 要检查的字符串
@@ -268,8 +304,8 @@ const y = (e) => {
268
304
  * @returns true 表示元素在可视区域内,false 表示元素不在可视区域内
269
305
  */
270
306
  isInViewport(e) {
271
- const r = e.getBoundingClientRect();
272
- return r.top >= 0 && r.left >= 0 && r.bottom <= window.innerHeight && r.right <= window.innerWidth;
307
+ const n = e.getBoundingClientRect();
308
+ return n.top >= 0 && n.left >= 0 && n.bottom <= window.innerHeight && n.right <= window.innerWidth;
273
309
  },
274
310
  /**
275
311
  * 判断是否为闰年
@@ -293,7 +329,7 @@ const y = (e) => {
293
329
  isMobile() {
294
330
  return /Mobi|Android|iPhone/i.test(navigator.userAgent);
295
331
  }
296
- }, v = {
332
+ }, I = {
297
333
  /**
298
334
  * 通过传入的name获取cookie的值
299
335
  * @param name cookie的name
@@ -301,8 +337,8 @@ const y = (e) => {
301
337
  */
302
338
  getCookie(e) {
303
339
  if (!e) return;
304
- const r = document.cookie.match(new RegExp("(^| )" + e + "=([^;]+)"));
305
- return r ? decodeURIComponent(r[2]) : null;
340
+ const n = document.cookie.match(new RegExp("(^| )" + e + "=([^;]+)"));
341
+ return n ? decodeURIComponent(n[2]) : null;
306
342
  },
307
343
  /**
308
344
  * 设置 cookie
@@ -311,9 +347,9 @@ const y = (e) => {
311
347
  * @param days cookie的过期时间,默认7天。如果为0,则表示cookie在会话结束时过期。如果为负数,则表示cookie已过期。
312
348
  * @returns void
313
349
  */
314
- setCookie(e, r, t = 7) {
315
- const n = /* @__PURE__ */ new Date();
316
- n.setTime(n.getTime() + t * 24 * 60 * 60 * 1e3), document.cookie = `${e}=${encodeURIComponent(r)};expires=${n.toUTCString()};path=/`;
350
+ setCookie(e, n, t = 7) {
351
+ const r = /* @__PURE__ */ new Date();
352
+ r.setTime(r.getTime() + t * 24 * 60 * 60 * 1e3), document.cookie = `${e}=${encodeURIComponent(n)};expires=${r.toUTCString()};path=/`;
317
353
  },
318
354
  /**
319
355
  * 删除cookie
@@ -323,15 +359,15 @@ const y = (e) => {
323
359
  deleteCookie(e) {
324
360
  this.setCookie(e, "", -1);
325
361
  }
326
- }, R = {
362
+ }, j = {
327
363
  /**
328
364
  * 获取当前时间字符串
329
365
  * @param locales 区域设置。如:'zh-CN','en-US',"chinese"。默认'zh-CN'。
330
366
  * @param hour12 是否使用12小时制。默认false,使用24小时制。
331
367
  * @returns 当前时间的字符串。如:'2025/5/27 16:54:45'
332
368
  */
333
- getTimeString(e, r = !1) {
334
- return r ? (/* @__PURE__ */ new Date()).toLocaleString(e, { hour12: !0 }) : (/* @__PURE__ */ new Date()).toLocaleString("chinese", { hour12: !1 });
369
+ getTimeString(e, n = !1) {
370
+ return n ? (/* @__PURE__ */ new Date()).toLocaleString(e, { hour12: !0 }) : (/* @__PURE__ */ new Date()).toLocaleString("chinese", { hour12: !1 });
335
371
  },
336
372
  /**
337
373
  * 计算两个日期相差天数
@@ -339,9 +375,9 @@ const y = (e) => {
339
375
  * @param date2 日期2
340
376
  * @returns 相差天数
341
377
  */
342
- diffDays(e, r) {
343
- const t = new Date(e).getTime(), n = new Date(r).getTime();
344
- return t > n ? Math.abs(Math.floor((t - n) / (24 * 3600 * 1e3))) : Math.abs(Math.floor((n - t) / (24 * 3600 * 1e3)));
378
+ diffDays(e, n) {
379
+ const t = new Date(e).getTime(), r = new Date(n).getTime();
380
+ return t > r ? Math.abs(Math.floor((t - r) / (24 * 3600 * 1e3))) : Math.abs(Math.floor((r - t) / (24 * 3600 * 1e3)));
345
381
  },
346
382
  /**
347
383
  * 生成唯一ID(时间戳+随机数)
@@ -357,9 +393,9 @@ const y = (e) => {
357
393
  * @param day 日期
358
394
  * @returns 当年的第几天
359
395
  */
360
- getWhichDays(e, r, t) {
361
- let n = t;
362
- for (let o = 1; o < r; o++)
396
+ getWhichDays(e, n, t) {
397
+ let r = t;
398
+ for (let o = 1; o < n; o++)
363
399
  switch (o) {
364
400
  case 1:
365
401
  case 3:
@@ -368,18 +404,18 @@ const y = (e) => {
368
404
  case 8:
369
405
  case 10:
370
406
  case 12:
371
- n += 31;
407
+ r += 31;
372
408
  break;
373
409
  case 2:
374
- m.isLeapYear(e) ? n += 29 : n += 28;
410
+ w.isLeapYear(e) ? r += 29 : r += 28;
375
411
  break;
376
412
  default:
377
- n += 30;
413
+ r += 30;
378
414
  break;
379
415
  }
380
- return n;
416
+ return r;
381
417
  }
382
- }, j = {
418
+ }, v = {
383
419
  /**
384
420
  * 获取元素相对于文档顶部的偏移量(距离)
385
421
  * 处理了SVG元素的特殊情况。
@@ -390,13 +426,13 @@ const y = (e) => {
390
426
  if (!e)
391
427
  throw new Error("Element is not provided");
392
428
  if (e instanceof SVGElement) {
393
- const t = e.getBoundingClientRect(), n = window.pageYOffset || document.documentElement.scrollTop;
394
- return t.top + n;
429
+ const t = e.getBoundingClientRect(), r = window.pageYOffset || document.documentElement.scrollTop;
430
+ return t.top + r;
395
431
  }
396
- let r = 0;
432
+ let n = 0;
397
433
  for (; e; )
398
- r += e.offsetTop, e = e.offsetParent;
399
- return r;
434
+ n += e.offsetTop, e = e.offsetParent;
435
+ return n;
400
436
  },
401
437
  /**
402
438
  * 获取文档的滚动值
@@ -419,9 +455,9 @@ const y = (e) => {
419
455
  */
420
456
  getPageValue(e) {
421
457
  e = e || window.event;
422
- const r = e.pageX || e.clientX + this.getScrollValue().scrollLeft, t = e.pageY || e.clientY + this.getScrollValue().scrollTop;
458
+ const n = e.pageX || e.clientX + this.getScrollValue().scrollLeft, t = e.pageY || e.clientY + this.getScrollValue().scrollTop;
423
459
  return {
424
- pageX: r,
460
+ pageX: n,
425
461
  pageY: t
426
462
  };
427
463
  },
@@ -433,32 +469,32 @@ const y = (e) => {
433
469
  * @param fn 事件处理函数
434
470
  */
435
471
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
436
- addEventListener(e, r, t) {
437
- e.addEventListener ? e.addEventListener(r, t) : e.attachEvent ? e.attachEvent("on" + r, t) : e["on" + r] = t;
472
+ addEventListener(e, n, t) {
473
+ e.addEventListener ? e.addEventListener(n, t) : e.attachEvent ? e.attachEvent("on" + n, t) : e["on" + n] = t;
438
474
  }
439
- }, C = {
475
+ }, R = {
440
476
  /**
441
477
  * 将blob对象转化成文件并导出到本地
442
478
  * @param blob blob对象
443
479
  * @param filename 文件名
444
480
  */
445
- saveAsBlob(e, r) {
446
- const t = document.createElement("a"), n = window.URL.createObjectURL(e);
447
- t.href = n, t.download = r, document.body.appendChild(t), t.click(), URL.revokeObjectURL(n), document.body.removeChild(t);
481
+ saveAsBlob(e, n) {
482
+ const t = document.createElement("a"), r = window.URL.createObjectURL(e);
483
+ t.href = r, t.download = n, document.body.appendChild(t), t.click(), URL.revokeObjectURL(r), document.body.removeChild(t);
448
484
  }
449
- }, k = {
485
+ }, C = {
450
486
  /**
451
487
  * 将选中的字母数组从A-Z排序:用于试题选择答案的排序实例
452
488
  * @param arr 字母数组
453
489
  * @returns
454
490
  */
455
491
  sortFromA2Z(e) {
456
- return e != null && e.length ? e.sort((t, n) => {
457
- const o = t.toUpperCase(), s = n.toUpperCase();
492
+ return e != null && e.length ? e.sort((t, r) => {
493
+ const o = t.toUpperCase(), s = r.toUpperCase();
458
494
  return o < s ? -1 : o > s ? 1 : 0;
459
495
  }) : void 0;
460
496
  }
461
- }, B = {
497
+ }, k = {
462
498
  /**
463
499
  * 角度(度数)转弧度
464
500
  * 在数学和编程里,角度有两种常用单位,分别是度(°)和弧度(rad)。
@@ -478,14 +514,14 @@ const y = (e) => {
478
514
  * @param targetLng 目标经度
479
515
  * @returns 距离值 单位:km
480
516
  */
481
- getDistance(e, r, t, n) {
482
- const o = this.degrees2Radians(e), s = this.degrees2Radians(t), c = o - s, i = this.degrees2Radians(r) - this.degrees2Radians(n);
483
- let l = 2 * Math.asin(
517
+ getDistance(e, n, t, r) {
518
+ const o = this.degrees2Radians(e), s = this.degrees2Radians(t), l = o - s, c = this.degrees2Radians(n) - this.degrees2Radians(r);
519
+ let a = 2 * Math.asin(
484
520
  Math.sqrt(
485
- Math.pow(Math.sin(c / 2), 2) + Math.cos(o) * Math.cos(s) * Math.pow(Math.sin(i / 2), 2)
521
+ Math.pow(Math.sin(l / 2), 2) + Math.cos(o) * Math.cos(s) * Math.pow(Math.sin(c / 2), 2)
486
522
  )
487
523
  );
488
- return l = l * 6378.137, l = Math.round(l * 1e4) / 1e4, l = +l.toFixed(2), console.log("经纬度计算的距离为:" + l), l;
524
+ return a = a * 6378.137, a = Math.round(a * 1e4) / 1e4, a = +a.toFixed(2), console.log("经纬度计算的距离为:" + a), a;
489
525
  },
490
526
  /**
491
527
  * 计算两个坐标点之间的距离(Haversine公式)
@@ -502,23 +538,23 @@ const y = (e) => {
502
538
  * @param unit 距离单位,默认单位为千米。可选值:km(千米)、m(米)、mi(英里)、nmi(海里)
503
539
  * @returns 距离值
504
540
  */
505
- calculateDistanceByHaversine(e, r, t = "km") {
506
- const n = this, o = e.longitude ?? e.lng, s = e.latitude ?? e.lat, c = r.longitude ?? r.lng, i = r.latitude ?? r.lat;
507
- if (o === void 0 || s === void 0 || c === void 0 || i === void 0)
541
+ calculateDistanceByHaversine(e, n, t = "km") {
542
+ const r = this, o = e.longitude ?? e.lng, s = e.latitude ?? e.lat, l = n.longitude ?? n.lng, c = n.latitude ?? n.lat;
543
+ if (o === void 0 || s === void 0 || l === void 0 || c === void 0)
508
544
  throw new Error("无效的坐标格式,缺少经纬度信息");
509
- const l = 6371, h = n.degrees2Radians(s), a = n.degrees2Radians(i), d = n.degrees2Radians(i - s), f = n.degrees2Radians(c - o), u = Math.sin(d / 2) * Math.sin(d / 2) + Math.cos(h) * Math.cos(a) * Math.sin(f / 2) * Math.sin(f / 2), p = 2 * Math.atan2(Math.sqrt(u), Math.sqrt(1 - u)), g = l * p;
545
+ const a = 6371, g = r.degrees2Radians(s), i = 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(i) * Math.sin(f / 2) * Math.sin(f / 2), p = 2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d)), h = a * p;
510
546
  switch (t) {
511
547
  case "m":
512
- return g * 1e3;
548
+ return h * 1e3;
513
549
  // 米
514
550
  case "mi":
515
- return g * 0.621371;
551
+ return h * 0.621371;
516
552
  // 英里
517
553
  case "nmi":
518
- return g * 0.539957;
554
+ return h * 0.539957;
519
555
  // 海里
520
556
  default:
521
- return g;
557
+ return h;
522
558
  }
523
559
  },
524
560
  /**
@@ -528,31 +564,31 @@ const y = (e) => {
528
564
  * @param closed 是否闭合路径,默认不闭合
529
565
  * @returns 距离结果对象。包含每个距离段的数组(segments)和总距离(total)。
530
566
  */
531
- calculateDistancesByHaversine(e, r = "km", t = !1) {
567
+ calculateDistancesByHaversine(e, n = "km", t = !1) {
532
568
  if (e.length < 2)
533
569
  return { segments: [], total: 0 };
534
- const n = [];
570
+ const r = [];
535
571
  let o = 0;
536
572
  for (let s = 0; s < e.length - 1; s++) {
537
- const c = this.calculateDistanceByHaversine(e[s], e[s + 1], r);
538
- n.push(c), o += c;
573
+ const l = this.calculateDistanceByHaversine(e[s], e[s + 1], n);
574
+ r.push(l), o += l;
539
575
  }
540
576
  if (t && e.length > 2) {
541
- const s = this.calculateDistanceByHaversine(e[e.length - 1], e[0], r);
542
- n.push(s), o += s;
577
+ const s = this.calculateDistanceByHaversine(e[e.length - 1], e[0], n);
578
+ r.push(s), o += s;
543
579
  }
544
- return { segments: n, total: o };
580
+ return { segments: r, total: o };
545
581
  }
546
582
  };
547
- class T {
583
+ class B {
548
584
  /**
549
585
  * 转换为标准金额格式(带千分位和两位小数)
550
586
  * @param num 要转换的数字
551
587
  * @returns 格式化后的字符串
552
588
  */
553
- static toStandardFormat(r) {
589
+ static toStandardFormat(n) {
554
590
  try {
555
- const t = typeof r == "string" ? parseFloat(r) : r;
591
+ const t = typeof n == "string" ? parseFloat(n) : n;
556
592
  if (isNaN(t))
557
593
  throw new Error("输入不是有效的数字");
558
594
  if (!isFinite(t))
@@ -567,46 +603,46 @@ class T {
567
603
  * @param num 要转换的数字
568
604
  * @returns 中文大写金额字符串
569
605
  */
570
- static toChineseFormat(r) {
606
+ static toChineseFormat(n) {
571
607
  try {
572
- const t = typeof r == "string" ? parseFloat(r) : r;
608
+ const t = typeof n == "string" ? parseFloat(n) : n;
573
609
  if (isNaN(t))
574
610
  throw new Error("输入不是有效的数字");
575
611
  if (t > 9999999999999e-2 || t < -9999999999999e-2)
576
612
  throw new Error("输入数字超出范围");
577
- const n = t < 0, o = Math.abs(t), s = Math.floor(o), c = Math.round((o - s) * 100), i = ["零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"], l = ["", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾", "佰", "仟"], h = ["角", "分"];
578
- let a = "", d = s;
579
- if (d === 0)
580
- a = i[0];
613
+ const r = t < 0, o = Math.abs(t), s = Math.floor(o), l = Math.round((o - s) * 100), c = ["零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"], a = ["", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾", "佰", "仟"], g = ["角", "分"];
614
+ let i = "", u = s;
615
+ if (u === 0)
616
+ i = c[0];
581
617
  else {
582
618
  let p = 0;
583
- for (; d > 0; ) {
584
- const g = d % 10;
585
- g !== 0 ? a = i[g] + l[p] + a : a.charAt(0) !== i[0] && (a = i[g] + a), d = Math.floor(d / 10), p++;
619
+ for (; u > 0; ) {
620
+ const h = u % 10;
621
+ h !== 0 ? i = c[h] + a[p] + i : i.charAt(0) !== c[0] && (i = c[h] + i), u = Math.floor(u / 10), p++;
586
622
  }
587
- a = a.replace(/零+/g, "零"), a = a.replace(/零+$/, "");
623
+ i = i.replace(/零+/g, "零"), i = i.replace(/零+$/, "");
588
624
  }
589
625
  let f = "";
590
- if (c > 0) {
591
- const p = Math.floor(c / 10), g = c % 10;
592
- p > 0 && (f += i[p] + h[0]), g > 0 && (f += i[g] + h[1]);
626
+ if (l > 0) {
627
+ const p = Math.floor(l / 10), h = l % 10;
628
+ p > 0 && (f += c[p] + g[0]), h > 0 && (f += c[h] + g[1]);
593
629
  } else
594
630
  f = "整";
595
- let u = (n ? "负" : "") + a + "圆" + f;
596
- return u === "零圆整" && (u = "零圆"), u;
631
+ let d = (r ? "负" : "") + i + "圆" + f;
632
+ return d === "零圆整" && (d = "零圆"), d;
597
633
  } catch (t) {
598
634
  return console.error("转换失败:", t), "格式错误";
599
635
  }
600
636
  }
601
637
  }
602
- const w = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], M = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
638
+ const M = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], x = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
603
639
  __proto__: null,
604
- toLetter: w
640
+ toLetter: M
605
641
  }, Symbol.toStringTag, { value: "Module" })), S = (e) => e.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","), O = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
606
642
  __proto__: null,
607
643
  toMoney: S
608
- }, Symbol.toStringTag, { value: "Module" })), _ = {
609
- ...M,
644
+ }, Symbol.toStringTag, { value: "Module" })), V = {
645
+ ...x,
610
646
  ...O,
611
647
  /**
612
648
  * 判断是否为数字
@@ -616,7 +652,7 @@ const w = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], M = /*
616
652
  isNumber(e) {
617
653
  return typeof e == "number" && !isNaN(e);
618
654
  }
619
- }, I = {
655
+ }, _ = {
620
656
  /**
621
657
  * 判断对象是否为空
622
658
  * @param obj 对象
@@ -631,9 +667,9 @@ const w = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], M = /*
631
667
  * @param obj2 目标对象
632
668
  */
633
669
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
634
- copy(e, r) {
670
+ copy(e, n) {
635
671
  for (const t in e)
636
- r[t] = e[t];
672
+ n[t] = e[t];
637
673
  },
638
674
  /**
639
675
  * 对象的深拷贝 把o1 的成员,复制给o2
@@ -641,13 +677,13 @@ const w = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], M = /*
641
677
  * @param o2
642
678
  */
643
679
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
644
- deepCopy(e, r) {
680
+ deepCopy(e, n) {
645
681
  for (const t in e) {
646
- const n = e[t];
647
- n instanceof Object ? (r[t] = {}, this.deepCopy(n, r[t])) : n instanceof Array ? (r[t] = [], this.deepCopy(n, r[t])) : r[t] = e[t];
682
+ const r = e[t];
683
+ r instanceof Object ? (n[t] = {}, this.deepCopy(r, n[t])) : r instanceof Array ? (n[t] = [], this.deepCopy(r, n[t])) : n[t] = e[t];
648
684
  }
649
685
  }
650
- }, N = {
686
+ }, T = {
651
687
  /**
652
688
  * 脱敏
653
689
  * @param phone 电话号码/手机号码
@@ -656,7 +692,7 @@ const w = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], M = /*
656
692
  desensitize(e) {
657
693
  return e ? e.replace(/^(\d{3})\d{4}(\d{4})$/, "$1****$2") || e.slice(0, 3) + "****" + e.slice(7) : "";
658
694
  }
659
- }, D = {
695
+ }, $ = {
660
696
  /**
661
697
  * 生成随机颜色
662
698
  * @returns 随机颜色值
@@ -670,8 +706,8 @@ const w = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], M = /*
670
706
  * @param max 最大值
671
707
  * @returns 随机数
672
708
  */
673
- int(e, r) {
674
- return Math.floor(Math.random() * (r - e + 1)) + e;
709
+ int(e, n) {
710
+ return Math.floor(Math.random() * (n - e + 1)) + e;
675
711
  },
676
712
  /**
677
713
  * 生成唯一ID(时间戳+随机数)
@@ -680,6 +716,43 @@ const w = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], M = /*
680
716
  uniqueId() {
681
717
  return Date.now().toString(36) + Math.random().toString(36).substr(2, 5);
682
718
  }
719
+ }, N = {
720
+ /**
721
+ * 验证手机号
722
+ */
723
+ mobile: /^1[3-9]\d{9}$/,
724
+ /**
725
+ * 验证邮箱
726
+ */
727
+ email: /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,
728
+ /**
729
+ * 验证中文
730
+ */
731
+ chinese: /^[\u4e00-\u9fa5]+$/,
732
+ /**
733
+ * 验证英文
734
+ */
735
+ english: /^[a-zA-Z]+$/,
736
+ /**
737
+ * 验证中文开头其他结束
738
+ */
739
+ chineseStart: /^[\u4e00-\u9fa5]+\w*$/,
740
+ /**
741
+ * 验证正整数
742
+ */
743
+ integer: /^\d+$/,
744
+ /**
745
+ * 验证零+正整数
746
+ */
747
+ integerAndzero: /^(0|[1-9]+[0-9]*)$/,
748
+ /**
749
+ * 验证强密码正则:密码须由大小字母+数字、大小字母+特殊符号、数字+特殊字符等组合,且存在字母时,必须包含大小写字母。长度必须8位以上
750
+ */
751
+ strongPassword: /^(?!.*[\s\p{C}])(?:(?=.*[A-Z])(?=.*[a-z])(?=.*[\d\W])|(?=.*\d)(?=.*[^\w\s])).{8,}$/u,
752
+ /**
753
+ * 验证0.01~0.99正则:最多两位小数。0.1、0.10、0.9、0.90
754
+ */
755
+ decimal: /^0\.(0[1-9]|[1-9][0-9]*)$/
683
756
  }, P = {
684
757
  /**
685
758
  * 通过key值获取 localStorage 中存储的某个值
@@ -694,8 +767,8 @@ const w = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], M = /*
694
767
  * @param key 设置的key
695
768
  * @param value 设置的value
696
769
  */
697
- setLocal(e, r) {
698
- localStorage.setItem(e, r);
770
+ setLocal(e, n) {
771
+ localStorage.setItem(e, n);
699
772
  },
700
773
  /**
701
774
  * 删除localStorage中的某个值
@@ -717,8 +790,8 @@ const w = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], M = /*
717
790
  * @param key 设置的key
718
791
  * @param value 设置的value
719
792
  */
720
- setSession(e, r) {
721
- sessionStorage.setItem(e, r);
793
+ setSession(e, n) {
794
+ sessionStorage.setItem(e, n);
722
795
  },
723
796
  /**
724
797
  * 删除sessionStorage中的某个值
@@ -727,18 +800,18 @@ const w = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], M = /*
727
800
  removeSession(e) {
728
801
  sessionStorage.removeItem(e);
729
802
  }
730
- }, F = {
803
+ }, D = {
731
804
  /**
732
805
  * 判断某元素是否在字符串中-比includes()方法更兼容,includes为ES6新增方法,IE不支持。小程序也不支持
733
806
  * @param str 字符串
734
807
  * @param element 查询元素
735
808
  * @returns 是否存在。true 存在;false 不存在
736
809
  */
737
- isExist(e, r) {
738
- if (!e || !r)
810
+ isExist(e, n) {
811
+ if (!e || !n)
739
812
  return !1;
740
813
  const t = e.split(",");
741
- return console.log("判断某元素是否在字符串中", t.indexOf(r) === -1), t.indexOf(r) !== -1;
814
+ return console.log("判断某元素是否在字符串中", t.indexOf(n) === -1), t.indexOf(n) !== -1;
742
815
  },
743
816
  /**
744
817
  * 判断某元素是否在字符串中-比isExist()方法更高效。
@@ -746,8 +819,8 @@ const w = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], M = /*
746
819
  * @param element 查询元素
747
820
  * @returns 是否存在。true 存在;false 不存在
748
821
  */
749
- includes(e, r) {
750
- return !e || !r ? !1 : e.includes(r);
822
+ includes(e, n) {
823
+ return !e || !n ? !1 : e.includes(n);
751
824
  },
752
825
  /**
753
826
  * 判断字符串是否为 JSON
@@ -767,13 +840,13 @@ const w = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], M = /*
767
840
  * @param element 元素
768
841
  * @returns 位置数组
769
842
  */
770
- indexsOfAppear(e, r) {
843
+ indexsOfAppear(e, n) {
771
844
  let t = -1;
772
- const n = [];
845
+ const r = [];
773
846
  do
774
- t = e.indexOf(r, t + 1), t !== -1 && n.push(t);
847
+ t = e.indexOf(n, t + 1), t !== -1 && r.push(t);
775
848
  while (t !== -1);
776
- return n;
849
+ return r;
777
850
  },
778
851
  /**
779
852
  * 获取字符串中出现次数最多的字符和次数
@@ -781,32 +854,32 @@ const w = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], M = /*
781
854
  * @returns 数组,第一个元素为出现次数,第二个元素为出现次数最多的字符
782
855
  */
783
856
  getMaxTimesAndVal(e) {
784
- const r = [0, ""], t = {};
857
+ const n = [0, ""], t = {};
785
858
  for (let s = 0; s < e.length; s++) {
786
- const c = e.charAt(s);
787
- t[c] ? t[c]++ : t[c] = 1;
859
+ const l = e.charAt(s);
860
+ t[l] ? t[l]++ : t[l] = 1;
788
861
  }
789
- let n = 1;
862
+ let r = 1;
790
863
  for (const s in t)
791
- n < t[s] && (n = t[s]);
864
+ r < t[s] && (r = t[s]);
792
865
  const o = [];
793
866
  for (const s in t)
794
- n == t[s] && o.push(s);
795
- return r[0] = n, r[1] = o.join(), r;
867
+ r == t[s] && o.push(s);
868
+ return n[0] = r, n[1] = o.join(), n;
796
869
  }
797
- }, U = (e) => {
870
+ }, A = (e) => {
798
871
  const t = new RegExp("[?&]" + e + "=([^&#]*)", "i").exec(window.location.href);
799
872
  return t ? decodeURIComponent(t[1]) : null;
800
873
  };
801
- function E(e) {
874
+ function U(e) {
802
875
  return new URLSearchParams(window.location.search).get(e);
803
876
  }
804
- const x = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
877
+ const E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
805
878
  __proto__: null,
806
- getQueryInfoByName: U,
807
- getQueryParam: E
808
- }, Symbol.toStringTag, { value: "Module" })), V = {
809
- ...x,
879
+ getQueryInfoByName: A,
880
+ getQueryParam: U
881
+ }, Symbol.toStringTag, { value: "Module" })), F = {
882
+ ...E,
810
883
  /**
811
884
  * 获取当前域名
812
885
  * @returns 当前url链接的host信息
@@ -821,42 +894,55 @@ const x = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
821
894
  getPath() {
822
895
  return window.location.pathname;
823
896
  }
824
- }, $ = {
897
+ }, z = {
825
898
  /**
826
- * 处理瀑布流数据,使其适合瀑布流布局展示
899
+ * 处理瀑布流数据,使其竖向瀑布流布局呈现横向瀑布流的展现形式。适用于 column-gap: 20rpx; column-count: 2; 布局的瀑布流
827
900
  * @param list 瀑布流数据-数组
828
901
  * @param columnsNum 需要展示的列数
829
902
  * @returns 适合瀑布流布局的数组
830
903
  */
831
- toList(e, r = 2) {
832
- console.log(e, r);
904
+ toList(e, n = 2) {
905
+ console.log(e, n);
833
906
  const t = {};
834
- for (let o = 0; o < r; o++)
907
+ for (let o = 0; o < n; o++)
835
908
  t[o] = [];
836
- e.forEach((o, s) => t[s % r].push(o));
837
- const n = [];
909
+ e.forEach((o, s) => t[s % n].push(o));
910
+ const r = [];
838
911
  for (const o in t)
839
- n.push(...t[o]);
840
- return n;
912
+ r.push(...t[o]);
913
+ return r;
914
+ },
915
+ jsLayout(e, n, t) {
916
+ const r = e.offsetWidth, o = n[0].offsetWidth, s = parseInt((r / o).toString()), l = (r - o * s) / (s - 1), c = [];
917
+ for (let a = 0, g = n.length; a < g; a++) {
918
+ const i = n[a];
919
+ if (a < s)
920
+ i.style.left = (o + l) * a + "px", c[a] = i.offsetHeight;
921
+ else {
922
+ const { minI: u, minV: f } = y.getMinValueAndIndex(c);
923
+ i.style.left = (o + l) * u + "px", i.style.top = f + t + "px", c[u] = i.offsetHeight + t + f;
924
+ }
925
+ }
841
926
  }
842
927
  };
843
928
  export {
844
- T as MoneyFormatter,
845
- L as arrayUtils,
846
- A as base64Utils,
847
- m as booleanUtils,
848
- v as cookieUtils,
849
- R as dateUtils,
850
- j as documentUtils,
851
- C as downloadUtils,
852
- k as letterUtils,
853
- B as mapUtils,
854
- _ as numberUtils,
855
- I as objectUtils,
856
- N as phoneUtils,
857
- D as randomUtils,
929
+ B as MoneyFormatter,
930
+ y as arrayUtils,
931
+ L as base64Utils,
932
+ w as booleanUtils,
933
+ I as cookieUtils,
934
+ j as dateUtils,
935
+ v as documentUtils,
936
+ R as downloadUtils,
937
+ C as letterUtils,
938
+ k as mapUtils,
939
+ V as numberUtils,
940
+ _ as objectUtils,
941
+ T as phoneUtils,
942
+ $ as randomUtils,
943
+ N as regexUtils,
858
944
  P as storageUtils,
859
- F as stringUtils,
860
- V as urlUtils,
861
- $ as waterfallUtils
945
+ D as stringUtils,
946
+ F as urlUtils,
947
+ z as waterfallUtils
862
948
  };
@@ -1 +1 @@
1
- (function(i,p){typeof exports=="object"&&typeof module<"u"?p(exports):typeof define=="function"&&define.amd?define(["exports"],p):(i=typeof globalThis<"u"?globalThis:i||self,p(i.yhkitUtils={}))})(this,function(i){"use strict";const w=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}},{...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),l=o+s;try{const c=atob(l),u=[];for(let g=0;g<c.length;g+=t){const a=c.slice(g,g+t),f=new Array(a.length);for(let d=0;d<a.length;d++)f[d]=a.charCodeAt(d);const h=new Uint8Array(f);u.push(h)}return new Blob(u,{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),l=o+s,c=atob(l),u=[];for(let a=0;a<c.length;a+=512){const f=c.slice(a,a+512),h=new Array(f.length);for(let d=0;d<f.length;d++)h[d]=f.charCodeAt(d);u.push(new Uint8Array(h))}const g=new Blob(u,{type:t});return new File([g],n,{type:t})}},m={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:m.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}},E={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)}},L={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),l=o-s,c=this.degrees2Radians(n)-this.degrees2Radians(r);let u=2*Math.asin(Math.sqrt(Math.pow(Math.sin(l/2),2)+Math.cos(o)*Math.cos(s)*Math.pow(Math.sin(c/2),2)));return u=u*6378.137,u=Math.round(u*1e4)/1e4,u=+u.toFixed(2),console.log("经纬度计算的距离为:"+u),u},calculateDistanceByHaversine(e,n,t="km"){const r=this,o=e.longitude??e.lng,s=e.latitude??e.lat,l=n.longitude??n.lng,c=n.latitude??n.lat;if(o===void 0||s===void 0||l===void 0||c===void 0)throw new Error("无效的坐标格式,缺少经纬度信息");const u=6371,g=r.degrees2Radians(s),a=r.degrees2Radians(c),f=r.degrees2Radians(c-s),h=r.degrees2Radians(l-o),d=Math.sin(f/2)*Math.sin(f/2)+Math.cos(g)*Math.cos(a)*Math.sin(h/2)*Math.sin(h/2),b=2*Math.atan2(Math.sqrt(d),Math.sqrt(1-d)),y=u*b;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 l=this.calculateDistanceByHaversine(e[s],e[s+1],n);r.push(l),o+=l}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 v{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),l=Math.round((o-s)*100),c=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],u=["","拾","佰","仟","万","拾","佰","仟","亿","拾","佰","仟"],g=["角","分"];let a="",f=s;if(f===0)a=c[0];else{let b=0;for(;f>0;){const y=f%10;y!==0?a=c[y]+u[b]+a:a.charAt(0)!==c[0]&&(a=c[y]+a),f=Math.floor(f/10),b++}a=a.replace(/零+/g,"零"),a=a.replace(/零+$/,"")}let h="";if(l>0){const b=Math.floor(l/10),y=l%10;b>0&&(h+=c[b]+g[0]),y>0&&(h+=c[y]+g[1])}else h="整";let d=(r?"负":"")+a+"圆"+h;return d==="零圆整"&&(d="零圆"),d}catch(t){return console.error("转换失败:",t),"格式错误"}}}const A={...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)}},R={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]}}},k={desensitize(e){return e?e.replace(/^(\d{3})\d{4}(\d{4})$/,"$1****$2")||e.slice(0,3)+"****"+e.slice(7):""}},T={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={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 l=e.charAt(s);t[l]?t[l]++:t[l]=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}},_=e=>{const t=new RegExp("[?&]"+e+"=([^&#]*)","i").exec(window.location.href);return t?decodeURIComponent(t[1]):null};function I(e){return new URLSearchParams(window.location.search).get(e)}const N={...Object.freeze(Object.defineProperty({__proto__:null,getQueryInfoByName:_,getQueryParam:I},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}};i.MoneyFormatter=v,i.arrayUtils=w,i.base64Utils=M,i.booleanUtils=m,i.cookieUtils=U,i.dateUtils=S,i.documentUtils=O,i.downloadUtils=E,i.letterUtils=L,i.mapUtils=j,i.numberUtils=A,i.objectUtils=R,i.phoneUtils=k,i.randomUtils=T,i.storageUtils=C,i.stringUtils=B,i.urlUtils=N,i.waterfallUtils=P,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
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"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@yh-kit/utils",
3
3
  "private": false,
4
- "version": "1.6.1",
4
+ "version": "1.7.0",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist",
@@ -60,6 +60,24 @@ export declare const arrayUtils: {
60
60
  * @returns 最小值
61
61
  */
62
62
  getMinValue(arr: number[]): number;
63
+ /**
64
+ * 获取数组中的最小值和索引
65
+ * @param array 数组
66
+ * @returns 最小值和索引
67
+ */
68
+ getMinValueAndIndex(array: number[]): {
69
+ minV: number;
70
+ minI: number;
71
+ };
72
+ /**
73
+ * 获取数组中的最大值和索引
74
+ * @param array 数组
75
+ * @returns 最大值和索引
76
+ */
77
+ getMaxValueAndIndex(array: number[]): {
78
+ maxV: number;
79
+ maxI: number;
80
+ };
63
81
  } & {
64
82
  toEnumObj: (arr: import("@yh-kit/types").IOptionItem[]) => import("@yh-kit/types").TValueEnum;
65
83
  };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 元素【Dom】相关工具函数
2
+ * 元素【Dom 文档流】相关工具函数
3
3
  */
4
4
  export declare const documentUtils: {
5
5
  /**
@@ -12,6 +12,7 @@ export * from "./number";
12
12
  export * from "./object";
13
13
  export * from "./phone";
14
14
  export * from "./random";
15
+ export * from "./regex";
15
16
  export * from "./storage";
16
17
  export * from "./string";
17
18
  export * from "./url";
@@ -0,0 +1,41 @@
1
+ /**
2
+ * 常用正则表达式
3
+ */
4
+ export declare const regexUtils: {
5
+ /**
6
+ * 验证手机号
7
+ */
8
+ mobile: RegExp;
9
+ /**
10
+ * 验证邮箱
11
+ */
12
+ email: RegExp;
13
+ /**
14
+ * 验证中文
15
+ */
16
+ chinese: RegExp;
17
+ /**
18
+ * 验证英文
19
+ */
20
+ english: RegExp;
21
+ /**
22
+ * 验证中文开头其他结束
23
+ */
24
+ chineseStart: RegExp;
25
+ /**
26
+ * 验证正整数
27
+ */
28
+ integer: RegExp;
29
+ /**
30
+ * 验证零+正整数
31
+ */
32
+ integerAndzero: RegExp;
33
+ /**
34
+ * 验证强密码正则:密码须由大小字母+数字、大小字母+特殊符号、数字+特殊字符等组合,且存在字母时,必须包含大小写字母。长度必须8位以上
35
+ */
36
+ strongPassword: RegExp;
37
+ /**
38
+ * 验证0.01~0.99正则:最多两位小数。0.1、0.10、0.9、0.90
39
+ */
40
+ decimal: RegExp;
41
+ };
@@ -3,10 +3,11 @@
3
3
  */
4
4
  export declare const waterfallUtils: {
5
5
  /**
6
- * 处理瀑布流数据,使其适合瀑布流布局展示
6
+ * 处理瀑布流数据,使其竖向瀑布流布局呈现横向瀑布流的展现形式。适用于 column-gap: 20rpx; column-count: 2; 布局的瀑布流
7
7
  * @param list 瀑布流数据-数组
8
8
  * @param columnsNum 需要展示的列数
9
9
  * @returns 适合瀑布流布局的数组
10
10
  */
11
11
  toList<T>(list: T[], columnsNum?: number): any[];
12
+ jsLayout(itemBox: HTMLElement, items: HTMLElement[], step: number): void;
12
13
  };