@sybz-components/utils 0.0.7 → 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 +3 -5
- package/dist/base.d.mts +3 -5
- package/dist/base.d.ts +3 -5
- 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.DJGyatmd.mjs → utils.1NRU16hJ.mjs} +75 -48
- package/dist/shared/{utils.Ck0CV9dy.cjs → utils.DQLx7A8M.cjs} +83 -56
- 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;
|
|
@@ -112,12 +111,11 @@ interface CopyOptions extends ToastOptions {
|
|
|
112
111
|
}
|
|
113
112
|
type WidthInput = string | number | Ref<string | number>;
|
|
114
113
|
type ConfirmMessage = string | VNode | (() => VNode);
|
|
115
|
-
type ConfirmAppendTarget = string | HTMLElement | null;
|
|
116
114
|
interface ConfirmOptions extends ElMessageBoxOptions {
|
|
117
115
|
/**
|
|
118
|
-
*
|
|
116
|
+
* 确认框主题。
|
|
119
117
|
*/
|
|
120
|
-
|
|
118
|
+
theme?: '' | 'chenghua';
|
|
121
119
|
/**
|
|
122
120
|
* 手动传入 appContext,处理多应用或嵌套弹窗场景。
|
|
123
121
|
*/
|
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;
|
|
@@ -112,12 +111,11 @@ interface CopyOptions extends ToastOptions {
|
|
|
112
111
|
}
|
|
113
112
|
type WidthInput = string | number | Ref<string | number>;
|
|
114
113
|
type ConfirmMessage = string | VNode | (() => VNode);
|
|
115
|
-
type ConfirmAppendTarget = string | HTMLElement | null;
|
|
116
114
|
interface ConfirmOptions extends ElMessageBoxOptions {
|
|
117
115
|
/**
|
|
118
|
-
*
|
|
116
|
+
* 确认框主题。
|
|
119
117
|
*/
|
|
120
|
-
|
|
118
|
+
theme?: '' | 'chenghua';
|
|
121
119
|
/**
|
|
122
120
|
* 手动传入 appContext,处理多应用或嵌套弹窗场景。
|
|
123
121
|
*/
|
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;
|
|
@@ -112,12 +111,11 @@ interface CopyOptions extends ToastOptions {
|
|
|
112
111
|
}
|
|
113
112
|
type WidthInput = string | number | Ref<string | number>;
|
|
114
113
|
type ConfirmMessage = string | VNode | (() => VNode);
|
|
115
|
-
type ConfirmAppendTarget = string | HTMLElement | null;
|
|
116
114
|
interface ConfirmOptions extends ElMessageBoxOptions {
|
|
117
115
|
/**
|
|
118
|
-
*
|
|
116
|
+
* 确认框主题。
|
|
119
117
|
*/
|
|
120
|
-
|
|
118
|
+
theme?: '' | 'chenghua';
|
|
121
119
|
/**
|
|
122
120
|
* 手动传入 appContext,处理多应用或嵌套弹窗场景。
|
|
123
121
|
*/
|
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,20 +225,22 @@ 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";
|
|
233
233
|
const DEFAULT_CANCEL_BUTTON_CLASS = "s-message-box__cancel-btn";
|
|
234
|
+
const CHENGHUA_CONFIRM_BOX_CLASS = "s-message-box--chenghua";
|
|
235
|
+
const CHENGHUA_CONFIRM_BUTTON_CLASS = "s-message-box__confirm-btn--chenghua";
|
|
236
|
+
const CHENGHUA_CANCEL_BUTTON_CLASS = "s-message-box__cancel-btn--chenghua";
|
|
234
237
|
function _getBrowserStorage(isSession = false) {
|
|
235
238
|
if (typeof window === "undefined") {
|
|
236
239
|
return null;
|
|
237
240
|
}
|
|
238
241
|
try {
|
|
239
242
|
return isSession ? window.sessionStorage : window.localStorage;
|
|
240
|
-
} catch
|
|
243
|
+
} catch {
|
|
241
244
|
return null;
|
|
242
245
|
}
|
|
243
246
|
}
|
|
@@ -250,7 +253,7 @@ function _parseStorageValue(value) {
|
|
|
250
253
|
if (typeof parsed !== "number") {
|
|
251
254
|
return parsed;
|
|
252
255
|
}
|
|
253
|
-
} catch
|
|
256
|
+
} catch {
|
|
254
257
|
}
|
|
255
258
|
return value;
|
|
256
259
|
}
|
|
@@ -332,8 +335,8 @@ function clearStorage(str = "") {
|
|
|
332
335
|
sessionStorageRef?.clear();
|
|
333
336
|
localStorageRef?.clear();
|
|
334
337
|
}
|
|
335
|
-
if (
|
|
336
|
-
|
|
338
|
+
if (typeof str === "string" || Array.isArray(str)) {
|
|
339
|
+
const strArr = Array.isArray(str) ? str : [str];
|
|
337
340
|
for (let i = 0; i < strArr.length; i++) {
|
|
338
341
|
sessionStorageRef?.removeItem(strArr[i]);
|
|
339
342
|
localStorageRef?.removeItem(strArr[i]);
|
|
@@ -341,16 +344,18 @@ function clearStorage(str = "") {
|
|
|
341
344
|
}
|
|
342
345
|
if (_isObjectWithExclude(str)) {
|
|
343
346
|
if (!isEmpty(str.exclude) && getType(str) === "object") {
|
|
344
|
-
|
|
345
|
-
|
|
347
|
+
const sessionStorageObj = {};
|
|
348
|
+
const localStorageObj = {};
|
|
346
349
|
for (const key in str.exclude) {
|
|
347
350
|
if (Object.prototype.hasOwnProperty.call(str.exclude, key)) {
|
|
348
351
|
const name = str.exclude[key];
|
|
349
|
-
|
|
350
|
-
|
|
352
|
+
const localValue = getStorage(name);
|
|
353
|
+
const sessionValue = getStorage(name, true);
|
|
354
|
+
if (localValue !== null) {
|
|
355
|
+
localStorageObj[name] = localValue;
|
|
351
356
|
}
|
|
352
|
-
if (
|
|
353
|
-
sessionStorageObj[name] =
|
|
357
|
+
if (sessionValue !== null) {
|
|
358
|
+
sessionStorageObj[name] = sessionValue;
|
|
354
359
|
}
|
|
355
360
|
}
|
|
356
361
|
}
|
|
@@ -366,7 +371,7 @@ function clearStorage(str = "") {
|
|
|
366
371
|
}
|
|
367
372
|
}
|
|
368
373
|
function _isObjectWithExclude(obj) {
|
|
369
|
-
return typeof obj === "object" && obj !== null && "exclude" in obj &&
|
|
374
|
+
return typeof obj === "object" && obj !== null && "exclude" in obj && Array.isArray(obj.exclude);
|
|
370
375
|
}
|
|
371
376
|
function validForm(ref, { message = "\u8868\u5355\u6821\u9A8C\u9519\u8BEF, \u8BF7\u68C0\u67E5", detail = false, showMessage = true } = {}) {
|
|
372
377
|
return new Promise((resolve, reject) => {
|
|
@@ -426,7 +431,7 @@ function isEmpty(data, strict = true) {
|
|
|
426
431
|
return false;
|
|
427
432
|
}
|
|
428
433
|
function merge(obj1, obj2) {
|
|
429
|
-
|
|
434
|
+
const merged = { ...obj1, ...obj2 };
|
|
430
435
|
for (let key in merged) {
|
|
431
436
|
if (!isEmpty(obj1[key]) && !isEmpty(obj2[key])) {
|
|
432
437
|
merged[key] = obj2[key];
|
|
@@ -439,13 +444,11 @@ function merge(obj1, obj2) {
|
|
|
439
444
|
return merged;
|
|
440
445
|
}
|
|
441
446
|
function clone(data, times = 1) {
|
|
442
|
-
|
|
443
|
-
|
|
447
|
+
const rawData = isRef(data) ? unref(data) : data;
|
|
448
|
+
if (!Array.isArray(rawData)) {
|
|
449
|
+
return cloneDeep(rawData);
|
|
444
450
|
}
|
|
445
|
-
|
|
446
|
-
return cloneDeep(data);
|
|
447
|
-
}
|
|
448
|
-
const clonedData = cloneDeep(data);
|
|
451
|
+
const clonedData = cloneDeep(rawData);
|
|
449
452
|
const result = [];
|
|
450
453
|
for (let i = 0; i < times; i++) {
|
|
451
454
|
result.push(...clonedData);
|
|
@@ -619,18 +622,18 @@ function validate(type = "required", rules = {}, pureValid = false) {
|
|
|
619
622
|
);
|
|
620
623
|
}
|
|
621
624
|
if (type === "between" /* BETWEEN */) {
|
|
622
|
-
let
|
|
623
|
-
let
|
|
625
|
+
let minValue = rulesObject.min ?? "";
|
|
626
|
+
let maxValue = rulesObject.max ?? "";
|
|
624
627
|
const validateBetween = (rule, value, callback) => {
|
|
625
628
|
let validFlag = /^-?[0-9]+$/.test(value);
|
|
626
629
|
if (!validFlag) {
|
|
627
630
|
callback(new Error("\u8BF7\u8F93\u5165\u6570\u5B57"));
|
|
628
631
|
}
|
|
629
|
-
if (
|
|
630
|
-
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}`));
|
|
631
634
|
}
|
|
632
|
-
if (value >
|
|
633
|
-
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}`));
|
|
634
637
|
}
|
|
635
638
|
callback();
|
|
636
639
|
};
|
|
@@ -693,6 +696,7 @@ function validate(type = "required", rules = {}, pureValid = false) {
|
|
|
693
696
|
trigger
|
|
694
697
|
};
|
|
695
698
|
}
|
|
699
|
+
return {};
|
|
696
700
|
}
|
|
697
701
|
const copy = (text, toastParams = {}) => {
|
|
698
702
|
const textarea = document.createElement("textarea");
|
|
@@ -703,14 +707,14 @@ const copy = (text, toastParams = {}) => {
|
|
|
703
707
|
document.execCommand("copy");
|
|
704
708
|
document.body.removeChild(textarea);
|
|
705
709
|
if (!toastParams.hideToast) {
|
|
706
|
-
const { hideToast, ...toastOptions } = toastParams;
|
|
710
|
+
const { hideToast: _hideToast, ...toastOptions } = toastParams;
|
|
707
711
|
$toast(text + "\u590D\u5236\u6210\u529F", toastOptions);
|
|
708
712
|
return true;
|
|
709
713
|
}
|
|
710
714
|
return true;
|
|
711
715
|
};
|
|
712
716
|
function log(variableStr, variable, otherInfo = "") {
|
|
713
|
-
const stack = new Error().stack
|
|
717
|
+
const stack = new Error().stack?.split("\n")[2]?.trim() ?? "";
|
|
714
718
|
const matchResult = stack.match(/\((.*):(\d+):(\d+)\)/);
|
|
715
719
|
let fileInfo = "";
|
|
716
720
|
try {
|
|
@@ -718,11 +722,11 @@ function log(variableStr, variable, otherInfo = "") {
|
|
|
718
722
|
const lineNumber = matchResult[2];
|
|
719
723
|
fileInfo = `vscode://file${JSON.parse(otherInfo)}:${lineNumber}`;
|
|
720
724
|
}
|
|
721
|
-
} catch
|
|
725
|
+
} catch {
|
|
722
726
|
fileInfo = otherInfo;
|
|
723
727
|
}
|
|
724
728
|
if (isRef(variable)) {
|
|
725
|
-
|
|
729
|
+
const unrefVariable = unref(variable);
|
|
726
730
|
_log(toRaw(unrefVariable));
|
|
727
731
|
} else {
|
|
728
732
|
_log(variable);
|
|
@@ -752,7 +756,7 @@ function random(min = 0, max = 10) {
|
|
|
752
756
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
753
757
|
}
|
|
754
758
|
function toLine(text, connect = "-") {
|
|
755
|
-
let translateText = text.replace(/([A-Z])/g, (match,
|
|
759
|
+
let translateText = text.replace(/([A-Z])/g, (match, _letter, offset) => {
|
|
756
760
|
if (offset === 0) {
|
|
757
761
|
return `${match.toLocaleLowerCase()}`;
|
|
758
762
|
} else {
|
|
@@ -801,7 +805,7 @@ async function tryCatch(task, sendLoading) {
|
|
|
801
805
|
if (isRef(sendLoading)) {
|
|
802
806
|
sendLoading.value = value;
|
|
803
807
|
} else if (sendLoading !== void 0 && sendLoading !== null) {
|
|
804
|
-
|
|
808
|
+
consola.warn("Cannot modify non-ref sendLoading directly!");
|
|
805
809
|
}
|
|
806
810
|
};
|
|
807
811
|
updateLoading(true);
|
|
@@ -852,9 +856,19 @@ function debounce(func, delay = 500, immediate, resultCallback) {
|
|
|
852
856
|
return _debounce;
|
|
853
857
|
}
|
|
854
858
|
function confirm(message, options = {}, appContext = null) {
|
|
859
|
+
const {
|
|
860
|
+
theme,
|
|
861
|
+
customClass,
|
|
862
|
+
confirmButtonClass,
|
|
863
|
+
cancelButtonClass,
|
|
864
|
+
appendTo,
|
|
865
|
+
appContext: optionAppContext,
|
|
866
|
+
...messageBoxOptions
|
|
867
|
+
} = options;
|
|
855
868
|
const resolvedMessage = typeof message === "function" ? message() : message;
|
|
856
|
-
const resolvedAppendTo = _resolveAppendTarget(
|
|
857
|
-
const resolvedAppContext = _resolveAppContext(
|
|
869
|
+
const resolvedAppendTo = _resolveAppendTarget(appendTo);
|
|
870
|
+
const resolvedAppContext = _resolveAppContext(optionAppContext || appContext);
|
|
871
|
+
const isChenghuaTheme = theme === "chenghua";
|
|
858
872
|
const mergeOptions = {
|
|
859
873
|
title: "\u63D0\u793A",
|
|
860
874
|
draggable: true,
|
|
@@ -862,11 +876,20 @@ function confirm(message, options = {}, appContext = null) {
|
|
|
862
876
|
cancelButtonText: "\u53D6\u6D88",
|
|
863
877
|
confirmButtonText: "\u786E\u5B9A",
|
|
864
878
|
dangerouslyUseHTMLString: true,
|
|
879
|
+
...messageBoxOptions,
|
|
865
880
|
appendTo: resolvedAppendTo,
|
|
866
881
|
appContext: resolvedAppContext,
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
882
|
+
customClass: _mergeClassNames(isChenghuaTheme && CHENGHUA_CONFIRM_BOX_CLASS, customClass),
|
|
883
|
+
confirmButtonClass: _mergeClassNames(
|
|
884
|
+
DEFAULT_CONFIRM_BUTTON_CLASS,
|
|
885
|
+
isChenghuaTheme && CHENGHUA_CONFIRM_BUTTON_CLASS,
|
|
886
|
+
confirmButtonClass
|
|
887
|
+
),
|
|
888
|
+
cancelButtonClass: _mergeClassNames(
|
|
889
|
+
DEFAULT_CANCEL_BUTTON_CLASS,
|
|
890
|
+
isChenghuaTheme && CHENGHUA_CANCEL_BUTTON_CLASS,
|
|
891
|
+
cancelButtonClass
|
|
892
|
+
)
|
|
870
893
|
};
|
|
871
894
|
return ElMessageBox.confirm(resolvedMessage, mergeOptions);
|
|
872
895
|
}
|
|
@@ -885,7 +908,7 @@ function _resolveAppendTarget(appendTo) {
|
|
|
885
908
|
try {
|
|
886
909
|
const selector = rawSelector.startsWith("#") || rawSelector.startsWith(".") || rawSelector.startsWith("[") ? rawSelector : `#${rawSelector}`;
|
|
887
910
|
return document.querySelector(selector) || appendTo;
|
|
888
|
-
} catch
|
|
911
|
+
} catch {
|
|
889
912
|
return appendTo;
|
|
890
913
|
}
|
|
891
914
|
}
|
|
@@ -904,10 +927,14 @@ function _resolveAppContext(appContext) {
|
|
|
904
927
|
if (appContext) {
|
|
905
928
|
return appContext;
|
|
906
929
|
}
|
|
930
|
+
const installWithContext = ElMessageBox.install;
|
|
931
|
+
const messageBoxWithContext = ElMessageBox;
|
|
932
|
+
const elementPlusContext = installWithContext?.context || messageBoxWithContext._context || null;
|
|
907
933
|
if (typeof document === "undefined") {
|
|
908
|
-
return
|
|
934
|
+
return elementPlusContext;
|
|
909
935
|
}
|
|
910
|
-
|
|
936
|
+
const appRoot = document.querySelector("#app");
|
|
937
|
+
return elementPlusContext || appRoot?._vue_app?._context || null;
|
|
911
938
|
}
|
|
912
939
|
function getVariable(propertyName, fallback = "") {
|
|
913
940
|
if (typeof document === "undefined") {
|
|
@@ -919,7 +946,7 @@ function getVariable(propertyName, fallback = "") {
|
|
|
919
946
|
const DEFAULT_BUILD_TIME_FALLBACK = "\u672A\u6CE8\u5165";
|
|
920
947
|
function getUtilsBuildTime(fallback = DEFAULT_BUILD_TIME_FALLBACK) {
|
|
921
948
|
{
|
|
922
|
-
return "2026-06-
|
|
949
|
+
return "2026-06-29 10:10:51";
|
|
923
950
|
}
|
|
924
951
|
}
|
|
925
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,20 +228,22 @@ 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";
|
|
236
236
|
const DEFAULT_CANCEL_BUTTON_CLASS = "s-message-box__cancel-btn";
|
|
237
|
+
const CHENGHUA_CONFIRM_BOX_CLASS = "s-message-box--chenghua";
|
|
238
|
+
const CHENGHUA_CONFIRM_BUTTON_CLASS = "s-message-box__confirm-btn--chenghua";
|
|
239
|
+
const CHENGHUA_CANCEL_BUTTON_CLASS = "s-message-box__cancel-btn--chenghua";
|
|
237
240
|
function _getBrowserStorage(isSession = false) {
|
|
238
241
|
if (typeof window === "undefined") {
|
|
239
242
|
return null;
|
|
240
243
|
}
|
|
241
244
|
try {
|
|
242
245
|
return isSession ? window.sessionStorage : window.localStorage;
|
|
243
|
-
} catch
|
|
246
|
+
} catch {
|
|
244
247
|
return null;
|
|
245
248
|
}
|
|
246
249
|
}
|
|
@@ -253,7 +256,7 @@ function _parseStorageValue(value) {
|
|
|
253
256
|
if (typeof parsed !== "number") {
|
|
254
257
|
return parsed;
|
|
255
258
|
}
|
|
256
|
-
} catch
|
|
259
|
+
} catch {
|
|
257
260
|
}
|
|
258
261
|
return value;
|
|
259
262
|
}
|
|
@@ -335,8 +338,8 @@ function clearStorage(str = "") {
|
|
|
335
338
|
sessionStorageRef?.clear();
|
|
336
339
|
localStorageRef?.clear();
|
|
337
340
|
}
|
|
338
|
-
if (
|
|
339
|
-
|
|
341
|
+
if (typeof str === "string" || Array.isArray(str)) {
|
|
342
|
+
const strArr = Array.isArray(str) ? str : [str];
|
|
340
343
|
for (let i = 0; i < strArr.length; i++) {
|
|
341
344
|
sessionStorageRef?.removeItem(strArr[i]);
|
|
342
345
|
localStorageRef?.removeItem(strArr[i]);
|
|
@@ -344,16 +347,18 @@ function clearStorage(str = "") {
|
|
|
344
347
|
}
|
|
345
348
|
if (_isObjectWithExclude(str)) {
|
|
346
349
|
if (!isEmpty(str.exclude) && getType(str) === "object") {
|
|
347
|
-
|
|
348
|
-
|
|
350
|
+
const sessionStorageObj = {};
|
|
351
|
+
const localStorageObj = {};
|
|
349
352
|
for (const key in str.exclude) {
|
|
350
353
|
if (Object.prototype.hasOwnProperty.call(str.exclude, key)) {
|
|
351
354
|
const name = str.exclude[key];
|
|
352
|
-
|
|
353
|
-
|
|
355
|
+
const localValue = getStorage(name);
|
|
356
|
+
const sessionValue = getStorage(name, true);
|
|
357
|
+
if (localValue !== null) {
|
|
358
|
+
localStorageObj[name] = localValue;
|
|
354
359
|
}
|
|
355
|
-
if (
|
|
356
|
-
sessionStorageObj[name] =
|
|
360
|
+
if (sessionValue !== null) {
|
|
361
|
+
sessionStorageObj[name] = sessionValue;
|
|
357
362
|
}
|
|
358
363
|
}
|
|
359
364
|
}
|
|
@@ -369,11 +374,11 @@ function clearStorage(str = "") {
|
|
|
369
374
|
}
|
|
370
375
|
}
|
|
371
376
|
function _isObjectWithExclude(obj) {
|
|
372
|
-
return typeof obj === "object" && obj !== null && "exclude" in obj &&
|
|
377
|
+
return typeof obj === "object" && obj !== null && "exclude" in obj && Array.isArray(obj.exclude);
|
|
373
378
|
}
|
|
374
379
|
function validForm(ref, { message = "\u8868\u5355\u6821\u9A8C\u9519\u8BEF, \u8BF7\u68C0\u67E5", detail = false, showMessage = true } = {}) {
|
|
375
380
|
return new Promise((resolve, reject) => {
|
|
376
|
-
|
|
381
|
+
vue.unref(ref).validate((valid, status) => {
|
|
377
382
|
if (valid) {
|
|
378
383
|
resolve(status);
|
|
379
384
|
} else {
|
|
@@ -398,8 +403,8 @@ function isPlainObject(data) {
|
|
|
398
403
|
return proto === Object.prototype || proto === null;
|
|
399
404
|
}
|
|
400
405
|
function isEmpty(data, strict = true) {
|
|
401
|
-
if (
|
|
402
|
-
data =
|
|
406
|
+
if (vue.isRef(data)) {
|
|
407
|
+
data = vue.unref(data);
|
|
403
408
|
}
|
|
404
409
|
if (data == null) return true;
|
|
405
410
|
if (data instanceof Date) {
|
|
@@ -429,7 +434,7 @@ function isEmpty(data, strict = true) {
|
|
|
429
434
|
return false;
|
|
430
435
|
}
|
|
431
436
|
function merge(obj1, obj2) {
|
|
432
|
-
|
|
437
|
+
const merged = { ...obj1, ...obj2 };
|
|
433
438
|
for (let key in merged) {
|
|
434
439
|
if (!isEmpty(obj1[key]) && !isEmpty(obj2[key])) {
|
|
435
440
|
merged[key] = obj2[key];
|
|
@@ -442,13 +447,11 @@ function merge(obj1, obj2) {
|
|
|
442
447
|
return merged;
|
|
443
448
|
}
|
|
444
449
|
function clone(data, times = 1) {
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
if (getType(data) !== "array") {
|
|
449
|
-
return esToolkit.cloneDeep(data);
|
|
450
|
+
const rawData = vue.isRef(data) ? vue.unref(data) : data;
|
|
451
|
+
if (!Array.isArray(rawData)) {
|
|
452
|
+
return esToolkit.cloneDeep(rawData);
|
|
450
453
|
}
|
|
451
|
-
const clonedData = esToolkit.cloneDeep(
|
|
454
|
+
const clonedData = esToolkit.cloneDeep(rawData);
|
|
452
455
|
const result = [];
|
|
453
456
|
for (let i = 0; i < times; i++) {
|
|
454
457
|
result.push(...clonedData);
|
|
@@ -622,18 +625,18 @@ function validate(type = "required", rules = {}, pureValid = false) {
|
|
|
622
625
|
);
|
|
623
626
|
}
|
|
624
627
|
if (type === "between" /* BETWEEN */) {
|
|
625
|
-
let
|
|
626
|
-
let
|
|
628
|
+
let minValue = rulesObject.min ?? "";
|
|
629
|
+
let maxValue = rulesObject.max ?? "";
|
|
627
630
|
const validateBetween = (rule, value, callback) => {
|
|
628
631
|
let validFlag = /^-?[0-9]+$/.test(value);
|
|
629
632
|
if (!validFlag) {
|
|
630
633
|
callback(new Error("\u8BF7\u8F93\u5165\u6570\u5B57"));
|
|
631
634
|
}
|
|
632
|
-
if (
|
|
633
|
-
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}`));
|
|
634
637
|
}
|
|
635
|
-
if (value >
|
|
636
|
-
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}`));
|
|
637
640
|
}
|
|
638
641
|
callback();
|
|
639
642
|
};
|
|
@@ -696,6 +699,7 @@ function validate(type = "required", rules = {}, pureValid = false) {
|
|
|
696
699
|
trigger
|
|
697
700
|
};
|
|
698
701
|
}
|
|
702
|
+
return {};
|
|
699
703
|
}
|
|
700
704
|
const copy = (text, toastParams = {}) => {
|
|
701
705
|
const textarea = document.createElement("textarea");
|
|
@@ -706,14 +710,14 @@ const copy = (text, toastParams = {}) => {
|
|
|
706
710
|
document.execCommand("copy");
|
|
707
711
|
document.body.removeChild(textarea);
|
|
708
712
|
if (!toastParams.hideToast) {
|
|
709
|
-
const { hideToast, ...toastOptions } = toastParams;
|
|
713
|
+
const { hideToast: _hideToast, ...toastOptions } = toastParams;
|
|
710
714
|
$toast(text + "\u590D\u5236\u6210\u529F", toastOptions);
|
|
711
715
|
return true;
|
|
712
716
|
}
|
|
713
717
|
return true;
|
|
714
718
|
};
|
|
715
719
|
function log(variableStr, variable, otherInfo = "") {
|
|
716
|
-
const stack = new Error().stack
|
|
720
|
+
const stack = new Error().stack?.split("\n")[2]?.trim() ?? "";
|
|
717
721
|
const matchResult = stack.match(/\((.*):(\d+):(\d+)\)/);
|
|
718
722
|
let fileInfo = "";
|
|
719
723
|
try {
|
|
@@ -721,12 +725,12 @@ function log(variableStr, variable, otherInfo = "") {
|
|
|
721
725
|
const lineNumber = matchResult[2];
|
|
722
726
|
fileInfo = `vscode://file${JSON.parse(otherInfo)}:${lineNumber}`;
|
|
723
727
|
}
|
|
724
|
-
} catch
|
|
728
|
+
} catch {
|
|
725
729
|
fileInfo = otherInfo;
|
|
726
730
|
}
|
|
727
|
-
if (
|
|
728
|
-
|
|
729
|
-
_log(
|
|
731
|
+
if (vue.isRef(variable)) {
|
|
732
|
+
const unrefVariable = vue.unref(variable);
|
|
733
|
+
_log(vue.toRaw(unrefVariable));
|
|
730
734
|
} else {
|
|
731
735
|
_log(variable);
|
|
732
736
|
}
|
|
@@ -755,7 +759,7 @@ function random(min = 0, max = 10) {
|
|
|
755
759
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
756
760
|
}
|
|
757
761
|
function toLine(text, connect = "-") {
|
|
758
|
-
let translateText = text.replace(/([A-Z])/g, (match,
|
|
762
|
+
let translateText = text.replace(/([A-Z])/g, (match, _letter, offset) => {
|
|
759
763
|
if (offset === 0) {
|
|
760
764
|
return `${match.toLocaleLowerCase()}`;
|
|
761
765
|
} else {
|
|
@@ -766,7 +770,7 @@ function toLine(text, connect = "-") {
|
|
|
766
770
|
}
|
|
767
771
|
const _CSS_UNIT_RE = /^[0-9]+(\.[0-9]+)?(px|%|em|rem|vw|vh|ch)$/;
|
|
768
772
|
function processWidth(initValue, isBase = false) {
|
|
769
|
-
const raw =
|
|
773
|
+
const raw = vue.unref(initValue);
|
|
770
774
|
if (!raw) {
|
|
771
775
|
return isBase ? "" : {};
|
|
772
776
|
}
|
|
@@ -801,10 +805,10 @@ function throttle(fn, delay = 1e3) {
|
|
|
801
805
|
}
|
|
802
806
|
async function tryCatch(task, sendLoading) {
|
|
803
807
|
const updateLoading = (value) => {
|
|
804
|
-
if (
|
|
808
|
+
if (vue.isRef(sendLoading)) {
|
|
805
809
|
sendLoading.value = value;
|
|
806
810
|
} else if (sendLoading !== void 0 && sendLoading !== null) {
|
|
807
|
-
|
|
811
|
+
consola.consola.warn("Cannot modify non-ref sendLoading directly!");
|
|
808
812
|
}
|
|
809
813
|
};
|
|
810
814
|
updateLoading(true);
|
|
@@ -855,9 +859,19 @@ function debounce(func, delay = 500, immediate, resultCallback) {
|
|
|
855
859
|
return _debounce;
|
|
856
860
|
}
|
|
857
861
|
function confirm(message, options = {}, appContext = null) {
|
|
862
|
+
const {
|
|
863
|
+
theme,
|
|
864
|
+
customClass,
|
|
865
|
+
confirmButtonClass,
|
|
866
|
+
cancelButtonClass,
|
|
867
|
+
appendTo,
|
|
868
|
+
appContext: optionAppContext,
|
|
869
|
+
...messageBoxOptions
|
|
870
|
+
} = options;
|
|
858
871
|
const resolvedMessage = typeof message === "function" ? message() : message;
|
|
859
|
-
const resolvedAppendTo = _resolveAppendTarget(
|
|
860
|
-
const resolvedAppContext = _resolveAppContext(
|
|
872
|
+
const resolvedAppendTo = _resolveAppendTarget(appendTo);
|
|
873
|
+
const resolvedAppContext = _resolveAppContext(optionAppContext || appContext);
|
|
874
|
+
const isChenghuaTheme = theme === "chenghua";
|
|
861
875
|
const mergeOptions = {
|
|
862
876
|
title: "\u63D0\u793A",
|
|
863
877
|
draggable: true,
|
|
@@ -865,11 +879,20 @@ function confirm(message, options = {}, appContext = null) {
|
|
|
865
879
|
cancelButtonText: "\u53D6\u6D88",
|
|
866
880
|
confirmButtonText: "\u786E\u5B9A",
|
|
867
881
|
dangerouslyUseHTMLString: true,
|
|
882
|
+
...messageBoxOptions,
|
|
868
883
|
appendTo: resolvedAppendTo,
|
|
869
884
|
appContext: resolvedAppContext,
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
885
|
+
customClass: _mergeClassNames(isChenghuaTheme && CHENGHUA_CONFIRM_BOX_CLASS, customClass),
|
|
886
|
+
confirmButtonClass: _mergeClassNames(
|
|
887
|
+
DEFAULT_CONFIRM_BUTTON_CLASS,
|
|
888
|
+
isChenghuaTheme && CHENGHUA_CONFIRM_BUTTON_CLASS,
|
|
889
|
+
confirmButtonClass
|
|
890
|
+
),
|
|
891
|
+
cancelButtonClass: _mergeClassNames(
|
|
892
|
+
DEFAULT_CANCEL_BUTTON_CLASS,
|
|
893
|
+
isChenghuaTheme && CHENGHUA_CANCEL_BUTTON_CLASS,
|
|
894
|
+
cancelButtonClass
|
|
895
|
+
)
|
|
873
896
|
};
|
|
874
897
|
return elementPlus.ElMessageBox.confirm(resolvedMessage, mergeOptions);
|
|
875
898
|
}
|
|
@@ -888,7 +911,7 @@ function _resolveAppendTarget(appendTo) {
|
|
|
888
911
|
try {
|
|
889
912
|
const selector = rawSelector.startsWith("#") || rawSelector.startsWith(".") || rawSelector.startsWith("[") ? rawSelector : `#${rawSelector}`;
|
|
890
913
|
return document.querySelector(selector) || appendTo;
|
|
891
|
-
} catch
|
|
914
|
+
} catch {
|
|
892
915
|
return appendTo;
|
|
893
916
|
}
|
|
894
917
|
}
|
|
@@ -907,10 +930,14 @@ function _resolveAppContext(appContext) {
|
|
|
907
930
|
if (appContext) {
|
|
908
931
|
return appContext;
|
|
909
932
|
}
|
|
933
|
+
const installWithContext = elementPlus.ElMessageBox.install;
|
|
934
|
+
const messageBoxWithContext = elementPlus.ElMessageBox;
|
|
935
|
+
const elementPlusContext = installWithContext?.context || messageBoxWithContext._context || null;
|
|
910
936
|
if (typeof document === "undefined") {
|
|
911
|
-
return
|
|
937
|
+
return elementPlusContext;
|
|
912
938
|
}
|
|
913
|
-
|
|
939
|
+
const appRoot = document.querySelector("#app");
|
|
940
|
+
return elementPlusContext || appRoot?._vue_app?._context || null;
|
|
914
941
|
}
|
|
915
942
|
function getVariable(propertyName, fallback = "") {
|
|
916
943
|
if (typeof document === "undefined") {
|
|
@@ -922,7 +949,7 @@ function getVariable(propertyName, fallback = "") {
|
|
|
922
949
|
const DEFAULT_BUILD_TIME_FALLBACK = "\u672A\u6CE8\u5165";
|
|
923
950
|
function getUtilsBuildTime(fallback = DEFAULT_BUILD_TIME_FALLBACK) {
|
|
924
951
|
{
|
|
925
|
-
return "2026-06-
|
|
952
|
+
return "2026-06-29 10:10:51";
|
|
926
953
|
}
|
|
927
954
|
}
|
|
928
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