@yh-kit/utils 1.7.0 → 1.8.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,22 +1,25 @@
1
- const m = (e) => {
2
- if (!e || !e.length) return {};
1
+ var m = Object.defineProperty;
2
+ var b = (t, n, e) => n in t ? m(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
3
+ var y = (t, n, e) => b(t, typeof n != "symbol" ? n + "" : n, e);
4
+ const A = (t) => {
5
+ if (!t || !t.length) return {};
3
6
  const n = {};
4
- return e.forEach((t) => {
5
- const r = Object.assign({ label: t.label, text: t.label }, t);
6
- n[t == null ? void 0 : t.value] = r;
7
+ return t.forEach((e) => {
8
+ const o = Object.assign({ label: e.label, text: e.label }, e);
9
+ n[e == null ? void 0 : e.value] = o;
7
10
  }), n;
8
- }, b = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11
+ }, w = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9
12
  __proto__: null,
10
- toEnumObj: m
11
- }, Symbol.toStringTag, { value: "Module" })), y = Object.assign(
13
+ toEnumObj: A
14
+ }, Symbol.toStringTag, { value: "Module" })), S = Object.assign(
12
15
  {
13
16
  /**
14
17
  * 数组去重
15
18
  * @param arr 数组
16
19
  * @returns 去重后的数组
17
20
  */
18
- unique(e) {
19
- return e ? Array.from(new Set(e)) : [];
21
+ unique(t) {
22
+ return t ? Array.from(new Set(t)) : [];
20
23
  },
21
24
  /**
22
25
  * 判断某元素是否在数组中
@@ -24,8 +27,8 @@ const m = (e) => {
24
27
  * @param element 查询元素
25
28
  * @returns 是否存在。true 存在;false 不存在
26
29
  */
27
- isExist(e, n) {
28
- return !e || !n ? !1 : e.indexOf(n) !== -1;
30
+ isExist(t, n) {
31
+ return !t || !n ? !1 : t.indexOf(n) !== -1;
29
32
  },
30
33
  /**
31
34
  * 统计数组中某元素出现的次数:对于大型数组,手动循环的性能略优于 filter 和 reduce。
@@ -33,11 +36,11 @@ const m = (e) => {
33
36
  * @param target 目标元素
34
37
  * @returns 出现次数
35
38
  */
36
- countOfAppear(e, n) {
37
- let t = 0;
38
- for (const r of e)
39
- r === n && t++;
40
- return t;
39
+ countOfAppear(t, n) {
40
+ let e = 0;
41
+ for (const o of t)
42
+ o === n && e++;
43
+ return e;
41
44
  },
42
45
  /**
43
46
  * 查找某个元素在数组中重复出现的位置
@@ -45,13 +48,13 @@ const m = (e) => {
45
48
  * @param element 元素
46
49
  * @returns 位置数组
47
50
  */
48
- indexsOfAppear(e, n) {
49
- let t = -1;
50
- const r = [];
51
+ indexsOfAppear(t, n) {
52
+ let e = -1;
53
+ const o = [];
51
54
  do
52
- t = e.indexOf(n, t + 1), t !== -1 && r.push(t);
53
- while (t !== -1);
54
- return r;
55
+ e = t.indexOf(n, e + 1), e !== -1 && o.push(e);
56
+ while (e !== -1);
57
+ return o;
55
58
  },
56
59
  /**
57
60
  * 数组排序-默认升序
@@ -59,8 +62,8 @@ const m = (e) => {
59
62
  * @param order 排序方式:asc 升序;desc 降序
60
63
  * @returns 排序后的数组
61
64
  */
62
- sort(e, n = "asc") {
63
- return e ? e.sort((t, r) => n === "asc" ? t > r ? 1 : -1 : t < r ? 1 : -1) : [];
65
+ sort(t, n = "asc") {
66
+ return t ? t.sort((e, o) => n === "asc" ? e > o ? 1 : -1 : e < o ? 1 : -1) : [];
64
67
  },
65
68
  /**
66
69
  * 数组乱序(洗牌算法)
@@ -73,72 +76,67 @@ const m = (e) => {
73
76
  * @param arr 数组
74
77
  * @returns
75
78
  */
76
- shuffle(e) {
77
- if (!e)
79
+ shuffle(t) {
80
+ if (!t)
78
81
  return [];
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
+ for (let n = t.length - 1; n > 0; n--) {
83
+ const e = Math.floor(Math.random() * (n + 1));
84
+ [t[n], t[e]] = [t[e], t[n]];
82
85
  }
83
- return e;
86
+ return t;
84
87
  },
85
88
  /**
86
89
  * 获取数组中的最大值
87
90
  * @param arr 数组
88
91
  * @returns 最大值
89
92
  */
90
- getMaxValue(e) {
91
- return e ? Math.max(...e) : 0;
93
+ getMaxValue(t) {
94
+ return t ? Math.max(...t) : 0;
92
95
  },
93
96
  /**
94
97
  * 获取数组中的最小值
95
98
  * @param arr 数组
96
99
  * @returns 最小值
97
100
  */
98
- getMinValue(e) {
99
- return e ? Math.min(...e) : 0;
101
+ getMinValue(t) {
102
+ return t ? Math.min(...t) : 0;
100
103
  },
101
104
  /**
102
105
  * 获取数组中的最小值和索引
103
106
  * @param array 数组
104
107
  * @returns 最小值和索引
105
108
  */
106
- getMinValueAndIndex(e) {
107
- if (e.length === 0) return { minV: 0, minI: 0 };
109
+ getMinValueAndIndex(t) {
110
+ if (t.length === 0) return { value: 0, index: 0 };
108
111
  const n = {
109
112
  /** 最小值 */
110
- minV: e[0],
113
+ value: t[0],
111
114
  /** 最小值索引 */
112
- minI: 0
115
+ index: 0
113
116
  };
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
+ for (let e = 1, o = t.length; e < o; e++) {
118
+ const r = t[e];
119
+ n.value > r && (n.value = r, n.index = e);
117
120
  }
118
121
  return n;
119
122
  },
120
123
  /**
121
124
  * 获取数组中的最大值和索引
122
- * @param array 数组
125
+ * @param arr 数组
123
126
  * @returns 最大值和索引
124
127
  */
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;
128
+ getMaxValueAndIndex(t) {
129
+ return t.length === 0 ? { value: 0, index: 0 } : t.reduce(
130
+ (n, e, o) => e < n.value ? { value: e, index: o } : n,
131
+ { value: t[0], index: 0 }
132
+ );
136
133
  }
137
134
  },
138
135
  {
139
- ...b
136
+ ...w
140
137
  }
141
- ), L = {
138
+ );
139
+ class M {
142
140
  /**
143
141
  * 将Base64编码的字符串转换为Blob对象。
144
142
  * Blob对象用于表示二进制大型对象,可以在浏览器环境中处理大文件或二进制数据。
@@ -148,22 +146,22 @@ const m = (e) => {
148
146
  * @param sliceSize 可选参数,表示分片大小,默认为512字节。用于控制每次处理的Base64字符串长度,以优化大文件的处理。
149
147
  * @returns 返回转换后的Blob对象,如果转换失败,则返回null。
150
148
  */
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;
149
+ static toBlob(n, e = "", o = 512) {
150
+ const s = (n.split(",")[1] || n).replace(/-/g, "+").replace(/_/g, "/"), c = "=".repeat((4 - s.length % 4) % 4), l = s + c;
153
151
  try {
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);
152
+ const i = atob(l), h = [];
153
+ for (let a = 0; a < i.length; a += o) {
154
+ const u = i.slice(a, a + o), d = new Array(u.length);
155
+ for (let f = 0; f < u.length; f++)
156
+ d[f] = u.charCodeAt(f);
157
+ const g = new Uint8Array(d);
158
+ h.push(g);
161
159
  }
162
- return new Blob(a, { type: n });
163
- } catch (c) {
164
- return console.error("Failed to convert base64 to blob:", c), null;
160
+ return new Blob(h, { type: e });
161
+ } catch (i) {
162
+ return console.error("Failed to convert base64 to blob:", i), null;
165
163
  }
166
- },
164
+ }
167
165
  /**
168
166
  * 将Base64编码的字符串转换为File对象。
169
167
  * 这个函数接受一个Base64编码的字符串,一个可选的文件名和一个可选的MIME类型,
@@ -174,73 +172,180 @@ const m = (e) => {
174
172
  * @param mimeType MIME类型,默认为"text/plain"。
175
173
  * @returns 返回一个File对象,包含解码后的数据。
176
174
  */
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));
175
+ static toFile(n, e = "file.txt", o = "text/plain") {
176
+ const s = n.replace(/^data:.+;base64,/, "").replace(/-/g, "+").replace(/_/g, "/"), c = "=".repeat((4 - s.length % 4) % 4), l = s + c, i = atob(l), h = [];
177
+ for (let u = 0; u < i.length; u += 512) {
178
+ const d = i.slice(u, u + 512), g = new Array(d.length);
179
+ for (let f = 0; f < d.length; f++)
180
+ g[f] = d.charCodeAt(f);
181
+ h.push(new Uint8Array(g));
182
+ }
183
+ const a = new Blob(h, { type: o });
184
+ return new File([a], e, { type: o });
185
+ }
186
+ /**
187
+ * base64加密 -- 普通字符串转 Base64 编码
188
+ * @param text 普通字符串
189
+ * @returns Base64 编码字符串
190
+ */
191
+ static encode(n) {
192
+ if (!n) return "";
193
+ const e = this._stringToUtf8Bytes(n);
194
+ return this._bytesToBase64(e);
195
+ }
196
+ /**
197
+ * base64解密 -- Base64 编码转普通字符串
198
+ * @param base64Str Base64 编码字符串
199
+ * @returns 普通字符串
200
+ */
201
+ static decode(n) {
202
+ if (!n) return "";
203
+ n = n.replace(/\s/g, "");
204
+ const e = this._base64ToBytes(n);
205
+ return this._utf8BytesToString(e);
206
+ }
207
+ /**
208
+ * 字符串转 UTF-8 字节数组
209
+ */
210
+ static _stringToUtf8Bytes(n) {
211
+ const e = [];
212
+ for (let o = 0; o < n.length; o++) {
213
+ let r = n.charCodeAt(o);
214
+ if (r < 128)
215
+ e.push(r);
216
+ else if (r < 2048)
217
+ e.push(192 | r >> 6), e.push(128 | r & 63);
218
+ else if (r < 55296 || r >= 57344)
219
+ e.push(224 | r >> 12), e.push(128 | r >> 6 & 63), e.push(128 | r & 63);
220
+ else {
221
+ o++;
222
+ const s = r, c = n.charCodeAt(o);
223
+ if (isNaN(c))
224
+ throw new Error("代理对不完整");
225
+ r = 65536 + ((s & 1023) << 10) + (c & 1023), e.push(240 | r >> 18), e.push(128 | r >> 12 & 63), e.push(128 | r >> 6 & 63), e.push(128 | r & 63);
226
+ }
227
+ }
228
+ return e;
229
+ }
230
+ /**
231
+ * UTF-8 字节数组转字符串
232
+ */
233
+ static _utf8BytesToString(n) {
234
+ let e = "", o = 0;
235
+ for (; o < n.length; ) {
236
+ const r = n[o++];
237
+ if (r < 128)
238
+ e += String.fromCharCode(r);
239
+ else if (r >= 192 && r < 224) {
240
+ const s = n[o++] & 63;
241
+ e += String.fromCharCode((r & 31) << 6 | s);
242
+ } else if (r >= 224 && r < 240) {
243
+ const s = n[o++] & 63, c = n[o++] & 63;
244
+ e += String.fromCharCode((r & 15) << 12 | s << 6 | c);
245
+ } else if (r >= 240 && r < 248) {
246
+ const s = n[o++] & 63, c = n[o++] & 63, l = n[o++] & 63, i = (r & 7) << 18 | s << 12 | c << 6 | l, h = Math.floor((i - 65536) / 1024) + 55296, a = (i - 65536) % 1024 + 56320;
247
+ e += String.fromCharCode(h, a);
248
+ } else
249
+ e += "�";
250
+ }
251
+ return e;
252
+ }
253
+ /**
254
+ * 字节数组转 Base64 编码
255
+ */
256
+ static _bytesToBase64(n) {
257
+ let e = "", o = 0;
258
+ for (; o < n.length; ) {
259
+ const r = n[o++], s = o < n.length, c = s ? n[o++] : 0, l = o < n.length, i = l ? n[o++] : 0, h = r >> 2, a = (r & 3) << 4 | c >> 4, u = (c & 15) << 2 | i >> 6, d = i & 63;
260
+ s ? l ? e += this.BASE64_CHARS.charAt(h) + this.BASE64_CHARS.charAt(a) + this.BASE64_CHARS.charAt(u) + this.BASE64_CHARS.charAt(d) : e += this.BASE64_CHARS.charAt(h) + this.BASE64_CHARS.charAt(a) + this.BASE64_CHARS.charAt(u) + "=" : e += this.BASE64_CHARS.charAt(h) + this.BASE64_CHARS.charAt(a) + "==";
261
+ }
262
+ return e;
263
+ }
264
+ /**
265
+ * Base64 编码转字节数组
266
+ */
267
+ static _base64ToBytes(n) {
268
+ const e = n.length;
269
+ let o = 0;
270
+ e >= 2 && (n[e - 1] === "=" && o++, n[e - 2] === "=" && o++);
271
+ const r = Math.floor(e * 3 / 4) - o, s = new Array(r), c = new Array(256).fill(-1);
272
+ for (let h = 0; h < this.BASE64_CHARS.length; h++)
273
+ c[this.BASE64_CHARS.charCodeAt(h)] = h;
274
+ let l = 0, i = 0;
275
+ for (; i < e; ) {
276
+ const h = c[n.charCodeAt(i++)], a = c[n.charCodeAt(i++)], u = i < e ? c[n.charCodeAt(i++)] : -1, d = i < e ? c[n.charCodeAt(i++)] : -1;
277
+ if (h === -1 || a === -1)
278
+ throw new Error("无效的 Base64 字符");
279
+ const g = h << 2 | a >> 4;
280
+ if (s[l++] = g, u !== -1) {
281
+ const f = (a & 15) << 4 | u >> 2;
282
+ if (s[l++] = f, d !== -1) {
283
+ const p = (u & 3) << 6 | d;
284
+ s[l++] = p;
285
+ }
286
+ }
184
287
  }
185
- const g = new Blob(a, { type: t });
186
- return new File([g], n, { type: t });
288
+ return s;
187
289
  }
188
- }, w = {
290
+ }
291
+ /** Base64 编码表 */
292
+ y(M, "BASE64_CHARS", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");
293
+ const C = {
189
294
  /**
190
295
  * 检查是否为空字符串
191
296
  * @param str 要检查的字符串
192
297
  * @returns 如果字符串为空,则返回 true,否则返回 false
193
298
  */
194
- isEmptyString(e) {
195
- return typeof e == "string" && e.trim() === "";
299
+ isEmptyString(t) {
300
+ return typeof t == "string" && t.trim() === "";
196
301
  },
197
302
  /**
198
303
  * 判断是否为数字
199
304
  * @param val 要检查的值
200
305
  * @returns 如果值是数字,则返回 true,否则返回 false
201
306
  */
202
- isNumber(e) {
203
- return typeof e == "number" && !isNaN(e);
307
+ isNumber(t) {
308
+ return typeof t == "number" && !isNaN(t);
204
309
  },
205
310
  /**
206
311
  * 判断是否为对象
207
312
  * @param val 要检查的值
208
313
  * @returns 如果值是对象,则返回 true,否则返回 false
209
314
  */
210
- isObject(e) {
211
- return e !== null && typeof e == "object" && !Array.isArray(e);
315
+ isObject(t) {
316
+ return t !== null && typeof t == "object" && !Array.isArray(t);
212
317
  },
213
318
  /**
214
319
  * 判断对象是否为空
215
320
  * @param obj 要检查的对象
216
321
  * @returns 如果对象为空,则返回 true,否则返回 false
217
322
  */
218
- isEmptyObject(e) {
219
- return e ? Object.keys(e).length === 0 && e.constructor === Object : !0;
323
+ isEmptyObject(t) {
324
+ return t ? Object.keys(t).length === 0 && t.constructor === Object : !0;
220
325
  },
221
326
  /**
222
327
  * 判断是否为布尔值
223
328
  * @param val 要检查的值
224
329
  * @returns 如果值是布尔值,则返回 true,否则返回 false
225
330
  */
226
- isBoolean(e) {
227
- return typeof e == "boolean";
331
+ isBoolean(t) {
332
+ return typeof t == "boolean";
228
333
  },
229
334
  /**
230
335
  * 判断是否为数组
231
336
  * @param val 要检查的值
232
337
  * @returns 如果值是数组,则返回 true,否则返回 false
233
338
  */
234
- isArray(e) {
235
- return Array.isArray(e);
339
+ isArray(t) {
340
+ return Array.isArray(t);
236
341
  },
237
342
  /**
238
343
  * 判断是否为函数
239
344
  * @param val 要检查的值
240
345
  * @returns
241
346
  */
242
- isFunction(e) {
243
- return typeof e == "function";
347
+ isFunction(t) {
348
+ return typeof t == "function";
244
349
  },
245
350
  /**
246
351
  * 判断是否为 Promise 对象
@@ -248,41 +353,41 @@ const m = (e) => {
248
353
  * @returns 如果对象是 Promise 对象,则返回 true,否则返回 false
249
354
  */
250
355
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
251
- isPromise(e) {
252
- return !!e && (typeof e == "object" || typeof e == "function") && typeof e.then == "function";
356
+ isPromise(t) {
357
+ return !!t && (typeof t == "object" || typeof t == "function") && typeof t.then == "function";
253
358
  },
254
359
  /**
255
360
  * 判断是否为 DOM 元素
256
361
  * @param obj 要检查的对象
257
362
  * @returns 如果对象是 DOM 元素,则返回 true,否则返回 false
258
363
  */
259
- isElement(e) {
260
- return e instanceof Element;
364
+ isElement(t) {
365
+ return t instanceof Element;
261
366
  },
262
367
  /**
263
368
  * 判断手机号格式(中国)
264
369
  * @param str 手机号字符串
265
370
  * @returns true 表示手机号格式正确,false 表示手机号格式错误
266
371
  */
267
- isPhone(e) {
268
- return /^1[3-9]\d{9}$/.test(e);
372
+ isPhone(t) {
373
+ return /^1[3-9]\d{9}$/.test(t);
269
374
  },
270
375
  /**
271
376
  * 判断邮箱格式
272
377
  * @param str 邮箱字符串
273
378
  * @returns true 表示邮箱格式正确,false 表示邮箱格式错误
274
379
  */
275
- isEmail(e) {
276
- return /^[\w.-]+@[\w.-]+\.\w+$/.test(e);
380
+ isEmail(t) {
381
+ return /^[\w.-]+@[\w.-]+\.\w+$/.test(t);
277
382
  },
278
383
  /**
279
384
  * 判断字符串是否为 JSON
280
385
  * @param str 字符串
281
386
  * @returns true 表示是 JSON,false 表示不是 JSON
282
387
  */
283
- isJSON(e) {
388
+ isJSON(t) {
284
389
  try {
285
- return JSON.parse(e), !0;
390
+ return JSON.parse(t), !0;
286
391
  } catch {
287
392
  return !1;
288
393
  }
@@ -295,16 +400,16 @@ const m = (e) => {
295
400
  * const img = new Image();
296
401
  * img.src = "URL_ADDRESS * img.src = "https://example.com/image.jpg";
297
402
  */
298
- isImageLoaded(e) {
299
- return e.complete && e.naturalWidth !== 0;
403
+ isImageLoaded(t) {
404
+ return t.complete && t.naturalWidth !== 0;
300
405
  },
301
406
  /**
302
407
  * 判断元素是否在可视区域内
303
408
  * @param el 元素对象
304
409
  * @returns true 表示元素在可视区域内,false 表示元素不在可视区域内
305
410
  */
306
- isInViewport(e) {
307
- const n = e.getBoundingClientRect();
411
+ isInViewport(t) {
412
+ const n = t.getBoundingClientRect();
308
413
  return n.top >= 0 && n.left >= 0 && n.bottom <= window.innerHeight && n.right <= window.innerWidth;
309
414
  },
310
415
  /**
@@ -319,8 +424,8 @@ const m = (e) => {
319
424
  * isLeapYear(2025); // false
320
425
  * isLeapYear(2024); // true
321
426
  */
322
- isLeapYear(e) {
323
- return e % 4 === 0 && e % 100 !== 0 || e % 400 === 0;
427
+ isLeapYear(t) {
428
+ return t % 4 === 0 && t % 100 !== 0 || t % 400 === 0;
324
429
  },
325
430
  /**
326
431
  * 判断是否为移动端
@@ -329,15 +434,15 @@ const m = (e) => {
329
434
  isMobile() {
330
435
  return /Mobi|Android|iPhone/i.test(navigator.userAgent);
331
436
  }
332
- }, I = {
437
+ }, L = {
333
438
  /**
334
439
  * 通过传入的name获取cookie的值
335
440
  * @param name cookie的name
336
441
  * @returns cookie的值
337
442
  */
338
- getCookie(e) {
339
- if (!e) return;
340
- const n = document.cookie.match(new RegExp("(^| )" + e + "=([^;]+)"));
443
+ getCookie(t) {
444
+ if (!t) return;
445
+ const n = document.cookie.match(new RegExp("(^| )" + t + "=([^;]+)"));
341
446
  return n ? decodeURIComponent(n[2]) : null;
342
447
  },
343
448
  /**
@@ -347,27 +452,27 @@ const m = (e) => {
347
452
  * @param days cookie的过期时间,默认7天。如果为0,则表示cookie在会话结束时过期。如果为负数,则表示cookie已过期。
348
453
  * @returns void
349
454
  */
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=/`;
455
+ setCookie(t, n, e = 7) {
456
+ const o = /* @__PURE__ */ new Date();
457
+ o.setTime(o.getTime() + e * 24 * 60 * 60 * 1e3), document.cookie = `${t}=${encodeURIComponent(n)};expires=${o.toUTCString()};path=/`;
353
458
  },
354
459
  /**
355
460
  * 删除cookie
356
461
  * @param name cookie的name
357
462
  * @returns void
358
463
  */
359
- deleteCookie(e) {
360
- this.setCookie(e, "", -1);
464
+ deleteCookie(t) {
465
+ this.setCookie(t, "", -1);
361
466
  }
362
- }, j = {
467
+ }, T = {
363
468
  /**
364
469
  * 获取当前时间字符串
365
470
  * @param locales 区域设置。如:'zh-CN','en-US',"chinese"。默认'zh-CN'。
366
471
  * @param hour12 是否使用12小时制。默认false,使用24小时制。
367
472
  * @returns 当前时间的字符串。如:'2025/5/27 16:54:45'
368
473
  */
369
- getTimeString(e, n = !1) {
370
- return n ? (/* @__PURE__ */ new Date()).toLocaleString(e, { hour12: !0 }) : (/* @__PURE__ */ new Date()).toLocaleString("chinese", { hour12: !1 });
474
+ getTimeString(t, n = !1) {
475
+ return n ? (/* @__PURE__ */ new Date()).toLocaleString(t, { hour12: !0 }) : (/* @__PURE__ */ new Date()).toLocaleString("chinese", { hour12: !1 });
371
476
  },
372
477
  /**
373
478
  * 计算两个日期相差天数
@@ -375,9 +480,9 @@ const m = (e) => {
375
480
  * @param date2 日期2
376
481
  * @returns 相差天数
377
482
  */
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)));
483
+ diffDays(t, n) {
484
+ const e = new Date(t).getTime(), o = new Date(n).getTime();
485
+ return e > o ? Math.abs(Math.floor((e - o) / (24 * 3600 * 1e3))) : Math.abs(Math.floor((o - e) / (24 * 3600 * 1e3)));
381
486
  },
382
487
  /**
383
488
  * 生成唯一ID(时间戳+随机数)
@@ -393,10 +498,10 @@ const m = (e) => {
393
498
  * @param day 日期
394
499
  * @returns 当年的第几天
395
500
  */
396
- getWhichDays(e, n, t) {
397
- let r = t;
398
- for (let o = 1; o < n; o++)
399
- switch (o) {
501
+ getWhichDays(t, n, e) {
502
+ let o = e;
503
+ for (let r = 1; r < n; r++)
504
+ switch (r) {
400
505
  case 1:
401
506
  case 3:
402
507
  case 5:
@@ -404,34 +509,34 @@ const m = (e) => {
404
509
  case 8:
405
510
  case 10:
406
511
  case 12:
407
- r += 31;
512
+ o += 31;
408
513
  break;
409
514
  case 2:
410
- w.isLeapYear(e) ? r += 29 : r += 28;
515
+ C.isLeapYear(t) ? o += 29 : o += 28;
411
516
  break;
412
517
  default:
413
- r += 30;
518
+ o += 30;
414
519
  break;
415
520
  }
416
- return r;
521
+ return o;
417
522
  }
418
- }, v = {
523
+ }, j = {
419
524
  /**
420
525
  * 获取元素相对于文档顶部的偏移量(距离)
421
526
  * 处理了SVG元素的特殊情况。
422
527
  * @param el 元素
423
528
  * @returns 偏移量(距离值)
424
529
  */
425
- getOffsetTop(e) {
426
- if (!e)
530
+ getOffsetTop(t) {
531
+ if (!t)
427
532
  throw new Error("Element is not provided");
428
- if (e instanceof SVGElement) {
429
- const t = e.getBoundingClientRect(), r = window.pageYOffset || document.documentElement.scrollTop;
430
- return t.top + r;
533
+ if (t instanceof SVGElement) {
534
+ const e = t.getBoundingClientRect(), o = window.pageYOffset || document.documentElement.scrollTop;
535
+ return e.top + o;
431
536
  }
432
537
  let n = 0;
433
- for (; e; )
434
- n += e.offsetTop, e = e.offsetParent;
538
+ for (; t; )
539
+ n += t.offsetTop, t = t.offsetParent;
435
540
  return n;
436
541
  },
437
542
  /**
@@ -439,11 +544,11 @@ const m = (e) => {
439
544
  * @returns 包含滚动值的对象 { scrollLeft: 水平滚动值, scrollTop: 垂直滚动值 }
440
545
  */
441
546
  getScrollValue() {
442
- const e = {
547
+ const t = {
443
548
  scrollLeft: 0,
444
549
  scrollTop: 0
445
550
  };
446
- return e.scrollLeft = document.body.scrollLeft || document.documentElement.scrollLeft, e.scrollTop = document.body.scrollTop || document.documentElement.scrollTop, e;
551
+ return t.scrollLeft = document.body.scrollLeft || document.documentElement.scrollLeft, t.scrollTop = document.body.scrollTop || document.documentElement.scrollTop, t;
447
552
  },
448
553
  /**
449
554
  * 获取鼠标事件的页面坐标
@@ -453,12 +558,12 @@ const m = (e) => {
453
558
  * @param e 鼠标事件
454
559
  * @returns 包含页面坐标的对象 { pageX: 水平页面坐标, pageY: 垂直页面坐标 }
455
560
  */
456
- getPageValue(e) {
457
- e = e || window.event;
458
- const n = e.pageX || e.clientX + this.getScrollValue().scrollLeft, t = e.pageY || e.clientY + this.getScrollValue().scrollTop;
561
+ getPageValue(t) {
562
+ t = t || window.event;
563
+ const n = t.pageX || t.clientX + this.getScrollValue().scrollLeft, e = t.pageY || t.clientY + this.getScrollValue().scrollTop;
459
564
  return {
460
565
  pageX: n,
461
- pageY: t
566
+ pageY: e
462
567
  };
463
568
  },
464
569
  /**
@@ -469,32 +574,32 @@ const m = (e) => {
469
574
  * @param fn 事件处理函数
470
575
  */
471
576
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
472
- addEventListener(e, n, t) {
473
- e.addEventListener ? e.addEventListener(n, t) : e.attachEvent ? e.attachEvent("on" + n, t) : e["on" + n] = t;
577
+ addEventListener(t, n, e) {
578
+ t.addEventListener ? t.addEventListener(n, e) : t.attachEvent ? t.attachEvent("on" + n, e) : t["on" + n] = e;
474
579
  }
475
- }, R = {
580
+ }, k = {
476
581
  /**
477
582
  * 将blob对象转化成文件并导出到本地
478
583
  * @param blob blob对象
479
584
  * @param filename 文件名
480
585
  */
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);
586
+ saveAsBlob(t, n) {
587
+ const e = document.createElement("a"), o = window.URL.createObjectURL(t);
588
+ e.href = o, e.download = n, document.body.appendChild(e), e.click(), URL.revokeObjectURL(o), document.body.removeChild(e);
484
589
  }
485
- }, C = {
590
+ }, I = {
486
591
  /**
487
592
  * 将选中的字母数组从A-Z排序:用于试题选择答案的排序实例
488
593
  * @param arr 字母数组
489
594
  * @returns
490
595
  */
491
- sortFromA2Z(e) {
492
- return e != null && e.length ? e.sort((t, r) => {
493
- const o = t.toUpperCase(), s = r.toUpperCase();
494
- return o < s ? -1 : o > s ? 1 : 0;
596
+ sortFromA2Z(t) {
597
+ return t != null && t.length ? t.sort((e, o) => {
598
+ const r = e.toUpperCase(), s = o.toUpperCase();
599
+ return r < s ? -1 : r > s ? 1 : 0;
495
600
  }) : void 0;
496
601
  }
497
- }, k = {
602
+ }, H = {
498
603
  /**
499
604
  * 角度(度数)转弧度
500
605
  * 在数学和编程里,角度有两种常用单位,分别是度(°)和弧度(rad)。
@@ -503,8 +608,8 @@ const m = (e) => {
503
608
  * @param degrees 度数。单位:°
504
609
  * @returns 弧度值
505
610
  */
506
- degrees2Radians(e) {
507
- return e * Math.PI / 180;
611
+ degrees2Radians(t) {
612
+ return t * Math.PI / 180;
508
613
  },
509
614
  /**
510
615
  * 根据经纬度计算距离【弃用】
@@ -514,14 +619,14 @@ const m = (e) => {
514
619
  * @param targetLng 目标经度
515
620
  * @returns 距离值 单位:km
516
621
  */
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(
622
+ getDistance(t, n, e, o) {
623
+ const r = this.degrees2Radians(t), s = this.degrees2Radians(e), c = r - s, l = this.degrees2Radians(n) - this.degrees2Radians(o);
624
+ let i = 2 * Math.asin(
520
625
  Math.sqrt(
521
- Math.pow(Math.sin(l / 2), 2) + Math.cos(o) * Math.cos(s) * Math.pow(Math.sin(c / 2), 2)
626
+ Math.pow(Math.sin(c / 2), 2) + Math.cos(r) * Math.cos(s) * Math.pow(Math.sin(l / 2), 2)
522
627
  )
523
628
  );
524
- return a = a * 6378.137, a = Math.round(a * 1e4) / 1e4, a = +a.toFixed(2), console.log("经纬度计算的距离为:" + a), a;
629
+ return i = i * 6378.137, i = Math.round(i * 1e4) / 1e4, i = +i.toFixed(2), console.log("经纬度计算的距离为:" + i), i;
525
630
  },
526
631
  /**
527
632
  * 计算两个坐标点之间的距离(Haversine公式)
@@ -538,23 +643,23 @@ const m = (e) => {
538
643
  * @param unit 距离单位,默认单位为千米。可选值:km(千米)、m(米)、mi(英里)、nmi(海里)
539
644
  * @returns 距离值
540
645
  */
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)
646
+ calculateDistanceByHaversine(t, n, e = "km") {
647
+ const o = this, r = t.longitude ?? t.lng, s = t.latitude ?? t.lat, c = n.longitude ?? n.lng, l = n.latitude ?? n.lat;
648
+ if (r === void 0 || s === void 0 || c === void 0 || l === void 0)
544
649
  throw new Error("无效的坐标格式,缺少经纬度信息");
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;
546
- switch (t) {
650
+ const i = 6371, h = o.degrees2Radians(s), a = o.degrees2Radians(l), u = o.degrees2Radians(l - s), d = o.degrees2Radians(c - r), g = 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(g), Math.sqrt(1 - g)), p = i * f;
651
+ switch (e) {
547
652
  case "m":
548
- return h * 1e3;
653
+ return p * 1e3;
549
654
  // 米
550
655
  case "mi":
551
- return h * 0.621371;
656
+ return p * 0.621371;
552
657
  // 英里
553
658
  case "nmi":
554
- return h * 0.539957;
659
+ return p * 0.539957;
555
660
  // 海里
556
661
  default:
557
- return h;
662
+ return p;
558
663
  }
559
664
  },
560
665
  /**
@@ -564,23 +669,23 @@ const m = (e) => {
564
669
  * @param closed 是否闭合路径,默认不闭合
565
670
  * @returns 距离结果对象。包含每个距离段的数组(segments)和总距离(total)。
566
671
  */
567
- calculateDistancesByHaversine(e, n = "km", t = !1) {
568
- if (e.length < 2)
672
+ calculateDistancesByHaversine(t, n = "km", e = !1) {
673
+ if (t.length < 2)
569
674
  return { segments: [], total: 0 };
570
- const r = [];
571
- let o = 0;
572
- for (let s = 0; s < e.length - 1; s++) {
573
- const l = this.calculateDistanceByHaversine(e[s], e[s + 1], n);
574
- r.push(l), o += l;
675
+ const o = [];
676
+ let r = 0;
677
+ for (let s = 0; s < t.length - 1; s++) {
678
+ const c = this.calculateDistanceByHaversine(t[s], t[s + 1], n);
679
+ o.push(c), r += c;
575
680
  }
576
- if (t && e.length > 2) {
577
- const s = this.calculateDistanceByHaversine(e[e.length - 1], e[0], n);
578
- r.push(s), o += s;
681
+ if (e && t.length > 2) {
682
+ const s = this.calculateDistanceByHaversine(t[t.length - 1], t[0], n);
683
+ o.push(s), r += s;
579
684
  }
580
- return { segments: r, total: o };
685
+ return { segments: o, total: r };
581
686
  }
582
687
  };
583
- class B {
688
+ class N {
584
689
  /**
585
690
  * 转换为标准金额格式(带千分位和两位小数)
586
691
  * @param num 要转换的数字
@@ -588,14 +693,14 @@ class B {
588
693
  */
589
694
  static toStandardFormat(n) {
590
695
  try {
591
- const t = typeof n == "string" ? parseFloat(n) : n;
592
- if (isNaN(t))
696
+ const e = typeof n == "string" ? parseFloat(n) : n;
697
+ if (isNaN(e))
593
698
  throw new Error("输入不是有效的数字");
594
- if (!isFinite(t))
699
+ if (!isFinite(e))
595
700
  throw new Error("输入是无穷大");
596
- return t.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
597
- } catch (t) {
598
- return console.error("格式化失败:", t), "格式错误";
701
+ return e.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
702
+ } catch (e) {
703
+ return console.error("格式化失败:", e), "格式错误";
599
704
  }
600
705
  }
601
706
  /**
@@ -605,61 +710,61 @@ class B {
605
710
  */
606
711
  static toChineseFormat(n) {
607
712
  try {
608
- const t = typeof n == "string" ? parseFloat(n) : n;
609
- if (isNaN(t))
713
+ const e = typeof n == "string" ? parseFloat(n) : n;
714
+ if (isNaN(e))
610
715
  throw new Error("输入不是有效的数字");
611
- if (t > 9999999999999e-2 || t < -9999999999999e-2)
716
+ if (e > 9999999999999e-2 || e < -9999999999999e-2)
612
717
  throw new Error("输入数字超出范围");
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;
718
+ const o = e < 0, r = Math.abs(e), s = Math.floor(r), c = Math.round((r - s) * 100), l = ["零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"], i = ["", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾", "佰", "仟"], h = ["角", "分"];
719
+ let a = "", u = s;
615
720
  if (u === 0)
616
- i = c[0];
721
+ a = l[0];
617
722
  else {
618
- let p = 0;
723
+ let f = 0;
619
724
  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++;
725
+ const p = u % 10;
726
+ p !== 0 ? a = l[p] + i[f] + a : a.charAt(0) !== l[0] && (a = l[p] + a), u = Math.floor(u / 10), f++;
622
727
  }
623
- i = i.replace(/零+/g, "零"), i = i.replace(/零+$/, "");
728
+ a = a.replace(/零+/g, "零"), a = a.replace(/零+$/, "");
624
729
  }
625
- let f = "";
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]);
730
+ let d = "";
731
+ if (c > 0) {
732
+ const f = Math.floor(c / 10), p = c % 10;
733
+ f > 0 && (d += l[f] + h[0]), p > 0 && (d += l[p] + h[1]);
629
734
  } else
630
- f = "整";
631
- let d = (r ? "负" : "") + i + "圆" + f;
632
- return d === "零圆整" && (d = "零圆"), d;
633
- } catch (t) {
634
- return console.error("转换失败:", t), "格式错误";
735
+ d = "整";
736
+ let g = (o ? "负" : "") + a + "圆" + d;
737
+ return g === "零圆整" && (g = "零圆"), g;
738
+ } catch (e) {
739
+ return console.error("转换失败:", e), "格式错误";
635
740
  }
636
741
  }
637
742
  }
638
- const M = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], x = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
743
+ const B = (t) => t > 25 || t < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[t], E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
639
744
  __proto__: null,
640
- toLetter: M
641
- }, Symbol.toStringTag, { value: "Module" })), S = (e) => e.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","), O = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
745
+ toLetter: B
746
+ }, Symbol.toStringTag, { value: "Module" })), x = (t) => t.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","), _ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
642
747
  __proto__: null,
643
- toMoney: S
644
- }, Symbol.toStringTag, { value: "Module" })), V = {
645
- ...x,
646
- ...O,
748
+ toMoney: x
749
+ }, Symbol.toStringTag, { value: "Module" })), P = {
750
+ ...E,
751
+ ..._,
647
752
  /**
648
753
  * 判断是否为数字
649
754
  * @param val 待判断的值
650
755
  * @returns 是否为数字。true 是;false 否
651
756
  */
652
- isNumber(e) {
653
- return typeof e == "number" && !isNaN(e);
757
+ isNumber(t) {
758
+ return typeof t == "number" && !isNaN(t);
654
759
  }
655
- }, _ = {
760
+ }, $ = {
656
761
  /**
657
762
  * 判断对象是否为空
658
763
  * @param obj 对象
659
764
  * @returns 是否为空。true 为空;false 不为空
660
765
  */
661
- isEmptyObject(e) {
662
- return e ? Object.keys(e).length === 0 && e.constructor === Object : !0;
766
+ isEmptyObject(t) {
767
+ return t ? Object.keys(t).length === 0 && t.constructor === Object : !0;
663
768
  },
664
769
  /**
665
770
  * 复制对象【对象的浅拷贝 把obj1的成员,复制给obj2】
@@ -667,9 +772,9 @@ const M = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], x = /*
667
772
  * @param obj2 目标对象
668
773
  */
669
774
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
670
- copy(e, n) {
671
- for (const t in e)
672
- n[t] = e[t];
775
+ copy(t, n) {
776
+ for (const e in t)
777
+ n[e] = t[e];
673
778
  },
674
779
  /**
675
780
  * 对象的深拷贝 把o1 的成员,复制给o2
@@ -677,22 +782,22 @@ const M = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], x = /*
677
782
  * @param o2
678
783
  */
679
784
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
680
- deepCopy(e, n) {
681
- for (const t in e) {
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];
785
+ deepCopy(t, n) {
786
+ for (const e in t) {
787
+ const o = t[e];
788
+ o instanceof Object ? (n[e] = {}, this.deepCopy(o, n[e])) : o instanceof Array ? (n[e] = [], this.deepCopy(o, n[e])) : n[e] = t[e];
684
789
  }
685
790
  }
686
- }, T = {
791
+ }, D = {
687
792
  /**
688
793
  * 脱敏
689
794
  * @param phone 电话号码/手机号码
690
795
  * @returns 脱敏后的电话号码/手机号码
691
796
  */
692
- desensitize(e) {
693
- return e ? e.replace(/^(\d{3})\d{4}(\d{4})$/, "$1****$2") || e.slice(0, 3) + "****" + e.slice(7) : "";
797
+ desensitize(t) {
798
+ return t ? t.replace(/^(\d{3})\d{4}(\d{4})$/, "$1****$2") || t.slice(0, 3) + "****" + t.slice(7) : "";
694
799
  }
695
- }, $ = {
800
+ }, F = {
696
801
  /**
697
802
  * 生成随机颜色
698
803
  * @returns 随机颜色值
@@ -706,8 +811,8 @@ const M = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], x = /*
706
811
  * @param max 最大值
707
812
  * @returns 随机数
708
813
  */
709
- int(e, n) {
710
- return Math.floor(Math.random() * (n - e + 1)) + e;
814
+ int(t, n) {
815
+ return Math.floor(Math.random() * (n - t + 1)) + t;
711
816
  },
712
817
  /**
713
818
  * 生成唯一ID(时间戳+随机数)
@@ -716,7 +821,7 @@ const M = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], x = /*
716
821
  uniqueId() {
717
822
  return Date.now().toString(36) + Math.random().toString(36).substr(2, 5);
718
823
  }
719
- }, N = {
824
+ }, V = {
720
825
  /**
721
826
  * 验证手机号
722
827
  */
@@ -753,65 +858,65 @@ const M = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], x = /*
753
858
  * 验证0.01~0.99正则:最多两位小数。0.1、0.10、0.9、0.90
754
859
  */
755
860
  decimal: /^0\.(0[1-9]|[1-9][0-9]*)$/
756
- }, P = {
861
+ }, z = {
757
862
  /**
758
863
  * 通过key值获取 localStorage 中存储的某个值
759
864
  * @param key 获取的key
760
865
  * @returns 获取的值
761
866
  */
762
- getLocal(e) {
763
- return localStorage.getItem(e);
867
+ getLocal(t) {
868
+ return localStorage.getItem(t);
764
869
  },
765
870
  /**
766
871
  * 设置localStorage中的某个值
767
872
  * @param key 设置的key
768
873
  * @param value 设置的value
769
874
  */
770
- setLocal(e, n) {
771
- localStorage.setItem(e, n);
875
+ setLocal(t, n) {
876
+ localStorage.setItem(t, n);
772
877
  },
773
878
  /**
774
879
  * 删除localStorage中的某个值
775
880
  * @param key 删除的key
776
881
  */
777
- removeLocal(e) {
778
- localStorage.removeItem(e);
882
+ removeLocal(t) {
883
+ localStorage.removeItem(t);
779
884
  },
780
885
  /**
781
886
  * 通过key值获取 sessionStorage 中存储的某个值
782
887
  * @param key 获取的key
783
888
  * @returns 获取的值
784
889
  */
785
- getSession(e) {
786
- return sessionStorage.getItem(e);
890
+ getSession(t) {
891
+ return sessionStorage.getItem(t);
787
892
  },
788
893
  /**
789
894
  * 设置sessionStorage中的某个值
790
895
  * @param key 设置的key
791
896
  * @param value 设置的value
792
897
  */
793
- setSession(e, n) {
794
- sessionStorage.setItem(e, n);
898
+ setSession(t, n) {
899
+ sessionStorage.setItem(t, n);
795
900
  },
796
901
  /**
797
902
  * 删除sessionStorage中的某个值
798
903
  * @param key 删除的key
799
904
  */
800
- removeSession(e) {
801
- sessionStorage.removeItem(e);
905
+ removeSession(t) {
906
+ sessionStorage.removeItem(t);
802
907
  }
803
- }, D = {
908
+ }, W = {
804
909
  /**
805
910
  * 判断某元素是否在字符串中-比includes()方法更兼容,includes为ES6新增方法,IE不支持。小程序也不支持
806
911
  * @param str 字符串
807
912
  * @param element 查询元素
808
913
  * @returns 是否存在。true 存在;false 不存在
809
914
  */
810
- isExist(e, n) {
811
- if (!e || !n)
915
+ isExist(t, n) {
916
+ if (!t || !n)
812
917
  return !1;
813
- const t = e.split(",");
814
- return console.log("判断某元素是否在字符串中", t.indexOf(n) === -1), t.indexOf(n) !== -1;
918
+ const e = t.split(",");
919
+ return console.log("判断某元素是否在字符串中", e.indexOf(n) === -1), e.indexOf(n) !== -1;
815
920
  },
816
921
  /**
817
922
  * 判断某元素是否在字符串中-比isExist()方法更高效。
@@ -819,17 +924,17 @@ const M = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], x = /*
819
924
  * @param element 查询元素
820
925
  * @returns 是否存在。true 存在;false 不存在
821
926
  */
822
- includes(e, n) {
823
- return !e || !n ? !1 : e.includes(n);
927
+ includes(t, n) {
928
+ return !t || !n ? !1 : t.includes(n);
824
929
  },
825
930
  /**
826
931
  * 判断字符串是否为 JSON
827
932
  * @param str 字符串
828
933
  * @returns
829
934
  */
830
- isJSON(e) {
935
+ isJSON(t) {
831
936
  try {
832
- return JSON.parse(e), !0;
937
+ return JSON.parse(t), !0;
833
938
  } catch {
834
939
  return !1;
835
940
  }
@@ -840,46 +945,46 @@ const M = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], x = /*
840
945
  * @param element 元素
841
946
  * @returns 位置数组
842
947
  */
843
- indexsOfAppear(e, n) {
844
- let t = -1;
845
- const r = [];
948
+ indexsOfAppear(t, n) {
949
+ let e = -1;
950
+ const o = [];
846
951
  do
847
- t = e.indexOf(n, t + 1), t !== -1 && r.push(t);
848
- while (t !== -1);
849
- return r;
952
+ e = t.indexOf(n, e + 1), e !== -1 && o.push(e);
953
+ while (e !== -1);
954
+ return o;
850
955
  },
851
956
  /**
852
957
  * 获取字符串中出现次数最多的字符和次数
853
958
  * @param string 字符串
854
959
  * @returns 数组,第一个元素为出现次数,第二个元素为出现次数最多的字符
855
960
  */
856
- getMaxTimesAndVal(e) {
857
- const n = [0, ""], t = {};
858
- for (let s = 0; s < e.length; s++) {
859
- const l = e.charAt(s);
860
- t[l] ? t[l]++ : t[l] = 1;
961
+ getMaxTimesAndVal(t) {
962
+ const n = [0, ""], e = {};
963
+ for (let s = 0; s < t.length; s++) {
964
+ const c = t.charAt(s);
965
+ e[c] ? e[c]++ : e[c] = 1;
861
966
  }
862
- let r = 1;
863
- for (const s in t)
864
- r < t[s] && (r = t[s]);
865
- const o = [];
866
- for (const s in t)
867
- r == t[s] && o.push(s);
868
- return n[0] = r, n[1] = o.join(), n;
967
+ let o = 1;
968
+ for (const s in e)
969
+ o < e[s] && (o = e[s]);
970
+ const r = [];
971
+ for (const s in e)
972
+ o == e[s] && r.push(s);
973
+ return n[0] = o, n[1] = r.join(), n;
869
974
  }
870
- }, A = (e) => {
871
- const t = new RegExp("[?&]" + e + "=([^&#]*)", "i").exec(window.location.href);
872
- return t ? decodeURIComponent(t[1]) : null;
975
+ }, O = (t) => {
976
+ const e = new RegExp("[?&]" + t + "=([^&#]*)", "i").exec(window.location.href);
977
+ return e ? decodeURIComponent(e[1]) : null;
873
978
  };
874
- function U(e) {
875
- return new URLSearchParams(window.location.search).get(e);
979
+ function R(t) {
980
+ return new URLSearchParams(window.location.search).get(t);
876
981
  }
877
- const E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
982
+ const v = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
878
983
  __proto__: null,
879
- getQueryInfoByName: A,
880
- getQueryParam: U
881
- }, Symbol.toStringTag, { value: "Module" })), F = {
882
- ...E,
984
+ getQueryInfoByName: O,
985
+ getQueryParam: R
986
+ }, Symbol.toStringTag, { value: "Module" })), q = {
987
+ ...v,
883
988
  /**
884
989
  * 获取当前域名
885
990
  * @returns 当前url链接的host信息
@@ -894,55 +999,61 @@ const E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
894
999
  getPath() {
895
1000
  return window.location.pathname;
896
1001
  }
897
- }, z = {
1002
+ }, Y = {
898
1003
  /**
899
1004
  * 处理瀑布流数据,使其竖向瀑布流布局呈现横向瀑布流的展现形式。适用于 column-gap: 20rpx; column-count: 2; 布局的瀑布流
900
1005
  * @param list 瀑布流数据-数组
901
1006
  * @param columnsNum 需要展示的列数
902
1007
  * @returns 适合瀑布流布局的数组
903
1008
  */
904
- toList(e, n = 2) {
905
- console.log(e, n);
906
- const t = {};
907
- for (let o = 0; o < n; o++)
908
- t[o] = [];
909
- e.forEach((o, s) => t[s % n].push(o));
910
- const r = [];
911
- for (const o in t)
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;
1009
+ toList(t, n = 2) {
1010
+ console.log(t, n);
1011
+ const e = {};
1012
+ for (let r = 0; r < n; r++)
1013
+ e[r] = [];
1014
+ t.forEach((r, s) => e[s % n].push(r));
1015
+ const o = [];
1016
+ for (const r in e)
1017
+ o.push(...e[r]);
1018
+ return o;
1019
+ },
1020
+ /**
1021
+ * js瀑布流布局
1022
+ * @param itemBox 瀑布流容器
1023
+ * @param items 瀑布流元素
1024
+ * @param step 间距
1025
+ */
1026
+ jsLayout(t, n, e) {
1027
+ const o = t.offsetWidth, r = n[0].offsetWidth, s = parseInt((o / r).toString()), c = (o - r * s) / (s - 1), l = [];
1028
+ for (let i = 0, h = n.length; i < h; i++) {
1029
+ const a = n[i];
1030
+ if (i < s)
1031
+ a.style.left = (r + c) * i + "px", l[i] = a.offsetHeight;
921
1032
  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;
1033
+ const { index: u, value: d } = S.getMinValueAndIndex(l);
1034
+ a.style.left = (r + c) * u + "px", a.style.top = d + e + "px", l[u] = a.offsetHeight + e + d;
924
1035
  }
925
1036
  }
926
1037
  }
927
1038
  };
928
1039
  export {
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,
944
- P as storageUtils,
945
- D as stringUtils,
946
- F as urlUtils,
947
- z as waterfallUtils
1040
+ M as Base64Utils,
1041
+ N as MoneyFormatter,
1042
+ S as arrayUtils,
1043
+ C as booleanUtils,
1044
+ L as cookieUtils,
1045
+ T as dateUtils,
1046
+ j as documentUtils,
1047
+ k as downloadUtils,
1048
+ I as letterUtils,
1049
+ H as mapUtils,
1050
+ P as numberUtils,
1051
+ $ as objectUtils,
1052
+ D as phoneUtils,
1053
+ F as randomUtils,
1054
+ V as regexpUtils,
1055
+ z as storageUtils,
1056
+ W as stringUtils,
1057
+ q as urlUtils,
1058
+ Y as waterfallUtils
948
1059
  };