@sybz-components/utils 1.0.16 → 1.0.18
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 +1 -1
- package/dist/base.d.cts +4 -2
- package/dist/base.d.mts +4 -2
- package/dist/base.d.ts +4 -2
- package/dist/base.mjs +1 -1
- package/dist/format.cjs +1 -1
- package/dist/format.mjs +1 -1
- package/dist/http.cjs +1 -1
- package/dist/http.d.cts +4 -6
- package/dist/http.d.mts +4 -6
- package/dist/http.d.ts +4 -6
- package/dist/http.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/shared/{utils.BVs9MJTE.mjs → utils.D3fsXXCj.mjs} +33 -25
- package/dist/shared/{utils.KWmfSH7h.cjs → utils.DqukLavi.cjs} +33 -25
- package/package.json +1 -1
package/dist/base.cjs
CHANGED
package/dist/base.d.cts
CHANGED
|
@@ -39,6 +39,8 @@ interface SybzUtilsConfig {
|
|
|
39
39
|
http?: CreateHttpOptions;
|
|
40
40
|
}
|
|
41
41
|
interface ToastOptions extends Partial<MessageOptions> {
|
|
42
|
+
/** 是否启用仅在悬停关闭区域时出现的关闭按钮,默认 `true`。 */
|
|
43
|
+
showClose?: boolean;
|
|
42
44
|
/**
|
|
43
45
|
* 调用前是否先关闭全部消息提示。
|
|
44
46
|
*/
|
|
@@ -57,7 +59,7 @@ interface ClearStorageExcludeOptions {
|
|
|
57
59
|
type ClearStorageInput = string | string[] | ClearStorageExcludeOptions;
|
|
58
60
|
interface ValidateFormOptions {
|
|
59
61
|
/**
|
|
60
|
-
*
|
|
62
|
+
* 校验失败时的自定义提示文案;不传时根据字段错误自动选择。
|
|
61
63
|
*/
|
|
62
64
|
message?: string;
|
|
63
65
|
/**
|
|
@@ -130,7 +132,7 @@ interface CopyOptions extends ToastOptions {
|
|
|
130
132
|
*/
|
|
131
133
|
hideToast?: boolean;
|
|
132
134
|
}
|
|
133
|
-
type WidthInput = string | number | Ref<string | number>;
|
|
135
|
+
type WidthInput = string | number | boolean | Ref<string | number | boolean>;
|
|
134
136
|
type ConfirmMessage = string | VNode | (() => VNode);
|
|
135
137
|
type ConfirmTheme = UtilsTheme;
|
|
136
138
|
interface ConfirmCustomOptions {
|
package/dist/base.d.mts
CHANGED
|
@@ -39,6 +39,8 @@ interface SybzUtilsConfig {
|
|
|
39
39
|
http?: CreateHttpOptions;
|
|
40
40
|
}
|
|
41
41
|
interface ToastOptions extends Partial<MessageOptions> {
|
|
42
|
+
/** 是否启用仅在悬停关闭区域时出现的关闭按钮,默认 `true`。 */
|
|
43
|
+
showClose?: boolean;
|
|
42
44
|
/**
|
|
43
45
|
* 调用前是否先关闭全部消息提示。
|
|
44
46
|
*/
|
|
@@ -57,7 +59,7 @@ interface ClearStorageExcludeOptions {
|
|
|
57
59
|
type ClearStorageInput = string | string[] | ClearStorageExcludeOptions;
|
|
58
60
|
interface ValidateFormOptions {
|
|
59
61
|
/**
|
|
60
|
-
*
|
|
62
|
+
* 校验失败时的自定义提示文案;不传时根据字段错误自动选择。
|
|
61
63
|
*/
|
|
62
64
|
message?: string;
|
|
63
65
|
/**
|
|
@@ -130,7 +132,7 @@ interface CopyOptions extends ToastOptions {
|
|
|
130
132
|
*/
|
|
131
133
|
hideToast?: boolean;
|
|
132
134
|
}
|
|
133
|
-
type WidthInput = string | number | Ref<string | number>;
|
|
135
|
+
type WidthInput = string | number | boolean | Ref<string | number | boolean>;
|
|
134
136
|
type ConfirmMessage = string | VNode | (() => VNode);
|
|
135
137
|
type ConfirmTheme = UtilsTheme;
|
|
136
138
|
interface ConfirmCustomOptions {
|
package/dist/base.d.ts
CHANGED
|
@@ -39,6 +39,8 @@ interface SybzUtilsConfig {
|
|
|
39
39
|
http?: CreateHttpOptions;
|
|
40
40
|
}
|
|
41
41
|
interface ToastOptions extends Partial<MessageOptions> {
|
|
42
|
+
/** 是否启用仅在悬停关闭区域时出现的关闭按钮,默认 `true`。 */
|
|
43
|
+
showClose?: boolean;
|
|
42
44
|
/**
|
|
43
45
|
* 调用前是否先关闭全部消息提示。
|
|
44
46
|
*/
|
|
@@ -57,7 +59,7 @@ interface ClearStorageExcludeOptions {
|
|
|
57
59
|
type ClearStorageInput = string | string[] | ClearStorageExcludeOptions;
|
|
58
60
|
interface ValidateFormOptions {
|
|
59
61
|
/**
|
|
60
|
-
*
|
|
62
|
+
* 校验失败时的自定义提示文案;不传时根据字段错误自动选择。
|
|
61
63
|
*/
|
|
62
64
|
message?: string;
|
|
63
65
|
/**
|
|
@@ -130,7 +132,7 @@ interface CopyOptions extends ToastOptions {
|
|
|
130
132
|
*/
|
|
131
133
|
hideToast?: boolean;
|
|
132
134
|
}
|
|
133
|
-
type WidthInput = string | number | Ref<string | number>;
|
|
135
|
+
type WidthInput = string | number | boolean | Ref<string | number | boolean>;
|
|
134
136
|
type ConfirmMessage = string | VNode | (() => VNode);
|
|
135
137
|
type ConfirmTheme = UtilsTheme;
|
|
136
138
|
interface ConfirmCustomOptions {
|
package/dist/base.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'vue';
|
|
2
2
|
import 'consola';
|
|
3
3
|
import 'es-toolkit';
|
|
4
|
-
export { $ as $toast, c as clearStorage, a as clone, b as configureUtils, d as confirm, e as copy, f as debounce, g as delay, h as getStorage, i as getType, j as getUtilsBuildTime, k as getVariable, l as isEmpty, m as log, n as merge, o as mockValue, p as processWidth, r as random, s as setStorage, t as test, q as throttle, u as toLine, v as tryCatch, w as validate, x as validateForm, y as validateOnSubmit } from './shared/utils.
|
|
4
|
+
export { $ as $toast, c as clearStorage, a as clone, b as configureUtils, d as confirm, e as copy, f as debounce, g as delay, h as getStorage, i as getType, j as getUtilsBuildTime, k as getVariable, l as isEmpty, m as log, n as merge, o as mockValue, p as processWidth, r as random, s as setStorage, t as test, q as throttle, u as toLine, v as tryCatch, w as validate, x as validateForm, y as validateOnSubmit } from './shared/utils.D3fsXXCj.mjs';
|
|
5
5
|
import './confirmSemantic.mjs';
|
|
6
6
|
import 'element-plus';
|
|
7
7
|
import 'axios';
|
package/dist/format.cjs
CHANGED
package/dist/format.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { z as formatBytes, A as formatBytesConvert, B as formatDurationTime, C as formatTextToHtml, D as formatThousands, E as formatTime, F as formatToFixed } from './shared/utils.
|
|
1
|
+
export { z as formatBytes, A as formatBytesConvert, B as formatDurationTime, C as formatTextToHtml, D as formatThousands, E as formatTime, F as formatToFixed } from './shared/utils.D3fsXXCj.mjs';
|
|
2
2
|
import './is.mjs';
|
|
3
3
|
import 'consola';
|
|
4
4
|
import 'vue';
|
package/dist/http.cjs
CHANGED
package/dist/http.d.cts
CHANGED
|
@@ -42,7 +42,6 @@ interface CreateHttpOptions<D = unknown> extends CreateAxiosDefaults<D> {
|
|
|
42
42
|
}
|
|
43
43
|
type HttpClient = Omit<AxiosInstance, 'get' | 'post' | 'put' | 'patch' | 'delete'> & {
|
|
44
44
|
<T = unknown, D = unknown>(url: string, config?: HttpRequestConfig<D>): Promise<T>;
|
|
45
|
-
<T = unknown, D = unknown>(url: string, params?: unknown, config?: HttpRequestConfig<D>): Promise<T>;
|
|
46
45
|
send<T = unknown, D = unknown>(config: HttpRequestConfig<D> & {
|
|
47
46
|
rawResponse: true;
|
|
48
47
|
}): Promise<AxiosResponse<T>>;
|
|
@@ -50,12 +49,11 @@ type HttpClient = Omit<AxiosInstance, 'get' | 'post' | 'put' | 'patch' | 'delete
|
|
|
50
49
|
rawResponse?: false;
|
|
51
50
|
}): Promise<T>;
|
|
52
51
|
get<T = unknown>(url: string, config?: HttpRequestConfig): Promise<T>;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
patch<T = unknown, D = unknown>(url: string, data?: D, config?: HttpRequestConfig<D>): Promise<T>;
|
|
52
|
+
post<T = unknown, D = unknown>(url: string, config?: HttpRequestConfig<D>): Promise<T>;
|
|
53
|
+
put<T = unknown, D = unknown>(url: string, config?: HttpRequestConfig<D>): Promise<T>;
|
|
54
|
+
patch<T = unknown, D = unknown>(url: string, config?: HttpRequestConfig<D>): Promise<T>;
|
|
57
55
|
delete<T = unknown>(url: string, config?: HttpRequestConfig): Promise<T>;
|
|
58
|
-
download(url: string,
|
|
56
|
+
download(url: string, config?: HttpRequestConfig): Promise<Blob>;
|
|
59
57
|
};
|
|
60
58
|
declare function createHttp<D = unknown>(options?: CreateHttpOptions<D>): HttpClient;
|
|
61
59
|
/** 全局 HTTP 客户端;通过 configureUtils({ http: ... }) 配置一次。 */
|
package/dist/http.d.mts
CHANGED
|
@@ -42,7 +42,6 @@ interface CreateHttpOptions<D = unknown> extends CreateAxiosDefaults<D> {
|
|
|
42
42
|
}
|
|
43
43
|
type HttpClient = Omit<AxiosInstance, 'get' | 'post' | 'put' | 'patch' | 'delete'> & {
|
|
44
44
|
<T = unknown, D = unknown>(url: string, config?: HttpRequestConfig<D>): Promise<T>;
|
|
45
|
-
<T = unknown, D = unknown>(url: string, params?: unknown, config?: HttpRequestConfig<D>): Promise<T>;
|
|
46
45
|
send<T = unknown, D = unknown>(config: HttpRequestConfig<D> & {
|
|
47
46
|
rawResponse: true;
|
|
48
47
|
}): Promise<AxiosResponse<T>>;
|
|
@@ -50,12 +49,11 @@ type HttpClient = Omit<AxiosInstance, 'get' | 'post' | 'put' | 'patch' | 'delete
|
|
|
50
49
|
rawResponse?: false;
|
|
51
50
|
}): Promise<T>;
|
|
52
51
|
get<T = unknown>(url: string, config?: HttpRequestConfig): Promise<T>;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
patch<T = unknown, D = unknown>(url: string, data?: D, config?: HttpRequestConfig<D>): Promise<T>;
|
|
52
|
+
post<T = unknown, D = unknown>(url: string, config?: HttpRequestConfig<D>): Promise<T>;
|
|
53
|
+
put<T = unknown, D = unknown>(url: string, config?: HttpRequestConfig<D>): Promise<T>;
|
|
54
|
+
patch<T = unknown, D = unknown>(url: string, config?: HttpRequestConfig<D>): Promise<T>;
|
|
57
55
|
delete<T = unknown>(url: string, config?: HttpRequestConfig): Promise<T>;
|
|
58
|
-
download(url: string,
|
|
56
|
+
download(url: string, config?: HttpRequestConfig): Promise<Blob>;
|
|
59
57
|
};
|
|
60
58
|
declare function createHttp<D = unknown>(options?: CreateHttpOptions<D>): HttpClient;
|
|
61
59
|
/** 全局 HTTP 客户端;通过 configureUtils({ http: ... }) 配置一次。 */
|
package/dist/http.d.ts
CHANGED
|
@@ -42,7 +42,6 @@ interface CreateHttpOptions<D = unknown> extends CreateAxiosDefaults<D> {
|
|
|
42
42
|
}
|
|
43
43
|
type HttpClient = Omit<AxiosInstance, 'get' | 'post' | 'put' | 'patch' | 'delete'> & {
|
|
44
44
|
<T = unknown, D = unknown>(url: string, config?: HttpRequestConfig<D>): Promise<T>;
|
|
45
|
-
<T = unknown, D = unknown>(url: string, params?: unknown, config?: HttpRequestConfig<D>): Promise<T>;
|
|
46
45
|
send<T = unknown, D = unknown>(config: HttpRequestConfig<D> & {
|
|
47
46
|
rawResponse: true;
|
|
48
47
|
}): Promise<AxiosResponse<T>>;
|
|
@@ -50,12 +49,11 @@ type HttpClient = Omit<AxiosInstance, 'get' | 'post' | 'put' | 'patch' | 'delete
|
|
|
50
49
|
rawResponse?: false;
|
|
51
50
|
}): Promise<T>;
|
|
52
51
|
get<T = unknown>(url: string, config?: HttpRequestConfig): Promise<T>;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
patch<T = unknown, D = unknown>(url: string, data?: D, config?: HttpRequestConfig<D>): Promise<T>;
|
|
52
|
+
post<T = unknown, D = unknown>(url: string, config?: HttpRequestConfig<D>): Promise<T>;
|
|
53
|
+
put<T = unknown, D = unknown>(url: string, config?: HttpRequestConfig<D>): Promise<T>;
|
|
54
|
+
patch<T = unknown, D = unknown>(url: string, config?: HttpRequestConfig<D>): Promise<T>;
|
|
57
55
|
delete<T = unknown>(url: string, config?: HttpRequestConfig): Promise<T>;
|
|
58
|
-
download(url: string,
|
|
56
|
+
download(url: string, config?: HttpRequestConfig): Promise<Blob>;
|
|
59
57
|
};
|
|
60
58
|
declare function createHttp<D = unknown>(options?: CreateHttpOptions<D>): HttpClient;
|
|
61
59
|
/** 全局 HTTP 客户端;通过 configureUtils({ http: ... }) 配置一次。 */
|
package/dist/http.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'axios';
|
|
2
|
-
export { H as HttpError, G as configureHttp, I as createHttp, J as http } from './shared/utils.
|
|
2
|
+
export { H as HttpError, G as configureHttp, I as createHttp, J as http } from './shared/utils.D3fsXXCj.mjs';
|
|
3
3
|
import 'vue';
|
|
4
4
|
import 'consola';
|
|
5
5
|
import 'es-toolkit';
|
package/dist/index.cjs
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { $ as $toast, H as HttpError, c as clearStorage, a as clone, G as configureHttp, b as configureUtils, d as confirm, e as copy, I as createHttp, f as debounce, g as delay, z as formatBytes, A as formatBytesConvert, B as formatDurationTime, C as formatTextToHtml, D as formatThousands, E as formatTime, F as formatToFixed, h as getStorage, i as getType, j as getUtilsBuildTime, k as getVariable, J as http, l as isEmpty, m as log, n as merge, o as mockValue, p as processWidth, r as random, s as setStorage, t as test, q as throttle, u as toLine, v as tryCatch, w as validate, x as validateForm, y as validateOnSubmit } from './shared/utils.
|
|
1
|
+
export { $ as $toast, H as HttpError, c as clearStorage, a as clone, G as configureHttp, b as configureUtils, d as confirm, e as copy, I as createHttp, f as debounce, g as delay, z as formatBytes, A as formatBytesConvert, B as formatDurationTime, C as formatTextToHtml, D as formatThousands, E as formatTime, F as formatToFixed, h as getStorage, i as getType, j as getUtilsBuildTime, k as getVariable, J as http, l as isEmpty, m as log, n as merge, o as mockValue, p as processWidth, r as random, s as setStorage, t as test, q as throttle, u as toLine, v as tryCatch, w as validate, x as validateForm, y as validateOnSubmit } from './shared/utils.D3fsXXCj.mjs';
|
|
2
2
|
export { resolveConfirmSemantic } from './confirmSemantic.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 { SYBZ_THEME_PREFIX, isSybzTheme, resolveSybzComponentTheme } from './theme.mjs';
|
|
@@ -306,22 +306,15 @@ function createHttp(options = {}) {
|
|
|
306
306
|
const response = await instance.request(config);
|
|
307
307
|
return config.rawResponse ? response : response.data;
|
|
308
308
|
};
|
|
309
|
-
const
|
|
310
|
-
(key) => key in value
|
|
311
|
-
);
|
|
312
|
-
const request = (url, paramsOrConfig, config = {}) => {
|
|
313
|
-
const params = isRequestConfig(paramsOrConfig) ? void 0 : paramsOrConfig;
|
|
314
|
-
const requestConfig = isRequestConfig(paramsOrConfig) ? paramsOrConfig : config;
|
|
315
|
-
return send({ ...requestConfig, method: "GET", url, params, rawResponse: false });
|
|
316
|
-
};
|
|
309
|
+
const request = (url, config = {}) => send({ ...config, method: "GET", url, rawResponse: false });
|
|
317
310
|
const client = Object.assign(request, instance, {
|
|
318
311
|
send,
|
|
319
|
-
get: (url,
|
|
320
|
-
post: (url,
|
|
321
|
-
put: (url,
|
|
322
|
-
patch: (url,
|
|
312
|
+
get: (url, config) => request(url, config),
|
|
313
|
+
post: (url, config) => send({ ...config, method: "POST", url, rawResponse: false }),
|
|
314
|
+
put: (url, config) => send({ ...config, method: "PUT", url, rawResponse: false }),
|
|
315
|
+
patch: (url, config) => send({ ...config, method: "PATCH", url, rawResponse: false }),
|
|
323
316
|
delete: (url, config) => send({ ...config, method: "DELETE", url, rawResponse: false }),
|
|
324
|
-
download: (url,
|
|
317
|
+
download: (url, config) => send({ ...config, method: "GET", url, responseType: "blob", rawResponse: false })
|
|
325
318
|
});
|
|
326
319
|
return client;
|
|
327
320
|
}
|
|
@@ -397,9 +390,15 @@ function $toast(message, type = "success", otherParams = {}) {
|
|
|
397
390
|
if (options.closeAll) {
|
|
398
391
|
ElMessage.closeAll();
|
|
399
392
|
}
|
|
400
|
-
const resolvedCustomClass =
|
|
393
|
+
const resolvedCustomClass = _mergeClassNames(
|
|
394
|
+
"s-toast",
|
|
395
|
+
customClass !== "el" && "s-antd-message",
|
|
396
|
+
customClass !== "el" && theme !== "default" && `s-antd-message--${theme}`,
|
|
397
|
+
customClass !== "el" && customClass
|
|
398
|
+
);
|
|
401
399
|
ElMessage({
|
|
402
400
|
...messageOptions,
|
|
401
|
+
showClose: options.showClose ?? true,
|
|
403
402
|
customClass: resolvedCustomClass
|
|
404
403
|
});
|
|
405
404
|
}
|
|
@@ -494,19 +493,28 @@ function clearStorage(str = "") {
|
|
|
494
493
|
function _isObjectWithExclude(obj) {
|
|
495
494
|
return typeof obj === "object" && obj !== null && "exclude" in obj && Array.isArray(obj.exclude);
|
|
496
495
|
}
|
|
497
|
-
function validateForm(ref, { message
|
|
496
|
+
function validateForm(ref, { message, detail = false, showMessage = true } = {}) {
|
|
498
497
|
return new Promise((resolve, reject) => {
|
|
499
498
|
unref(ref).validate((valid, status) => {
|
|
500
499
|
if (valid) {
|
|
501
500
|
resolve(status);
|
|
502
501
|
} else {
|
|
503
|
-
if (
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
}
|
|
509
|
-
|
|
502
|
+
if (showMessage) {
|
|
503
|
+
const fieldNames = Object.keys(status ?? {});
|
|
504
|
+
const errors = fieldNames.flatMap((field) => {
|
|
505
|
+
const fieldErrors = status[field];
|
|
506
|
+
return Array.isArray(fieldErrors) ? fieldErrors : [fieldErrors];
|
|
507
|
+
});
|
|
508
|
+
const errorMessages = errors.map((error) => error?.message).filter((errorMessage) => typeof errorMessage === "string" && !!errorMessage.trim());
|
|
509
|
+
const nonRequiredMessage = errors.find((error) => {
|
|
510
|
+
const errorMessage = error?.message;
|
|
511
|
+
if (typeof errorMessage !== "string" || !errorMessage.trim()) return false;
|
|
512
|
+
if ("fieldValue" in Object(error) && !isEmpty(error.fieldValue)) return true;
|
|
513
|
+
return !/^(请输入|请选择|请填写|请上传|请勾选|不能为空)/.test(errorMessage) || /^请输入(?:正确|非负|正|整数|数字|\d|至少|最多|不超过)/.test(errorMessage);
|
|
514
|
+
})?.message;
|
|
515
|
+
const defaultMessage = nonRequiredMessage ?? (errorMessages.length ? "\u5B58\u5728\u5FC5\u586B\u9879\u672A\u586B\u5199\uFF0C\u8BF7\u8865\u5145\u5B8C\u6574" : "\u8868\u5355\u6821\u9A8C\u672A\u901A\u8FC7\uFF0C\u8BF7\u68C0\u67E5\u8F93\u5165");
|
|
516
|
+
const toastMessage = message === void 0 ? defaultMessage : message;
|
|
517
|
+
if (toastMessage) $toast(detail ? toastMessage + fieldNames.join(",") : toastMessage, "e");
|
|
510
518
|
}
|
|
511
519
|
reject(status);
|
|
512
520
|
}
|
|
@@ -922,10 +930,10 @@ const _CSS_UNIT_RE = /^[0-9]+(\.[0-9]+)?(px|%|em|rem|vw|vh|ch)$/;
|
|
|
922
930
|
const _CSS_LENGTH_FUNCTION_RE = /^(?:calc|min|max|clamp|var)\(.+\)$/;
|
|
923
931
|
function processWidth(initValue, isBase = false) {
|
|
924
932
|
const raw = unref(initValue);
|
|
925
|
-
if (raw === void 0 || raw === null || raw === "") {
|
|
933
|
+
if (raw === void 0 || raw === null || raw === "" || raw === false) {
|
|
926
934
|
return isBase ? "" : {};
|
|
927
935
|
}
|
|
928
|
-
const str = typeof raw === "number" ? `${raw}` : raw;
|
|
936
|
+
const str = raw === true ? "100%" : typeof raw === "number" ? `${raw}` : raw;
|
|
929
937
|
let res;
|
|
930
938
|
if (!isNaN(Number(str))) {
|
|
931
939
|
res = str + "px";
|
|
@@ -1196,7 +1204,7 @@ function getVariable(propertyName, fallback = "") {
|
|
|
1196
1204
|
const DEFAULT_BUILD_TIME_FALLBACK = "\u672A\u6CE8\u5165";
|
|
1197
1205
|
function getUtilsBuildTime(fallback = DEFAULT_BUILD_TIME_FALLBACK) {
|
|
1198
1206
|
{
|
|
1199
|
-
return "2026-
|
|
1207
|
+
return "2026-11-12 14:28:53";
|
|
1200
1208
|
}
|
|
1201
1209
|
}
|
|
1202
1210
|
function test() {
|
|
@@ -312,22 +312,15 @@ function createHttp(options = {}) {
|
|
|
312
312
|
const response = await instance.request(config);
|
|
313
313
|
return config.rawResponse ? response : response.data;
|
|
314
314
|
};
|
|
315
|
-
const
|
|
316
|
-
(key) => key in value
|
|
317
|
-
);
|
|
318
|
-
const request = (url, paramsOrConfig, config = {}) => {
|
|
319
|
-
const params = isRequestConfig(paramsOrConfig) ? void 0 : paramsOrConfig;
|
|
320
|
-
const requestConfig = isRequestConfig(paramsOrConfig) ? paramsOrConfig : config;
|
|
321
|
-
return send({ ...requestConfig, method: "GET", url, params, rawResponse: false });
|
|
322
|
-
};
|
|
315
|
+
const request = (url, config = {}) => send({ ...config, method: "GET", url, rawResponse: false });
|
|
323
316
|
const client = Object.assign(request, instance, {
|
|
324
317
|
send,
|
|
325
|
-
get: (url,
|
|
326
|
-
post: (url,
|
|
327
|
-
put: (url,
|
|
328
|
-
patch: (url,
|
|
318
|
+
get: (url, config) => request(url, config),
|
|
319
|
+
post: (url, config) => send({ ...config, method: "POST", url, rawResponse: false }),
|
|
320
|
+
put: (url, config) => send({ ...config, method: "PUT", url, rawResponse: false }),
|
|
321
|
+
patch: (url, config) => send({ ...config, method: "PATCH", url, rawResponse: false }),
|
|
329
322
|
delete: (url, config) => send({ ...config, method: "DELETE", url, rawResponse: false }),
|
|
330
|
-
download: (url,
|
|
323
|
+
download: (url, config) => send({ ...config, method: "GET", url, responseType: "blob", rawResponse: false })
|
|
331
324
|
});
|
|
332
325
|
return client;
|
|
333
326
|
}
|
|
@@ -403,9 +396,15 @@ function $toast(message, type = "success", otherParams = {}) {
|
|
|
403
396
|
if (options.closeAll) {
|
|
404
397
|
elementPlus.ElMessage.closeAll();
|
|
405
398
|
}
|
|
406
|
-
const resolvedCustomClass =
|
|
399
|
+
const resolvedCustomClass = _mergeClassNames(
|
|
400
|
+
"s-toast",
|
|
401
|
+
customClass !== "el" && "s-antd-message",
|
|
402
|
+
customClass !== "el" && theme !== "default" && `s-antd-message--${theme}`,
|
|
403
|
+
customClass !== "el" && customClass
|
|
404
|
+
);
|
|
407
405
|
elementPlus.ElMessage({
|
|
408
406
|
...messageOptions,
|
|
407
|
+
showClose: options.showClose ?? true,
|
|
409
408
|
customClass: resolvedCustomClass
|
|
410
409
|
});
|
|
411
410
|
}
|
|
@@ -500,19 +499,28 @@ function clearStorage(str = "") {
|
|
|
500
499
|
function _isObjectWithExclude(obj) {
|
|
501
500
|
return typeof obj === "object" && obj !== null && "exclude" in obj && Array.isArray(obj.exclude);
|
|
502
501
|
}
|
|
503
|
-
function validateForm(ref, { message
|
|
502
|
+
function validateForm(ref, { message, detail = false, showMessage = true } = {}) {
|
|
504
503
|
return new Promise((resolve, reject) => {
|
|
505
504
|
vue.unref(ref).validate((valid, status) => {
|
|
506
505
|
if (valid) {
|
|
507
506
|
resolve(status);
|
|
508
507
|
} else {
|
|
509
|
-
if (
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
}
|
|
515
|
-
|
|
508
|
+
if (showMessage) {
|
|
509
|
+
const fieldNames = Object.keys(status ?? {});
|
|
510
|
+
const errors = fieldNames.flatMap((field) => {
|
|
511
|
+
const fieldErrors = status[field];
|
|
512
|
+
return Array.isArray(fieldErrors) ? fieldErrors : [fieldErrors];
|
|
513
|
+
});
|
|
514
|
+
const errorMessages = errors.map((error) => error?.message).filter((errorMessage) => typeof errorMessage === "string" && !!errorMessage.trim());
|
|
515
|
+
const nonRequiredMessage = errors.find((error) => {
|
|
516
|
+
const errorMessage = error?.message;
|
|
517
|
+
if (typeof errorMessage !== "string" || !errorMessage.trim()) return false;
|
|
518
|
+
if ("fieldValue" in Object(error) && !isEmpty(error.fieldValue)) return true;
|
|
519
|
+
return !/^(请输入|请选择|请填写|请上传|请勾选|不能为空)/.test(errorMessage) || /^请输入(?:正确|非负|正|整数|数字|\d|至少|最多|不超过)/.test(errorMessage);
|
|
520
|
+
})?.message;
|
|
521
|
+
const defaultMessage = nonRequiredMessage ?? (errorMessages.length ? "\u5B58\u5728\u5FC5\u586B\u9879\u672A\u586B\u5199\uFF0C\u8BF7\u8865\u5145\u5B8C\u6574" : "\u8868\u5355\u6821\u9A8C\u672A\u901A\u8FC7\uFF0C\u8BF7\u68C0\u67E5\u8F93\u5165");
|
|
522
|
+
const toastMessage = message === void 0 ? defaultMessage : message;
|
|
523
|
+
if (toastMessage) $toast(detail ? toastMessage + fieldNames.join(",") : toastMessage, "e");
|
|
516
524
|
}
|
|
517
525
|
reject(status);
|
|
518
526
|
}
|
|
@@ -928,10 +936,10 @@ const _CSS_UNIT_RE = /^[0-9]+(\.[0-9]+)?(px|%|em|rem|vw|vh|ch)$/;
|
|
|
928
936
|
const _CSS_LENGTH_FUNCTION_RE = /^(?:calc|min|max|clamp|var)\(.+\)$/;
|
|
929
937
|
function processWidth(initValue, isBase = false) {
|
|
930
938
|
const raw = vue.unref(initValue);
|
|
931
|
-
if (raw === void 0 || raw === null || raw === "") {
|
|
939
|
+
if (raw === void 0 || raw === null || raw === "" || raw === false) {
|
|
932
940
|
return isBase ? "" : {};
|
|
933
941
|
}
|
|
934
|
-
const str = typeof raw === "number" ? `${raw}` : raw;
|
|
942
|
+
const str = raw === true ? "100%" : typeof raw === "number" ? `${raw}` : raw;
|
|
935
943
|
let res;
|
|
936
944
|
if (!isNaN(Number(str))) {
|
|
937
945
|
res = str + "px";
|
|
@@ -1202,7 +1210,7 @@ function getVariable(propertyName, fallback = "") {
|
|
|
1202
1210
|
const DEFAULT_BUILD_TIME_FALLBACK = "\u672A\u6CE8\u5165";
|
|
1203
1211
|
function getUtilsBuildTime(fallback = DEFAULT_BUILD_TIME_FALLBACK) {
|
|
1204
1212
|
{
|
|
1205
|
-
return "2026-
|
|
1213
|
+
return "2026-11-12 14:28:53";
|
|
1206
1214
|
}
|
|
1207
1215
|
}
|
|
1208
1216
|
function test() {
|