@sybz-components/utils 0.0.8 → 0.0.9
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/base.cjs +2 -2
- package/dist/base.d.cts +1 -2
- package/dist/base.d.mts +1 -2
- package/dist/base.d.ts +1 -2
- package/dist/base.mjs +2 -2
- package/dist/format.cjs +2 -2
- package/dist/format.mjs +2 -2
- package/dist/index.cjs +2 -4
- package/dist/index.d.cts +0 -2
- package/dist/index.d.mts +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.mjs +2 -3
- package/dist/shared/{utils.cf1aBGgC.mjs → utils.1NRU16hJ.mjs} +48 -43
- package/dist/shared/{utils.CDpXB2JP.cjs → utils.DQLx7A8M.cjs} +56 -51
- package/dist/ws.cjs +1 -1
- package/dist/ws.mjs +1 -1
- package/package.json +1 -1
- package/dist/test.cjs +0 -7
- package/dist/test.d.cts +0 -14
- package/dist/test.d.mts +0 -14
- package/dist/test.d.ts +0 -14
- package/dist/test.mjs +0 -5
package/dist/base.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('
|
|
3
|
+
require('vue');
|
|
4
4
|
require('consola');
|
|
5
5
|
require('es-toolkit');
|
|
6
|
-
const format = require('./shared/utils.
|
|
6
|
+
const format = require('./shared/utils.DQLx7A8M.cjs');
|
|
7
7
|
require('element-plus');
|
|
8
8
|
require('./is.cjs');
|
|
9
9
|
|
package/dist/base.d.cts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as element_plus from 'element-plus';
|
|
2
2
|
import { MessageOptions, ElMessageBoxOptions } from 'element-plus';
|
|
3
3
|
import * as vue from 'vue';
|
|
4
|
-
import { VNode, AppContext } from 'vue';
|
|
5
|
-
import { Ref } from '@vue/reactivity';
|
|
4
|
+
import { VNode, Ref, AppContext } from 'vue';
|
|
6
5
|
|
|
7
6
|
type Func<Args extends any[] = any[], Return = any> = (...args: Args) => Return;
|
|
8
7
|
type StorageValue = unknown;
|
package/dist/base.d.mts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as element_plus from 'element-plus';
|
|
2
2
|
import { MessageOptions, ElMessageBoxOptions } from 'element-plus';
|
|
3
3
|
import * as vue from 'vue';
|
|
4
|
-
import { VNode, AppContext } from 'vue';
|
|
5
|
-
import { Ref } from '@vue/reactivity';
|
|
4
|
+
import { VNode, Ref, AppContext } from 'vue';
|
|
6
5
|
|
|
7
6
|
type Func<Args extends any[] = any[], Return = any> = (...args: Args) => Return;
|
|
8
7
|
type StorageValue = unknown;
|
package/dist/base.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as element_plus from 'element-plus';
|
|
2
2
|
import { MessageOptions, ElMessageBoxOptions } from 'element-plus';
|
|
3
3
|
import * as vue from 'vue';
|
|
4
|
-
import { VNode, AppContext } from 'vue';
|
|
5
|
-
import { Ref } from '@vue/reactivity';
|
|
4
|
+
import { VNode, Ref, AppContext } from 'vue';
|
|
6
5
|
|
|
7
6
|
type Func<Args extends any[] = any[], Return = any> = (...args: Args) => Return;
|
|
8
7
|
type StorageValue = unknown;
|
package/dist/base.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import '
|
|
1
|
+
import 'vue';
|
|
2
2
|
import 'consola';
|
|
3
3
|
import 'es-toolkit';
|
|
4
|
-
export { $ as $toast, c as clearStorage, a as clone, b as confirm, d as copy, e as debounce, g as getStorage, f as getType, h as getUtilsBuildTime, i as getVariable, j as isEmpty, l as log, m as merge, p as processWidth, r as random, s as setStorage, k as sleep, t as test, n as throttle, o as toLine, q as tryCatch, u as uuid, v as validForm, w as validate, x as validateTrigger } from './shared/utils.
|
|
4
|
+
export { $ as $toast, c as clearStorage, a as clone, b as confirm, d as copy, e as debounce, g as getStorage, f as getType, h as getUtilsBuildTime, i as getVariable, j as isEmpty, l as log, m as merge, p as processWidth, r as random, s as setStorage, k as sleep, t as test, n as throttle, o as toLine, q as tryCatch, u as uuid, v as validForm, w as validate, x as validateTrigger } from './shared/utils.1NRU16hJ.mjs';
|
|
5
5
|
import 'element-plus';
|
|
6
6
|
import './is.mjs';
|
package/dist/format.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const format = require('./shared/utils.
|
|
3
|
+
const format = require('./shared/utils.DQLx7A8M.cjs');
|
|
4
4
|
require('./is.cjs');
|
|
5
|
-
require('@vue/reactivity');
|
|
6
5
|
require('consola');
|
|
6
|
+
require('vue');
|
|
7
7
|
require('es-toolkit');
|
|
8
8
|
require('element-plus');
|
|
9
9
|
|
package/dist/format.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { y as formatBytes, z as formatBytesConvert, A as formatDurationTime, B as formatImg, C as formatTextToHtml, D as formatThousands, E as formatTime, F as formatToFixed } from './shared/utils.
|
|
1
|
+
export { y as formatBytes, z as formatBytesConvert, A as formatDurationTime, B as formatImg, C as formatTextToHtml, D as formatThousands, E as formatTime, F as formatToFixed } from './shared/utils.1NRU16hJ.mjs';
|
|
2
2
|
import './is.mjs';
|
|
3
|
-
import '@vue/reactivity';
|
|
4
3
|
import 'consola';
|
|
4
|
+
import 'vue';
|
|
5
5
|
import 'es-toolkit';
|
|
6
6
|
import 'element-plus';
|
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const format = require('./shared/utils.
|
|
3
|
+
const format = require('./shared/utils.DQLx7A8M.cjs');
|
|
4
4
|
const day = require('./day.cjs');
|
|
5
5
|
const is = require('./is.cjs');
|
|
6
6
|
const ws = require('./ws.cjs');
|
|
7
|
-
|
|
8
|
-
require('@vue/reactivity');
|
|
7
|
+
require('vue');
|
|
9
8
|
require('consola');
|
|
10
9
|
require('es-toolkit');
|
|
11
10
|
require('element-plus');
|
|
@@ -75,4 +74,3 @@ exports.objectToString = is.objectToString;
|
|
|
75
74
|
exports.toRawType = is.toRawType;
|
|
76
75
|
exports.toTypeString = is.toTypeString;
|
|
77
76
|
exports.WS = ws.WS;
|
|
78
|
-
exports.onlyTest = test.onlyTest;
|
package/dist/index.d.cts
CHANGED
|
@@ -3,8 +3,6 @@ export { diffDate, diffDateFromCurrent, formatDate, formatDateToDay, formatDateT
|
|
|
3
3
|
export { isArray, isBoolean, isComponent, isDate, isEmptyObject, isFunction, isIOS, isMap, isNumber, isObject, isPlainObject, isPromise, isRegExp, isSVGElement, isSet, isString, isStringNumber, isSymbol, isUrl, objectToString, toRawType, toTypeString } from './is.cjs';
|
|
4
4
|
export { WS, WSAutoReconnectOptions, WSHeartbeatOptions, WSOptions } from './ws.cjs';
|
|
5
5
|
export { FormatBytesConvertOptions, FormatBytesOptions, FormatImgOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions, formatBytes, formatBytesConvert, formatDurationTime, formatImg, formatTextToHtml, formatThousands, formatTime, formatToFixed } from './format.cjs';
|
|
6
|
-
export { onlyTest } from './test.cjs';
|
|
7
6
|
import 'element-plus';
|
|
8
7
|
import 'vue';
|
|
9
|
-
import '@vue/reactivity';
|
|
10
8
|
import 'dayjs';
|
package/dist/index.d.mts
CHANGED
|
@@ -3,8 +3,6 @@ export { diffDate, diffDateFromCurrent, formatDate, formatDateToDay, formatDateT
|
|
|
3
3
|
export { isArray, isBoolean, isComponent, isDate, isEmptyObject, isFunction, isIOS, isMap, isNumber, isObject, isPlainObject, isPromise, isRegExp, isSVGElement, isSet, isString, isStringNumber, isSymbol, isUrl, objectToString, toRawType, toTypeString } from './is.mjs';
|
|
4
4
|
export { WS, WSAutoReconnectOptions, WSHeartbeatOptions, WSOptions } from './ws.mjs';
|
|
5
5
|
export { FormatBytesConvertOptions, FormatBytesOptions, FormatImgOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions, formatBytes, formatBytesConvert, formatDurationTime, formatImg, formatTextToHtml, formatThousands, formatTime, formatToFixed } from './format.mjs';
|
|
6
|
-
export { onlyTest } from './test.mjs';
|
|
7
6
|
import 'element-plus';
|
|
8
7
|
import 'vue';
|
|
9
|
-
import '@vue/reactivity';
|
|
10
8
|
import 'dayjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,6 @@ export { diffDate, diffDateFromCurrent, formatDate, formatDateToDay, formatDateT
|
|
|
3
3
|
export { isArray, isBoolean, isComponent, isDate, isEmptyObject, isFunction, isIOS, isMap, isNumber, isObject, isPlainObject, isPromise, isRegExp, isSVGElement, isSet, isString, isStringNumber, isSymbol, isUrl, objectToString, toRawType, toTypeString } from './is.js';
|
|
4
4
|
export { WS, WSAutoReconnectOptions, WSHeartbeatOptions, WSOptions } from './ws.js';
|
|
5
5
|
export { FormatBytesConvertOptions, FormatBytesOptions, FormatImgOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions, formatBytes, formatBytesConvert, formatDurationTime, formatImg, formatTextToHtml, formatThousands, formatTime, formatToFixed } from './format.js';
|
|
6
|
-
export { onlyTest } from './test.js';
|
|
7
6
|
import 'element-plus';
|
|
8
7
|
import 'vue';
|
|
9
|
-
import '@vue/reactivity';
|
|
10
8
|
import 'dayjs';
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
export { $ as $toast, c as clearStorage, a as clone, b as confirm, d as copy, e as debounce, y as formatBytes, z as formatBytesConvert, A as formatDurationTime, B as formatImg, C as formatTextToHtml, D as formatThousands, E as formatTime, F as formatToFixed, g as getStorage, f as getType, h as getUtilsBuildTime, i as getVariable, j as isEmpty, l as log, m as merge, p as processWidth, r as random, s as setStorage, k as sleep, t as test, n as throttle, o as toLine, q as tryCatch, u as uuid, v as validForm, w as validate, x as validateTrigger } from './shared/utils.
|
|
1
|
+
export { $ as $toast, c as clearStorage, a as clone, b as confirm, d as copy, e as debounce, y as formatBytes, z as formatBytesConvert, A as formatDurationTime, B as formatImg, C as formatTextToHtml, D as formatThousands, E as formatTime, F as formatToFixed, g as getStorage, f as getType, h as getUtilsBuildTime, i as getVariable, j as isEmpty, l as log, m as merge, p as processWidth, r as random, s as setStorage, k as sleep, t as test, n as throttle, o as toLine, q as tryCatch, u as uuid, v as validForm, w as validate, x as validateTrigger } from './shared/utils.1NRU16hJ.mjs';
|
|
2
2
|
export { diffDate, diffDateFromCurrent, formatDate, formatDateToDay, formatDateToMinute } from './day.mjs';
|
|
3
3
|
export { isArray, isBoolean, isComponent, isDate, isEmptyObject, isFunction, isIOS, isMap, isNumber, isObject, isPlainObject, isPromise, isRegExp, isSVGElement, isSet, isString, isStringNumber, isSymbol, isUrl, objectToString, toRawType, toTypeString } from './is.mjs';
|
|
4
4
|
export { WS } from './ws.mjs';
|
|
5
|
-
|
|
6
|
-
import '@vue/reactivity';
|
|
5
|
+
import 'vue';
|
|
7
6
|
import 'consola';
|
|
8
7
|
import 'es-toolkit';
|
|
9
8
|
import 'element-plus';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isRef, unref, toRaw } from '
|
|
1
|
+
import { isRef, unref, toRaw } from 'vue';
|
|
2
2
|
import { consola } from 'consola';
|
|
3
3
|
import { cloneDeep } from 'es-toolkit';
|
|
4
4
|
import { ElMessage, ElMessageBox } from 'element-plus';
|
|
@@ -47,9 +47,10 @@ function formatBytesConvert(oBytes, options = {}) {
|
|
|
47
47
|
}
|
|
48
48
|
const regex = /^\d{1,3}(,\d{3})*(\.\d+)?[a-zA-Z ]*$/;
|
|
49
49
|
if (typeof oBytes === "string" && regex.test(oBytes)) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
const normalizedBytes = oBytes.replace(/,/g, "");
|
|
51
|
+
bytes = normalizedBytes;
|
|
52
|
+
if (isStringNumber(normalizedBytes) || isNumber(normalizedBytes) || getType(normalizedBytes) !== "string") {
|
|
53
|
+
return parseDigitThounsands(normalizedBytes);
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
const bytesRegex = /^(\d+(?:\.\d+)?)\s*([BKMGTPEZY]?B|Byte)$/i;
|
|
@@ -70,13 +71,13 @@ function formatBytesConvert(oBytes, options = {}) {
|
|
|
70
71
|
}
|
|
71
72
|
const match = bytes.match(bytesRegex);
|
|
72
73
|
if (!match) {
|
|
73
|
-
|
|
74
|
+
consola.warn("Invalid bytes format. Please provide a valid bytes string, like '100GB'.");
|
|
74
75
|
return;
|
|
75
76
|
}
|
|
76
77
|
const size = parseFloat(match[1]);
|
|
77
78
|
const unit = match[2].toUpperCase();
|
|
78
79
|
if (!Object.prototype.hasOwnProperty.call(units, unit)) {
|
|
79
|
-
|
|
80
|
+
consola.warn(
|
|
80
81
|
"Invalid bytes unit. Please provide a valid unit, like 'B', 'BYTE', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', or 'YB'."
|
|
81
82
|
);
|
|
82
83
|
return;
|
|
@@ -224,9 +225,8 @@ function formatTextToHtml(str) {
|
|
|
224
225
|
if (!str || typeof str !== "string") {
|
|
225
226
|
return str;
|
|
226
227
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
return str;
|
|
228
|
+
const withBreaks = str.replace(/\n/g, "<br>");
|
|
229
|
+
return withBreaks.replace(/\t/g, " ");
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
const DEFAULT_CONFIRM_BUTTON_CLASS = "s-message-box__confirm-btn";
|
|
@@ -240,7 +240,7 @@ function _getBrowserStorage(isSession = false) {
|
|
|
240
240
|
}
|
|
241
241
|
try {
|
|
242
242
|
return isSession ? window.sessionStorage : window.localStorage;
|
|
243
|
-
} catch
|
|
243
|
+
} catch {
|
|
244
244
|
return null;
|
|
245
245
|
}
|
|
246
246
|
}
|
|
@@ -253,7 +253,7 @@ function _parseStorageValue(value) {
|
|
|
253
253
|
if (typeof parsed !== "number") {
|
|
254
254
|
return parsed;
|
|
255
255
|
}
|
|
256
|
-
} catch
|
|
256
|
+
} catch {
|
|
257
257
|
}
|
|
258
258
|
return value;
|
|
259
259
|
}
|
|
@@ -335,8 +335,8 @@ function clearStorage(str = "") {
|
|
|
335
335
|
sessionStorageRef?.clear();
|
|
336
336
|
localStorageRef?.clear();
|
|
337
337
|
}
|
|
338
|
-
if (
|
|
339
|
-
|
|
338
|
+
if (typeof str === "string" || Array.isArray(str)) {
|
|
339
|
+
const strArr = Array.isArray(str) ? str : [str];
|
|
340
340
|
for (let i = 0; i < strArr.length; i++) {
|
|
341
341
|
sessionStorageRef?.removeItem(strArr[i]);
|
|
342
342
|
localStorageRef?.removeItem(strArr[i]);
|
|
@@ -344,16 +344,18 @@ function clearStorage(str = "") {
|
|
|
344
344
|
}
|
|
345
345
|
if (_isObjectWithExclude(str)) {
|
|
346
346
|
if (!isEmpty(str.exclude) && getType(str) === "object") {
|
|
347
|
-
|
|
348
|
-
|
|
347
|
+
const sessionStorageObj = {};
|
|
348
|
+
const localStorageObj = {};
|
|
349
349
|
for (const key in str.exclude) {
|
|
350
350
|
if (Object.prototype.hasOwnProperty.call(str.exclude, key)) {
|
|
351
351
|
const name = str.exclude[key];
|
|
352
|
-
|
|
353
|
-
|
|
352
|
+
const localValue = getStorage(name);
|
|
353
|
+
const sessionValue = getStorage(name, true);
|
|
354
|
+
if (localValue !== null) {
|
|
355
|
+
localStorageObj[name] = localValue;
|
|
354
356
|
}
|
|
355
|
-
if (
|
|
356
|
-
sessionStorageObj[name] =
|
|
357
|
+
if (sessionValue !== null) {
|
|
358
|
+
sessionStorageObj[name] = sessionValue;
|
|
357
359
|
}
|
|
358
360
|
}
|
|
359
361
|
}
|
|
@@ -369,7 +371,7 @@ function clearStorage(str = "") {
|
|
|
369
371
|
}
|
|
370
372
|
}
|
|
371
373
|
function _isObjectWithExclude(obj) {
|
|
372
|
-
return typeof obj === "object" && obj !== null && "exclude" in obj &&
|
|
374
|
+
return typeof obj === "object" && obj !== null && "exclude" in obj && Array.isArray(obj.exclude);
|
|
373
375
|
}
|
|
374
376
|
function validForm(ref, { message = "\u8868\u5355\u6821\u9A8C\u9519\u8BEF, \u8BF7\u68C0\u67E5", detail = false, showMessage = true } = {}) {
|
|
375
377
|
return new Promise((resolve, reject) => {
|
|
@@ -429,7 +431,7 @@ function isEmpty(data, strict = true) {
|
|
|
429
431
|
return false;
|
|
430
432
|
}
|
|
431
433
|
function merge(obj1, obj2) {
|
|
432
|
-
|
|
434
|
+
const merged = { ...obj1, ...obj2 };
|
|
433
435
|
for (let key in merged) {
|
|
434
436
|
if (!isEmpty(obj1[key]) && !isEmpty(obj2[key])) {
|
|
435
437
|
merged[key] = obj2[key];
|
|
@@ -442,13 +444,11 @@ function merge(obj1, obj2) {
|
|
|
442
444
|
return merged;
|
|
443
445
|
}
|
|
444
446
|
function clone(data, times = 1) {
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
if (getType(data) !== "array") {
|
|
449
|
-
return cloneDeep(data);
|
|
447
|
+
const rawData = isRef(data) ? unref(data) : data;
|
|
448
|
+
if (!Array.isArray(rawData)) {
|
|
449
|
+
return cloneDeep(rawData);
|
|
450
450
|
}
|
|
451
|
-
const clonedData = cloneDeep(
|
|
451
|
+
const clonedData = cloneDeep(rawData);
|
|
452
452
|
const result = [];
|
|
453
453
|
for (let i = 0; i < times; i++) {
|
|
454
454
|
result.push(...clonedData);
|
|
@@ -622,18 +622,18 @@ function validate(type = "required", rules = {}, pureValid = false) {
|
|
|
622
622
|
);
|
|
623
623
|
}
|
|
624
624
|
if (type === "between" /* BETWEEN */) {
|
|
625
|
-
let
|
|
626
|
-
let
|
|
625
|
+
let minValue = rulesObject.min ?? "";
|
|
626
|
+
let maxValue = rulesObject.max ?? "";
|
|
627
627
|
const validateBetween = (rule, value, callback) => {
|
|
628
628
|
let validFlag = /^-?[0-9]+$/.test(value);
|
|
629
629
|
if (!validFlag) {
|
|
630
630
|
callback(new Error("\u8BF7\u8F93\u5165\u6570\u5B57"));
|
|
631
631
|
}
|
|
632
|
-
if (
|
|
633
|
-
callback(new Error(`\u6570\u5B57\u4E0D\u80FD\u5C0F\u4E8E${
|
|
632
|
+
if (!isEmpty(minValue) && value < minValue) {
|
|
633
|
+
callback(new Error(`\u6570\u5B57\u4E0D\u80FD\u5C0F\u4E8E${minValue}`));
|
|
634
634
|
}
|
|
635
|
-
if (value >
|
|
636
|
-
callback(new Error(`\u6570\u5B57\u4E0D\u80FD\u5927\u4E8E${
|
|
635
|
+
if (!isEmpty(maxValue) && value > maxValue && maxValue !== void 0) {
|
|
636
|
+
callback(new Error(`\u6570\u5B57\u4E0D\u80FD\u5927\u4E8E${maxValue}`));
|
|
637
637
|
}
|
|
638
638
|
callback();
|
|
639
639
|
};
|
|
@@ -696,6 +696,7 @@ function validate(type = "required", rules = {}, pureValid = false) {
|
|
|
696
696
|
trigger
|
|
697
697
|
};
|
|
698
698
|
}
|
|
699
|
+
return {};
|
|
699
700
|
}
|
|
700
701
|
const copy = (text, toastParams = {}) => {
|
|
701
702
|
const textarea = document.createElement("textarea");
|
|
@@ -706,14 +707,14 @@ const copy = (text, toastParams = {}) => {
|
|
|
706
707
|
document.execCommand("copy");
|
|
707
708
|
document.body.removeChild(textarea);
|
|
708
709
|
if (!toastParams.hideToast) {
|
|
709
|
-
const { hideToast, ...toastOptions } = toastParams;
|
|
710
|
+
const { hideToast: _hideToast, ...toastOptions } = toastParams;
|
|
710
711
|
$toast(text + "\u590D\u5236\u6210\u529F", toastOptions);
|
|
711
712
|
return true;
|
|
712
713
|
}
|
|
713
714
|
return true;
|
|
714
715
|
};
|
|
715
716
|
function log(variableStr, variable, otherInfo = "") {
|
|
716
|
-
const stack = new Error().stack
|
|
717
|
+
const stack = new Error().stack?.split("\n")[2]?.trim() ?? "";
|
|
717
718
|
const matchResult = stack.match(/\((.*):(\d+):(\d+)\)/);
|
|
718
719
|
let fileInfo = "";
|
|
719
720
|
try {
|
|
@@ -721,11 +722,11 @@ function log(variableStr, variable, otherInfo = "") {
|
|
|
721
722
|
const lineNumber = matchResult[2];
|
|
722
723
|
fileInfo = `vscode://file${JSON.parse(otherInfo)}:${lineNumber}`;
|
|
723
724
|
}
|
|
724
|
-
} catch
|
|
725
|
+
} catch {
|
|
725
726
|
fileInfo = otherInfo;
|
|
726
727
|
}
|
|
727
728
|
if (isRef(variable)) {
|
|
728
|
-
|
|
729
|
+
const unrefVariable = unref(variable);
|
|
729
730
|
_log(toRaw(unrefVariable));
|
|
730
731
|
} else {
|
|
731
732
|
_log(variable);
|
|
@@ -755,7 +756,7 @@ function random(min = 0, max = 10) {
|
|
|
755
756
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
756
757
|
}
|
|
757
758
|
function toLine(text, connect = "-") {
|
|
758
|
-
let translateText = text.replace(/([A-Z])/g, (match,
|
|
759
|
+
let translateText = text.replace(/([A-Z])/g, (match, _letter, offset) => {
|
|
759
760
|
if (offset === 0) {
|
|
760
761
|
return `${match.toLocaleLowerCase()}`;
|
|
761
762
|
} else {
|
|
@@ -804,7 +805,7 @@ async function tryCatch(task, sendLoading) {
|
|
|
804
805
|
if (isRef(sendLoading)) {
|
|
805
806
|
sendLoading.value = value;
|
|
806
807
|
} else if (sendLoading !== void 0 && sendLoading !== null) {
|
|
807
|
-
|
|
808
|
+
consola.warn("Cannot modify non-ref sendLoading directly!");
|
|
808
809
|
}
|
|
809
810
|
};
|
|
810
811
|
updateLoading(true);
|
|
@@ -907,7 +908,7 @@ function _resolveAppendTarget(appendTo) {
|
|
|
907
908
|
try {
|
|
908
909
|
const selector = rawSelector.startsWith("#") || rawSelector.startsWith(".") || rawSelector.startsWith("[") ? rawSelector : `#${rawSelector}`;
|
|
909
910
|
return document.querySelector(selector) || appendTo;
|
|
910
|
-
} catch
|
|
911
|
+
} catch {
|
|
911
912
|
return appendTo;
|
|
912
913
|
}
|
|
913
914
|
}
|
|
@@ -926,10 +927,14 @@ function _resolveAppContext(appContext) {
|
|
|
926
927
|
if (appContext) {
|
|
927
928
|
return appContext;
|
|
928
929
|
}
|
|
930
|
+
const installWithContext = ElMessageBox.install;
|
|
931
|
+
const messageBoxWithContext = ElMessageBox;
|
|
932
|
+
const elementPlusContext = installWithContext?.context || messageBoxWithContext._context || null;
|
|
929
933
|
if (typeof document === "undefined") {
|
|
930
|
-
return
|
|
934
|
+
return elementPlusContext;
|
|
931
935
|
}
|
|
932
|
-
|
|
936
|
+
const appRoot = document.querySelector("#app");
|
|
937
|
+
return elementPlusContext || appRoot?._vue_app?._context || null;
|
|
933
938
|
}
|
|
934
939
|
function getVariable(propertyName, fallback = "") {
|
|
935
940
|
if (typeof document === "undefined") {
|
|
@@ -941,7 +946,7 @@ function getVariable(propertyName, fallback = "") {
|
|
|
941
946
|
const DEFAULT_BUILD_TIME_FALLBACK = "\u672A\u6CE8\u5165";
|
|
942
947
|
function getUtilsBuildTime(fallback = DEFAULT_BUILD_TIME_FALLBACK) {
|
|
943
948
|
{
|
|
944
|
-
return "2026-06-
|
|
949
|
+
return "2026-06-29 10:10:51";
|
|
945
950
|
}
|
|
946
951
|
}
|
|
947
952
|
function test() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const vue = require('vue');
|
|
4
4
|
const consola = require('consola');
|
|
5
5
|
const esToolkit = require('es-toolkit');
|
|
6
6
|
const elementPlus = require('element-plus');
|
|
@@ -50,9 +50,10 @@ function formatBytesConvert(oBytes, options = {}) {
|
|
|
50
50
|
}
|
|
51
51
|
const regex = /^\d{1,3}(,\d{3})*(\.\d+)?[a-zA-Z ]*$/;
|
|
52
52
|
if (typeof oBytes === "string" && regex.test(oBytes)) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
const normalizedBytes = oBytes.replace(/,/g, "");
|
|
54
|
+
bytes = normalizedBytes;
|
|
55
|
+
if (is.isStringNumber(normalizedBytes) || is.isNumber(normalizedBytes) || getType(normalizedBytes) !== "string") {
|
|
56
|
+
return parseDigitThounsands(normalizedBytes);
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
const bytesRegex = /^(\d+(?:\.\d+)?)\s*([BKMGTPEZY]?B|Byte)$/i;
|
|
@@ -73,13 +74,13 @@ function formatBytesConvert(oBytes, options = {}) {
|
|
|
73
74
|
}
|
|
74
75
|
const match = bytes.match(bytesRegex);
|
|
75
76
|
if (!match) {
|
|
76
|
-
|
|
77
|
+
consola.consola.warn("Invalid bytes format. Please provide a valid bytes string, like '100GB'.");
|
|
77
78
|
return;
|
|
78
79
|
}
|
|
79
80
|
const size = parseFloat(match[1]);
|
|
80
81
|
const unit = match[2].toUpperCase();
|
|
81
82
|
if (!Object.prototype.hasOwnProperty.call(units, unit)) {
|
|
82
|
-
|
|
83
|
+
consola.consola.warn(
|
|
83
84
|
"Invalid bytes unit. Please provide a valid unit, like 'B', 'BYTE', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', or 'YB'."
|
|
84
85
|
);
|
|
85
86
|
return;
|
|
@@ -189,7 +190,7 @@ function formatImg(photoName, addPath = "", { basePath = "assets/images" } = {})
|
|
|
189
190
|
const addLastSlash = addPath.endsWith("/") || !addPath ? addPath : `${addPath}/`;
|
|
190
191
|
const addLastBasePathSlash = basePath.endsWith("/") || !basePath ? basePath : `${basePath}/`;
|
|
191
192
|
const mergeSrc = `${addLastSlash}${photoName}`;
|
|
192
|
-
return new URL(`../${addLastBasePathSlash}${mergeSrc}`, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/utils.
|
|
193
|
+
return new URL(`../${addLastBasePathSlash}${mergeSrc}`, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/utils.DQLx7A8M.cjs', document.baseURI).href))).href;
|
|
193
194
|
}
|
|
194
195
|
function formatToFixed(value, options) {
|
|
195
196
|
if (typeof options === "number") {
|
|
@@ -227,9 +228,8 @@ function formatTextToHtml(str) {
|
|
|
227
228
|
if (!str || typeof str !== "string") {
|
|
228
229
|
return str;
|
|
229
230
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
return str;
|
|
231
|
+
const withBreaks = str.replace(/\n/g, "<br>");
|
|
232
|
+
return withBreaks.replace(/\t/g, " ");
|
|
233
233
|
}
|
|
234
234
|
|
|
235
235
|
const DEFAULT_CONFIRM_BUTTON_CLASS = "s-message-box__confirm-btn";
|
|
@@ -243,7 +243,7 @@ function _getBrowserStorage(isSession = false) {
|
|
|
243
243
|
}
|
|
244
244
|
try {
|
|
245
245
|
return isSession ? window.sessionStorage : window.localStorage;
|
|
246
|
-
} catch
|
|
246
|
+
} catch {
|
|
247
247
|
return null;
|
|
248
248
|
}
|
|
249
249
|
}
|
|
@@ -256,7 +256,7 @@ function _parseStorageValue(value) {
|
|
|
256
256
|
if (typeof parsed !== "number") {
|
|
257
257
|
return parsed;
|
|
258
258
|
}
|
|
259
|
-
} catch
|
|
259
|
+
} catch {
|
|
260
260
|
}
|
|
261
261
|
return value;
|
|
262
262
|
}
|
|
@@ -338,8 +338,8 @@ function clearStorage(str = "") {
|
|
|
338
338
|
sessionStorageRef?.clear();
|
|
339
339
|
localStorageRef?.clear();
|
|
340
340
|
}
|
|
341
|
-
if (
|
|
342
|
-
|
|
341
|
+
if (typeof str === "string" || Array.isArray(str)) {
|
|
342
|
+
const strArr = Array.isArray(str) ? str : [str];
|
|
343
343
|
for (let i = 0; i < strArr.length; i++) {
|
|
344
344
|
sessionStorageRef?.removeItem(strArr[i]);
|
|
345
345
|
localStorageRef?.removeItem(strArr[i]);
|
|
@@ -347,16 +347,18 @@ function clearStorage(str = "") {
|
|
|
347
347
|
}
|
|
348
348
|
if (_isObjectWithExclude(str)) {
|
|
349
349
|
if (!isEmpty(str.exclude) && getType(str) === "object") {
|
|
350
|
-
|
|
351
|
-
|
|
350
|
+
const sessionStorageObj = {};
|
|
351
|
+
const localStorageObj = {};
|
|
352
352
|
for (const key in str.exclude) {
|
|
353
353
|
if (Object.prototype.hasOwnProperty.call(str.exclude, key)) {
|
|
354
354
|
const name = str.exclude[key];
|
|
355
|
-
|
|
356
|
-
|
|
355
|
+
const localValue = getStorage(name);
|
|
356
|
+
const sessionValue = getStorage(name, true);
|
|
357
|
+
if (localValue !== null) {
|
|
358
|
+
localStorageObj[name] = localValue;
|
|
357
359
|
}
|
|
358
|
-
if (
|
|
359
|
-
sessionStorageObj[name] =
|
|
360
|
+
if (sessionValue !== null) {
|
|
361
|
+
sessionStorageObj[name] = sessionValue;
|
|
360
362
|
}
|
|
361
363
|
}
|
|
362
364
|
}
|
|
@@ -372,11 +374,11 @@ function clearStorage(str = "") {
|
|
|
372
374
|
}
|
|
373
375
|
}
|
|
374
376
|
function _isObjectWithExclude(obj) {
|
|
375
|
-
return typeof obj === "object" && obj !== null && "exclude" in obj &&
|
|
377
|
+
return typeof obj === "object" && obj !== null && "exclude" in obj && Array.isArray(obj.exclude);
|
|
376
378
|
}
|
|
377
379
|
function validForm(ref, { message = "\u8868\u5355\u6821\u9A8C\u9519\u8BEF, \u8BF7\u68C0\u67E5", detail = false, showMessage = true } = {}) {
|
|
378
380
|
return new Promise((resolve, reject) => {
|
|
379
|
-
|
|
381
|
+
vue.unref(ref).validate((valid, status) => {
|
|
380
382
|
if (valid) {
|
|
381
383
|
resolve(status);
|
|
382
384
|
} else {
|
|
@@ -401,8 +403,8 @@ function isPlainObject(data) {
|
|
|
401
403
|
return proto === Object.prototype || proto === null;
|
|
402
404
|
}
|
|
403
405
|
function isEmpty(data, strict = true) {
|
|
404
|
-
if (
|
|
405
|
-
data =
|
|
406
|
+
if (vue.isRef(data)) {
|
|
407
|
+
data = vue.unref(data);
|
|
406
408
|
}
|
|
407
409
|
if (data == null) return true;
|
|
408
410
|
if (data instanceof Date) {
|
|
@@ -432,7 +434,7 @@ function isEmpty(data, strict = true) {
|
|
|
432
434
|
return false;
|
|
433
435
|
}
|
|
434
436
|
function merge(obj1, obj2) {
|
|
435
|
-
|
|
437
|
+
const merged = { ...obj1, ...obj2 };
|
|
436
438
|
for (let key in merged) {
|
|
437
439
|
if (!isEmpty(obj1[key]) && !isEmpty(obj2[key])) {
|
|
438
440
|
merged[key] = obj2[key];
|
|
@@ -445,13 +447,11 @@ function merge(obj1, obj2) {
|
|
|
445
447
|
return merged;
|
|
446
448
|
}
|
|
447
449
|
function clone(data, times = 1) {
|
|
448
|
-
|
|
449
|
-
|
|
450
|
+
const rawData = vue.isRef(data) ? vue.unref(data) : data;
|
|
451
|
+
if (!Array.isArray(rawData)) {
|
|
452
|
+
return esToolkit.cloneDeep(rawData);
|
|
450
453
|
}
|
|
451
|
-
|
|
452
|
-
return esToolkit.cloneDeep(data);
|
|
453
|
-
}
|
|
454
|
-
const clonedData = esToolkit.cloneDeep(data);
|
|
454
|
+
const clonedData = esToolkit.cloneDeep(rawData);
|
|
455
455
|
const result = [];
|
|
456
456
|
for (let i = 0; i < times; i++) {
|
|
457
457
|
result.push(...clonedData);
|
|
@@ -625,18 +625,18 @@ function validate(type = "required", rules = {}, pureValid = false) {
|
|
|
625
625
|
);
|
|
626
626
|
}
|
|
627
627
|
if (type === "between" /* BETWEEN */) {
|
|
628
|
-
let
|
|
629
|
-
let
|
|
628
|
+
let minValue = rulesObject.min ?? "";
|
|
629
|
+
let maxValue = rulesObject.max ?? "";
|
|
630
630
|
const validateBetween = (rule, value, callback) => {
|
|
631
631
|
let validFlag = /^-?[0-9]+$/.test(value);
|
|
632
632
|
if (!validFlag) {
|
|
633
633
|
callback(new Error("\u8BF7\u8F93\u5165\u6570\u5B57"));
|
|
634
634
|
}
|
|
635
|
-
if (
|
|
636
|
-
callback(new Error(`\u6570\u5B57\u4E0D\u80FD\u5C0F\u4E8E${
|
|
635
|
+
if (!isEmpty(minValue) && value < minValue) {
|
|
636
|
+
callback(new Error(`\u6570\u5B57\u4E0D\u80FD\u5C0F\u4E8E${minValue}`));
|
|
637
637
|
}
|
|
638
|
-
if (value >
|
|
639
|
-
callback(new Error(`\u6570\u5B57\u4E0D\u80FD\u5927\u4E8E${
|
|
638
|
+
if (!isEmpty(maxValue) && value > maxValue && maxValue !== void 0) {
|
|
639
|
+
callback(new Error(`\u6570\u5B57\u4E0D\u80FD\u5927\u4E8E${maxValue}`));
|
|
640
640
|
}
|
|
641
641
|
callback();
|
|
642
642
|
};
|
|
@@ -699,6 +699,7 @@ function validate(type = "required", rules = {}, pureValid = false) {
|
|
|
699
699
|
trigger
|
|
700
700
|
};
|
|
701
701
|
}
|
|
702
|
+
return {};
|
|
702
703
|
}
|
|
703
704
|
const copy = (text, toastParams = {}) => {
|
|
704
705
|
const textarea = document.createElement("textarea");
|
|
@@ -709,14 +710,14 @@ const copy = (text, toastParams = {}) => {
|
|
|
709
710
|
document.execCommand("copy");
|
|
710
711
|
document.body.removeChild(textarea);
|
|
711
712
|
if (!toastParams.hideToast) {
|
|
712
|
-
const { hideToast, ...toastOptions } = toastParams;
|
|
713
|
+
const { hideToast: _hideToast, ...toastOptions } = toastParams;
|
|
713
714
|
$toast(text + "\u590D\u5236\u6210\u529F", toastOptions);
|
|
714
715
|
return true;
|
|
715
716
|
}
|
|
716
717
|
return true;
|
|
717
718
|
};
|
|
718
719
|
function log(variableStr, variable, otherInfo = "") {
|
|
719
|
-
const stack = new Error().stack
|
|
720
|
+
const stack = new Error().stack?.split("\n")[2]?.trim() ?? "";
|
|
720
721
|
const matchResult = stack.match(/\((.*):(\d+):(\d+)\)/);
|
|
721
722
|
let fileInfo = "";
|
|
722
723
|
try {
|
|
@@ -724,12 +725,12 @@ function log(variableStr, variable, otherInfo = "") {
|
|
|
724
725
|
const lineNumber = matchResult[2];
|
|
725
726
|
fileInfo = `vscode://file${JSON.parse(otherInfo)}:${lineNumber}`;
|
|
726
727
|
}
|
|
727
|
-
} catch
|
|
728
|
+
} catch {
|
|
728
729
|
fileInfo = otherInfo;
|
|
729
730
|
}
|
|
730
|
-
if (
|
|
731
|
-
|
|
732
|
-
_log(
|
|
731
|
+
if (vue.isRef(variable)) {
|
|
732
|
+
const unrefVariable = vue.unref(variable);
|
|
733
|
+
_log(vue.toRaw(unrefVariable));
|
|
733
734
|
} else {
|
|
734
735
|
_log(variable);
|
|
735
736
|
}
|
|
@@ -758,7 +759,7 @@ function random(min = 0, max = 10) {
|
|
|
758
759
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
759
760
|
}
|
|
760
761
|
function toLine(text, connect = "-") {
|
|
761
|
-
let translateText = text.replace(/([A-Z])/g, (match,
|
|
762
|
+
let translateText = text.replace(/([A-Z])/g, (match, _letter, offset) => {
|
|
762
763
|
if (offset === 0) {
|
|
763
764
|
return `${match.toLocaleLowerCase()}`;
|
|
764
765
|
} else {
|
|
@@ -769,7 +770,7 @@ function toLine(text, connect = "-") {
|
|
|
769
770
|
}
|
|
770
771
|
const _CSS_UNIT_RE = /^[0-9]+(\.[0-9]+)?(px|%|em|rem|vw|vh|ch)$/;
|
|
771
772
|
function processWidth(initValue, isBase = false) {
|
|
772
|
-
const raw =
|
|
773
|
+
const raw = vue.unref(initValue);
|
|
773
774
|
if (!raw) {
|
|
774
775
|
return isBase ? "" : {};
|
|
775
776
|
}
|
|
@@ -804,10 +805,10 @@ function throttle(fn, delay = 1e3) {
|
|
|
804
805
|
}
|
|
805
806
|
async function tryCatch(task, sendLoading) {
|
|
806
807
|
const updateLoading = (value) => {
|
|
807
|
-
if (
|
|
808
|
+
if (vue.isRef(sendLoading)) {
|
|
808
809
|
sendLoading.value = value;
|
|
809
810
|
} else if (sendLoading !== void 0 && sendLoading !== null) {
|
|
810
|
-
|
|
811
|
+
consola.consola.warn("Cannot modify non-ref sendLoading directly!");
|
|
811
812
|
}
|
|
812
813
|
};
|
|
813
814
|
updateLoading(true);
|
|
@@ -910,7 +911,7 @@ function _resolveAppendTarget(appendTo) {
|
|
|
910
911
|
try {
|
|
911
912
|
const selector = rawSelector.startsWith("#") || rawSelector.startsWith(".") || rawSelector.startsWith("[") ? rawSelector : `#${rawSelector}`;
|
|
912
913
|
return document.querySelector(selector) || appendTo;
|
|
913
|
-
} catch
|
|
914
|
+
} catch {
|
|
914
915
|
return appendTo;
|
|
915
916
|
}
|
|
916
917
|
}
|
|
@@ -929,10 +930,14 @@ function _resolveAppContext(appContext) {
|
|
|
929
930
|
if (appContext) {
|
|
930
931
|
return appContext;
|
|
931
932
|
}
|
|
933
|
+
const installWithContext = elementPlus.ElMessageBox.install;
|
|
934
|
+
const messageBoxWithContext = elementPlus.ElMessageBox;
|
|
935
|
+
const elementPlusContext = installWithContext?.context || messageBoxWithContext._context || null;
|
|
932
936
|
if (typeof document === "undefined") {
|
|
933
|
-
return
|
|
937
|
+
return elementPlusContext;
|
|
934
938
|
}
|
|
935
|
-
|
|
939
|
+
const appRoot = document.querySelector("#app");
|
|
940
|
+
return elementPlusContext || appRoot?._vue_app?._context || null;
|
|
936
941
|
}
|
|
937
942
|
function getVariable(propertyName, fallback = "") {
|
|
938
943
|
if (typeof document === "undefined") {
|
|
@@ -944,7 +949,7 @@ function getVariable(propertyName, fallback = "") {
|
|
|
944
949
|
const DEFAULT_BUILD_TIME_FALLBACK = "\u672A\u6CE8\u5165";
|
|
945
950
|
function getUtilsBuildTime(fallback = DEFAULT_BUILD_TIME_FALLBACK) {
|
|
946
951
|
{
|
|
947
|
-
return "2026-06-
|
|
952
|
+
return "2026-06-29 10:10:51";
|
|
948
953
|
}
|
|
949
954
|
}
|
|
950
955
|
function test() {
|
package/dist/ws.cjs
CHANGED
package/dist/ws.mjs
CHANGED
package/package.json
CHANGED
package/dist/test.cjs
DELETED
package/dist/test.d.cts
DELETED
package/dist/test.d.mts
DELETED
package/dist/test.d.ts
DELETED