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