@sybz-components/utils 0.0.9 → 0.0.10
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 +4 -4
- package/dist/base.d.cts +16 -16
- package/dist/base.d.mts +16 -16
- package/dist/base.d.ts +16 -16
- package/dist/base.mjs +1 -1
- package/dist/format.cjs +1 -1
- package/dist/format.mjs +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/shared/{utils.DQLx7A8M.cjs → utils.BaNHAtTs.cjs} +16 -16
- package/dist/shared/{utils.1NRU16hJ.mjs → utils.CzQQZf9j.mjs} +13 -13
- package/package.json +1 -1
package/dist/base.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
require('vue');
|
|
4
4
|
require('consola');
|
|
5
5
|
require('es-toolkit');
|
|
6
|
-
const format = require('./shared/utils.
|
|
6
|
+
const format = require('./shared/utils.BaNHAtTs.cjs');
|
|
7
7
|
require('element-plus');
|
|
8
8
|
require('./is.cjs');
|
|
9
9
|
|
|
@@ -15,6 +15,7 @@ exports.clone = format.clone;
|
|
|
15
15
|
exports.confirm = format.confirm;
|
|
16
16
|
exports.copy = format.copy;
|
|
17
17
|
exports.debounce = format.debounce;
|
|
18
|
+
exports.delay = format.delay;
|
|
18
19
|
exports.getStorage = format.getStorage;
|
|
19
20
|
exports.getType = format.getType;
|
|
20
21
|
exports.getUtilsBuildTime = format.getUtilsBuildTime;
|
|
@@ -22,15 +23,14 @@ exports.getVariable = format.getVariable;
|
|
|
22
23
|
exports.isEmpty = format.isEmpty;
|
|
23
24
|
exports.log = format.log;
|
|
24
25
|
exports.merge = format.merge;
|
|
26
|
+
exports.mockValue = format.mockValue;
|
|
25
27
|
exports.processWidth = format.processWidth;
|
|
26
28
|
exports.random = format.random;
|
|
27
29
|
exports.setStorage = format.setStorage;
|
|
28
|
-
exports.sleep = format.sleep;
|
|
29
30
|
exports.test = format.test;
|
|
30
31
|
exports.throttle = format.throttle;
|
|
31
32
|
exports.toLine = format.toLine;
|
|
32
33
|
exports.tryCatch = format.tryCatch;
|
|
33
|
-
exports.uuid = format.uuid;
|
|
34
|
-
exports.validForm = format.validForm;
|
|
35
34
|
exports.validate = format.validate;
|
|
35
|
+
exports.validateForm = format.validateForm;
|
|
36
36
|
exports.validateTrigger = format.validateTrigger;
|
package/dist/base.d.cts
CHANGED
|
@@ -21,7 +21,7 @@ type ValidateRuleResult = {
|
|
|
21
21
|
max?: number;
|
|
22
22
|
};
|
|
23
23
|
type ValidatePrimitiveValue = string | number | boolean | null | undefined;
|
|
24
|
-
type
|
|
24
|
+
type MockValueOptionItem<T = any> = {
|
|
25
25
|
label: string;
|
|
26
26
|
value: T;
|
|
27
27
|
};
|
|
@@ -38,7 +38,7 @@ interface ClearStorageExcludeOptions {
|
|
|
38
38
|
exclude: string[];
|
|
39
39
|
}
|
|
40
40
|
type ClearStorageInput = string | string[] | ClearStorageExcludeOptions;
|
|
41
|
-
interface
|
|
41
|
+
interface ValidateFormOptions {
|
|
42
42
|
/**
|
|
43
43
|
* 校验失败时的提示文案。
|
|
44
44
|
*/
|
|
@@ -55,7 +55,7 @@ interface ValidFormOptions {
|
|
|
55
55
|
interface FormValidateTarget {
|
|
56
56
|
validate: (callback: (valid: boolean, status: StorageMap) => void) => void;
|
|
57
57
|
}
|
|
58
|
-
interface
|
|
58
|
+
interface MockValueOptions {
|
|
59
59
|
/**
|
|
60
60
|
* `email` 模式下的邮箱后缀,默认 `@qq.com`。
|
|
61
61
|
*/
|
|
@@ -238,12 +238,12 @@ declare function clearStorage(str?: ClearStorageInput): void;
|
|
|
238
238
|
* @returns 校验通过时返回表单状态对象,失败时 reject 对应状态对象。
|
|
239
239
|
*
|
|
240
240
|
* @example
|
|
241
|
-
* await
|
|
241
|
+
* await validateForm(formRef)
|
|
242
242
|
*
|
|
243
243
|
* @example
|
|
244
|
-
* await
|
|
244
|
+
* await validateForm(formRef, { message: '请检查表单信息', detail: true })
|
|
245
245
|
*/
|
|
246
|
-
declare function
|
|
246
|
+
declare function validateForm(ref: MaybeRef<FormValidateTarget>, { message, detail, showMessage }?: ValidateFormOptions): Promise<StorageMap>;
|
|
247
247
|
/**
|
|
248
248
|
* 判断值是否为空。
|
|
249
249
|
*
|
|
@@ -308,17 +308,17 @@ declare function clone<T>(data: T, times?: number): T;
|
|
|
308
308
|
* @returns 生成结果。
|
|
309
309
|
*
|
|
310
310
|
* @example
|
|
311
|
-
*
|
|
311
|
+
* mockValue()
|
|
312
312
|
* // => 'aB3d'
|
|
313
313
|
*
|
|
314
314
|
* @example
|
|
315
|
-
*
|
|
315
|
+
* mockValue('phone')
|
|
316
316
|
* // => '13603312460'
|
|
317
317
|
*
|
|
318
318
|
* @example
|
|
319
|
-
*
|
|
319
|
+
* mockValue('time', 0, { startStr: 'andy', timeStr: '{h}:{i}:{s}' })
|
|
320
320
|
*/
|
|
321
|
-
declare function
|
|
321
|
+
declare function mockValue(type?: string | Array<MockValueOptionItem>, length?: number, options?: MockValueOptions): string | number | any;
|
|
322
322
|
/**
|
|
323
323
|
* 获取值的原始类型名称,返回值统一为小写字符串。
|
|
324
324
|
*
|
|
@@ -336,7 +336,7 @@ declare function uuid(type?: string | Array<UuidOptionItem>, length?: number, op
|
|
|
336
336
|
declare function getType(type: unknown): string;
|
|
337
337
|
/**
|
|
338
338
|
* 一个辅助函数,用于在代码中创建一个暂停(延迟)。
|
|
339
|
-
* 它返回一个 Promise,你可以在 `await` 后使用它来实现类似 "
|
|
339
|
+
* 它返回一个 Promise,你可以在 `await` 后使用它来实现类似 "delay" 的效果。
|
|
340
340
|
*
|
|
341
341
|
* @param delay - 等待的毫秒数。默认值为 0,表示不延迟。
|
|
342
342
|
* @param fn - (可选) 一个在延迟结束后立即执行的函数。
|
|
@@ -346,12 +346,12 @@ declare function getType(type: unknown): string;
|
|
|
346
346
|
* @example
|
|
347
347
|
* // 基本用法:延迟 2 秒后打印消息
|
|
348
348
|
* console.log('开始');
|
|
349
|
-
* await
|
|
349
|
+
* await delay(2000);
|
|
350
350
|
* console.log('2秒后执行');
|
|
351
351
|
*
|
|
352
352
|
* @example
|
|
353
353
|
* // 带回调函数的用法:延迟 1 秒后执行清理工作
|
|
354
|
-
*
|
|
354
|
+
* delay(1000, () => {
|
|
355
355
|
* console.log('执行清理操作...');
|
|
356
356
|
* // 清理代码...
|
|
357
357
|
* });
|
|
@@ -360,10 +360,10 @@ declare function getType(type: unknown): string;
|
|
|
360
360
|
* // 在循环中使用:每次迭代后延迟 500 毫秒
|
|
361
361
|
* for (let i = 0; i < 5; i++) {
|
|
362
362
|
* console.log(`当前值: ${i}`);
|
|
363
|
-
* await
|
|
363
|
+
* await delay(500);
|
|
364
364
|
* }
|
|
365
365
|
*/
|
|
366
|
-
declare function
|
|
366
|
+
declare function delay(delay?: number, fn?: () => void): Promise<void>;
|
|
367
367
|
/**
|
|
368
368
|
* 为 `validate` 预置默认触发时机 `['blur', 'change']`。
|
|
369
369
|
*
|
|
@@ -559,4 +559,4 @@ declare function getUtilsBuildTime(fallback?: string): string;
|
|
|
559
559
|
*/
|
|
560
560
|
declare function test(): string;
|
|
561
561
|
|
|
562
|
-
export { $toast, clearStorage, clone, confirm, copy, debounce, getStorage, getType, getUtilsBuildTime, getVariable, isEmpty, log, merge, processWidth, random, setStorage,
|
|
562
|
+
export { $toast, clearStorage, clone, confirm, copy, debounce, delay, getStorage, getType, getUtilsBuildTime, getVariable, isEmpty, log, merge, mockValue, processWidth, random, setStorage, test, throttle, toLine, tryCatch, validate, validateForm, validateTrigger };
|
package/dist/base.d.mts
CHANGED
|
@@ -21,7 +21,7 @@ type ValidateRuleResult = {
|
|
|
21
21
|
max?: number;
|
|
22
22
|
};
|
|
23
23
|
type ValidatePrimitiveValue = string | number | boolean | null | undefined;
|
|
24
|
-
type
|
|
24
|
+
type MockValueOptionItem<T = any> = {
|
|
25
25
|
label: string;
|
|
26
26
|
value: T;
|
|
27
27
|
};
|
|
@@ -38,7 +38,7 @@ interface ClearStorageExcludeOptions {
|
|
|
38
38
|
exclude: string[];
|
|
39
39
|
}
|
|
40
40
|
type ClearStorageInput = string | string[] | ClearStorageExcludeOptions;
|
|
41
|
-
interface
|
|
41
|
+
interface ValidateFormOptions {
|
|
42
42
|
/**
|
|
43
43
|
* 校验失败时的提示文案。
|
|
44
44
|
*/
|
|
@@ -55,7 +55,7 @@ interface ValidFormOptions {
|
|
|
55
55
|
interface FormValidateTarget {
|
|
56
56
|
validate: (callback: (valid: boolean, status: StorageMap) => void) => void;
|
|
57
57
|
}
|
|
58
|
-
interface
|
|
58
|
+
interface MockValueOptions {
|
|
59
59
|
/**
|
|
60
60
|
* `email` 模式下的邮箱后缀,默认 `@qq.com`。
|
|
61
61
|
*/
|
|
@@ -238,12 +238,12 @@ declare function clearStorage(str?: ClearStorageInput): void;
|
|
|
238
238
|
* @returns 校验通过时返回表单状态对象,失败时 reject 对应状态对象。
|
|
239
239
|
*
|
|
240
240
|
* @example
|
|
241
|
-
* await
|
|
241
|
+
* await validateForm(formRef)
|
|
242
242
|
*
|
|
243
243
|
* @example
|
|
244
|
-
* await
|
|
244
|
+
* await validateForm(formRef, { message: '请检查表单信息', detail: true })
|
|
245
245
|
*/
|
|
246
|
-
declare function
|
|
246
|
+
declare function validateForm(ref: MaybeRef<FormValidateTarget>, { message, detail, showMessage }?: ValidateFormOptions): Promise<StorageMap>;
|
|
247
247
|
/**
|
|
248
248
|
* 判断值是否为空。
|
|
249
249
|
*
|
|
@@ -308,17 +308,17 @@ declare function clone<T>(data: T, times?: number): T;
|
|
|
308
308
|
* @returns 生成结果。
|
|
309
309
|
*
|
|
310
310
|
* @example
|
|
311
|
-
*
|
|
311
|
+
* mockValue()
|
|
312
312
|
* // => 'aB3d'
|
|
313
313
|
*
|
|
314
314
|
* @example
|
|
315
|
-
*
|
|
315
|
+
* mockValue('phone')
|
|
316
316
|
* // => '13603312460'
|
|
317
317
|
*
|
|
318
318
|
* @example
|
|
319
|
-
*
|
|
319
|
+
* mockValue('time', 0, { startStr: 'andy', timeStr: '{h}:{i}:{s}' })
|
|
320
320
|
*/
|
|
321
|
-
declare function
|
|
321
|
+
declare function mockValue(type?: string | Array<MockValueOptionItem>, length?: number, options?: MockValueOptions): string | number | any;
|
|
322
322
|
/**
|
|
323
323
|
* 获取值的原始类型名称,返回值统一为小写字符串。
|
|
324
324
|
*
|
|
@@ -336,7 +336,7 @@ declare function uuid(type?: string | Array<UuidOptionItem>, length?: number, op
|
|
|
336
336
|
declare function getType(type: unknown): string;
|
|
337
337
|
/**
|
|
338
338
|
* 一个辅助函数,用于在代码中创建一个暂停(延迟)。
|
|
339
|
-
* 它返回一个 Promise,你可以在 `await` 后使用它来实现类似 "
|
|
339
|
+
* 它返回一个 Promise,你可以在 `await` 后使用它来实现类似 "delay" 的效果。
|
|
340
340
|
*
|
|
341
341
|
* @param delay - 等待的毫秒数。默认值为 0,表示不延迟。
|
|
342
342
|
* @param fn - (可选) 一个在延迟结束后立即执行的函数。
|
|
@@ -346,12 +346,12 @@ declare function getType(type: unknown): string;
|
|
|
346
346
|
* @example
|
|
347
347
|
* // 基本用法:延迟 2 秒后打印消息
|
|
348
348
|
* console.log('开始');
|
|
349
|
-
* await
|
|
349
|
+
* await delay(2000);
|
|
350
350
|
* console.log('2秒后执行');
|
|
351
351
|
*
|
|
352
352
|
* @example
|
|
353
353
|
* // 带回调函数的用法:延迟 1 秒后执行清理工作
|
|
354
|
-
*
|
|
354
|
+
* delay(1000, () => {
|
|
355
355
|
* console.log('执行清理操作...');
|
|
356
356
|
* // 清理代码...
|
|
357
357
|
* });
|
|
@@ -360,10 +360,10 @@ declare function getType(type: unknown): string;
|
|
|
360
360
|
* // 在循环中使用:每次迭代后延迟 500 毫秒
|
|
361
361
|
* for (let i = 0; i < 5; i++) {
|
|
362
362
|
* console.log(`当前值: ${i}`);
|
|
363
|
-
* await
|
|
363
|
+
* await delay(500);
|
|
364
364
|
* }
|
|
365
365
|
*/
|
|
366
|
-
declare function
|
|
366
|
+
declare function delay(delay?: number, fn?: () => void): Promise<void>;
|
|
367
367
|
/**
|
|
368
368
|
* 为 `validate` 预置默认触发时机 `['blur', 'change']`。
|
|
369
369
|
*
|
|
@@ -559,4 +559,4 @@ declare function getUtilsBuildTime(fallback?: string): string;
|
|
|
559
559
|
*/
|
|
560
560
|
declare function test(): string;
|
|
561
561
|
|
|
562
|
-
export { $toast, clearStorage, clone, confirm, copy, debounce, getStorage, getType, getUtilsBuildTime, getVariable, isEmpty, log, merge, processWidth, random, setStorage,
|
|
562
|
+
export { $toast, clearStorage, clone, confirm, copy, debounce, delay, getStorage, getType, getUtilsBuildTime, getVariable, isEmpty, log, merge, mockValue, processWidth, random, setStorage, test, throttle, toLine, tryCatch, validate, validateForm, validateTrigger };
|
package/dist/base.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ type ValidateRuleResult = {
|
|
|
21
21
|
max?: number;
|
|
22
22
|
};
|
|
23
23
|
type ValidatePrimitiveValue = string | number | boolean | null | undefined;
|
|
24
|
-
type
|
|
24
|
+
type MockValueOptionItem<T = any> = {
|
|
25
25
|
label: string;
|
|
26
26
|
value: T;
|
|
27
27
|
};
|
|
@@ -38,7 +38,7 @@ interface ClearStorageExcludeOptions {
|
|
|
38
38
|
exclude: string[];
|
|
39
39
|
}
|
|
40
40
|
type ClearStorageInput = string | string[] | ClearStorageExcludeOptions;
|
|
41
|
-
interface
|
|
41
|
+
interface ValidateFormOptions {
|
|
42
42
|
/**
|
|
43
43
|
* 校验失败时的提示文案。
|
|
44
44
|
*/
|
|
@@ -55,7 +55,7 @@ interface ValidFormOptions {
|
|
|
55
55
|
interface FormValidateTarget {
|
|
56
56
|
validate: (callback: (valid: boolean, status: StorageMap) => void) => void;
|
|
57
57
|
}
|
|
58
|
-
interface
|
|
58
|
+
interface MockValueOptions {
|
|
59
59
|
/**
|
|
60
60
|
* `email` 模式下的邮箱后缀,默认 `@qq.com`。
|
|
61
61
|
*/
|
|
@@ -238,12 +238,12 @@ declare function clearStorage(str?: ClearStorageInput): void;
|
|
|
238
238
|
* @returns 校验通过时返回表单状态对象,失败时 reject 对应状态对象。
|
|
239
239
|
*
|
|
240
240
|
* @example
|
|
241
|
-
* await
|
|
241
|
+
* await validateForm(formRef)
|
|
242
242
|
*
|
|
243
243
|
* @example
|
|
244
|
-
* await
|
|
244
|
+
* await validateForm(formRef, { message: '请检查表单信息', detail: true })
|
|
245
245
|
*/
|
|
246
|
-
declare function
|
|
246
|
+
declare function validateForm(ref: MaybeRef<FormValidateTarget>, { message, detail, showMessage }?: ValidateFormOptions): Promise<StorageMap>;
|
|
247
247
|
/**
|
|
248
248
|
* 判断值是否为空。
|
|
249
249
|
*
|
|
@@ -308,17 +308,17 @@ declare function clone<T>(data: T, times?: number): T;
|
|
|
308
308
|
* @returns 生成结果。
|
|
309
309
|
*
|
|
310
310
|
* @example
|
|
311
|
-
*
|
|
311
|
+
* mockValue()
|
|
312
312
|
* // => 'aB3d'
|
|
313
313
|
*
|
|
314
314
|
* @example
|
|
315
|
-
*
|
|
315
|
+
* mockValue('phone')
|
|
316
316
|
* // => '13603312460'
|
|
317
317
|
*
|
|
318
318
|
* @example
|
|
319
|
-
*
|
|
319
|
+
* mockValue('time', 0, { startStr: 'andy', timeStr: '{h}:{i}:{s}' })
|
|
320
320
|
*/
|
|
321
|
-
declare function
|
|
321
|
+
declare function mockValue(type?: string | Array<MockValueOptionItem>, length?: number, options?: MockValueOptions): string | number | any;
|
|
322
322
|
/**
|
|
323
323
|
* 获取值的原始类型名称,返回值统一为小写字符串。
|
|
324
324
|
*
|
|
@@ -336,7 +336,7 @@ declare function uuid(type?: string | Array<UuidOptionItem>, length?: number, op
|
|
|
336
336
|
declare function getType(type: unknown): string;
|
|
337
337
|
/**
|
|
338
338
|
* 一个辅助函数,用于在代码中创建一个暂停(延迟)。
|
|
339
|
-
* 它返回一个 Promise,你可以在 `await` 后使用它来实现类似 "
|
|
339
|
+
* 它返回一个 Promise,你可以在 `await` 后使用它来实现类似 "delay" 的效果。
|
|
340
340
|
*
|
|
341
341
|
* @param delay - 等待的毫秒数。默认值为 0,表示不延迟。
|
|
342
342
|
* @param fn - (可选) 一个在延迟结束后立即执行的函数。
|
|
@@ -346,12 +346,12 @@ declare function getType(type: unknown): string;
|
|
|
346
346
|
* @example
|
|
347
347
|
* // 基本用法:延迟 2 秒后打印消息
|
|
348
348
|
* console.log('开始');
|
|
349
|
-
* await
|
|
349
|
+
* await delay(2000);
|
|
350
350
|
* console.log('2秒后执行');
|
|
351
351
|
*
|
|
352
352
|
* @example
|
|
353
353
|
* // 带回调函数的用法:延迟 1 秒后执行清理工作
|
|
354
|
-
*
|
|
354
|
+
* delay(1000, () => {
|
|
355
355
|
* console.log('执行清理操作...');
|
|
356
356
|
* // 清理代码...
|
|
357
357
|
* });
|
|
@@ -360,10 +360,10 @@ declare function getType(type: unknown): string;
|
|
|
360
360
|
* // 在循环中使用:每次迭代后延迟 500 毫秒
|
|
361
361
|
* for (let i = 0; i < 5; i++) {
|
|
362
362
|
* console.log(`当前值: ${i}`);
|
|
363
|
-
* await
|
|
363
|
+
* await delay(500);
|
|
364
364
|
* }
|
|
365
365
|
*/
|
|
366
|
-
declare function
|
|
366
|
+
declare function delay(delay?: number, fn?: () => void): Promise<void>;
|
|
367
367
|
/**
|
|
368
368
|
* 为 `validate` 预置默认触发时机 `['blur', 'change']`。
|
|
369
369
|
*
|
|
@@ -559,4 +559,4 @@ declare function getUtilsBuildTime(fallback?: string): string;
|
|
|
559
559
|
*/
|
|
560
560
|
declare function test(): string;
|
|
561
561
|
|
|
562
|
-
export { $toast, clearStorage, clone, confirm, copy, debounce, getStorage, getType, getUtilsBuildTime, getVariable, isEmpty, log, merge, processWidth, random, setStorage,
|
|
562
|
+
export { $toast, clearStorage, clone, confirm, copy, debounce, delay, getStorage, getType, getUtilsBuildTime, getVariable, isEmpty, log, merge, mockValue, processWidth, random, setStorage, test, throttle, toLine, tryCatch, validate, validateForm, validateTrigger };
|
package/dist/base.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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 confirm, d as copy, e as debounce, g as getStorage,
|
|
4
|
+
export { $ as $toast, c as clearStorage, a as clone, b as confirm, d as copy, e as debounce, f as delay, g as getStorage, h as getType, i as getUtilsBuildTime, j as getVariable, k as isEmpty, l as log, m as merge, n as mockValue, p as processWidth, r as random, s as setStorage, t as test, o as throttle, q as toLine, u as tryCatch, v as validate, w as validateForm, x as validateTrigger } from './shared/utils.CzQQZf9j.mjs';
|
|
5
5
|
import 'element-plus';
|
|
6
6
|
import './is.mjs';
|
package/dist/format.cjs
CHANGED
package/dist/format.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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.CzQQZf9j.mjs';
|
|
2
2
|
import './is.mjs';
|
|
3
3
|
import 'consola';
|
|
4
4
|
import 'vue';
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const format = require('./shared/utils.
|
|
3
|
+
const format = require('./shared/utils.BaNHAtTs.cjs');
|
|
4
4
|
const day = require('./day.cjs');
|
|
5
5
|
const is = require('./is.cjs');
|
|
6
6
|
const ws = require('./ws.cjs');
|
|
@@ -19,6 +19,7 @@ exports.clone = format.clone;
|
|
|
19
19
|
exports.confirm = format.confirm;
|
|
20
20
|
exports.copy = format.copy;
|
|
21
21
|
exports.debounce = format.debounce;
|
|
22
|
+
exports.delay = format.delay;
|
|
22
23
|
exports.formatBytes = format.formatBytes;
|
|
23
24
|
exports.formatBytesConvert = format.formatBytesConvert;
|
|
24
25
|
exports.formatDurationTime = format.formatDurationTime;
|
|
@@ -34,17 +35,16 @@ exports.getVariable = format.getVariable;
|
|
|
34
35
|
exports.isEmpty = format.isEmpty;
|
|
35
36
|
exports.log = format.log;
|
|
36
37
|
exports.merge = format.merge;
|
|
38
|
+
exports.mockValue = format.mockValue;
|
|
37
39
|
exports.processWidth = format.processWidth;
|
|
38
40
|
exports.random = format.random;
|
|
39
41
|
exports.setStorage = format.setStorage;
|
|
40
|
-
exports.sleep = format.sleep;
|
|
41
42
|
exports.test = format.test;
|
|
42
43
|
exports.throttle = format.throttle;
|
|
43
44
|
exports.toLine = format.toLine;
|
|
44
45
|
exports.tryCatch = format.tryCatch;
|
|
45
|
-
exports.uuid = format.uuid;
|
|
46
|
-
exports.validForm = format.validForm;
|
|
47
46
|
exports.validate = format.validate;
|
|
47
|
+
exports.validateForm = format.validateForm;
|
|
48
48
|
exports.validateTrigger = format.validateTrigger;
|
|
49
49
|
exports.diffDate = day.diffDate;
|
|
50
50
|
exports.diffDateFromCurrent = day.diffDateFromCurrent;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { $toast, clearStorage, clone, confirm, copy, debounce, getStorage, getType, getUtilsBuildTime, getVariable, isEmpty, log, merge, processWidth, random, setStorage,
|
|
1
|
+
export { $toast, clearStorage, clone, confirm, copy, debounce, delay, getStorage, getType, getUtilsBuildTime, getVariable, isEmpty, log, merge, mockValue, processWidth, random, setStorage, test, throttle, toLine, tryCatch, validate, validateForm, validateTrigger } from './base.cjs';
|
|
2
2
|
export { diffDate, diffDateFromCurrent, formatDate, formatDateToDay, formatDateToMinute } from './day.cjs';
|
|
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';
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { $toast, clearStorage, clone, confirm, copy, debounce, getStorage, getType, getUtilsBuildTime, getVariable, isEmpty, log, merge, processWidth, random, setStorage,
|
|
1
|
+
export { $toast, clearStorage, clone, confirm, copy, debounce, delay, getStorage, getType, getUtilsBuildTime, getVariable, isEmpty, log, merge, mockValue, processWidth, random, setStorage, test, throttle, toLine, tryCatch, validate, validateForm, validateTrigger } from './base.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, WSAutoReconnectOptions, WSHeartbeatOptions, WSOptions } from './ws.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { $toast, clearStorage, clone, confirm, copy, debounce, getStorage, getType, getUtilsBuildTime, getVariable, isEmpty, log, merge, processWidth, random, setStorage,
|
|
1
|
+
export { $toast, clearStorage, clone, confirm, copy, debounce, delay, getStorage, getType, getUtilsBuildTime, getVariable, isEmpty, log, merge, mockValue, processWidth, random, setStorage, test, throttle, toLine, tryCatch, validate, validateForm, validateTrigger } from './base.js';
|
|
2
2
|
export { diffDate, diffDateFromCurrent, formatDate, formatDateToDay, formatDateToMinute } from './day.js';
|
|
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';
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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,
|
|
1
|
+
export { $ as $toast, c as clearStorage, a as clone, b as confirm, d as copy, e as debounce, f as delay, 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, h as getType, i as getUtilsBuildTime, j as getVariable, k as isEmpty, l as log, m as merge, n as mockValue, p as processWidth, r as random, s as setStorage, t as test, o as throttle, q as toLine, u as tryCatch, v as validate, w as validateForm, x as validateTrigger } from './shared/utils.CzQQZf9j.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';
|
|
@@ -190,7 +190,7 @@ function formatImg(photoName, addPath = "", { basePath = "assets/images" } = {})
|
|
|
190
190
|
const addLastSlash = addPath.endsWith("/") || !addPath ? addPath : `${addPath}/`;
|
|
191
191
|
const addLastBasePathSlash = basePath.endsWith("/") || !basePath ? basePath : `${basePath}/`;
|
|
192
192
|
const mergeSrc = `${addLastSlash}${photoName}`;
|
|
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.
|
|
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.BaNHAtTs.cjs', document.baseURI).href))).href;
|
|
194
194
|
}
|
|
195
195
|
function formatToFixed(value, options) {
|
|
196
196
|
if (typeof options === "number") {
|
|
@@ -376,7 +376,7 @@ function clearStorage(str = "") {
|
|
|
376
376
|
function _isObjectWithExclude(obj) {
|
|
377
377
|
return typeof obj === "object" && obj !== null && "exclude" in obj && Array.isArray(obj.exclude);
|
|
378
378
|
}
|
|
379
|
-
function
|
|
379
|
+
function validateForm(ref, { message = "\u8868\u5355\u6821\u9A8C\u9519\u8BEF, \u8BF7\u68C0\u67E5", detail = false, showMessage = true } = {}) {
|
|
380
380
|
return new Promise((resolve, reject) => {
|
|
381
381
|
vue.unref(ref).validate((valid, status) => {
|
|
382
382
|
if (valid) {
|
|
@@ -458,7 +458,7 @@ function clone(data, times = 1) {
|
|
|
458
458
|
}
|
|
459
459
|
return result;
|
|
460
460
|
}
|
|
461
|
-
function
|
|
461
|
+
function mockValue(type = "", length = 4, options = {}) {
|
|
462
462
|
const { emailStr = "@qq.com", timeStr = "{y}-{m}-{d} {h}:{i}:{s}", startStr = "", optionsIndex = null } = options;
|
|
463
463
|
function isRef2(obj) {
|
|
464
464
|
return obj && typeof obj === "object" && obj._isRef === true;
|
|
@@ -490,11 +490,11 @@ function uuid(type = "", length = 4, options = {}) {
|
|
|
490
490
|
return result;
|
|
491
491
|
}
|
|
492
492
|
if (type === "email") {
|
|
493
|
-
result =
|
|
493
|
+
result = mockValue(startStr, length) + emailStr;
|
|
494
494
|
return result;
|
|
495
495
|
}
|
|
496
496
|
if (type === "time") {
|
|
497
|
-
return
|
|
497
|
+
return mockValue(startStr, length, options) + " " + formatTime(/* @__PURE__ */ new Date(), timeStr);
|
|
498
498
|
}
|
|
499
499
|
if (type === "number") {
|
|
500
500
|
const numChars = "123456789";
|
|
@@ -524,12 +524,12 @@ function getType(type) {
|
|
|
524
524
|
return typeof type;
|
|
525
525
|
}
|
|
526
526
|
}
|
|
527
|
-
function
|
|
527
|
+
function delay(delay2 = 0, fn) {
|
|
528
528
|
return new Promise(
|
|
529
529
|
(resolve) => setTimeout(() => {
|
|
530
530
|
fn?.();
|
|
531
531
|
resolve();
|
|
532
|
-
},
|
|
532
|
+
}, delay2)
|
|
533
533
|
);
|
|
534
534
|
}
|
|
535
535
|
function validateTrigger(type = "required", rules = {}, pureValid = false) {
|
|
@@ -785,18 +785,18 @@ function processWidth(initValue, isBase = false) {
|
|
|
785
785
|
}
|
|
786
786
|
return isBase ? res : { width: res };
|
|
787
787
|
}
|
|
788
|
-
function throttle(fn,
|
|
788
|
+
function throttle(fn, delay2 = 1e3) {
|
|
789
789
|
let last = 0;
|
|
790
790
|
let timer = void 0;
|
|
791
791
|
return function(...args) {
|
|
792
792
|
let context = this;
|
|
793
793
|
let now = +/* @__PURE__ */ new Date();
|
|
794
|
-
if (now - last <
|
|
794
|
+
if (now - last < delay2) {
|
|
795
795
|
clearTimeout(timer);
|
|
796
796
|
timer = setTimeout(function() {
|
|
797
797
|
last = now;
|
|
798
798
|
fn.apply(context, args);
|
|
799
|
-
},
|
|
799
|
+
}, delay2);
|
|
800
800
|
} else {
|
|
801
801
|
last = now;
|
|
802
802
|
fn.apply(context, args);
|
|
@@ -821,7 +821,7 @@ async function tryCatch(task, sendLoading) {
|
|
|
821
821
|
updateLoading(false);
|
|
822
822
|
}
|
|
823
823
|
}
|
|
824
|
-
function debounce(func,
|
|
824
|
+
function debounce(func, delay2 = 500, immediate, resultCallback) {
|
|
825
825
|
let timer = null;
|
|
826
826
|
let isInvoke = false;
|
|
827
827
|
const _debounce = function(...args) {
|
|
@@ -847,7 +847,7 @@ function debounce(func, delay = 500, immediate, resultCallback) {
|
|
|
847
847
|
}
|
|
848
848
|
isInvoke = false;
|
|
849
849
|
timer = null;
|
|
850
|
-
},
|
|
850
|
+
}, delay2);
|
|
851
851
|
}
|
|
852
852
|
});
|
|
853
853
|
};
|
|
@@ -949,7 +949,7 @@ function getVariable(propertyName, fallback = "") {
|
|
|
949
949
|
const DEFAULT_BUILD_TIME_FALLBACK = "\u672A\u6CE8\u5165";
|
|
950
950
|
function getUtilsBuildTime(fallback = DEFAULT_BUILD_TIME_FALLBACK) {
|
|
951
951
|
{
|
|
952
|
-
return "2026-
|
|
952
|
+
return "2026-07-01 13:13:26";
|
|
953
953
|
}
|
|
954
954
|
}
|
|
955
955
|
function test() {
|
|
@@ -962,6 +962,7 @@ exports.clone = clone;
|
|
|
962
962
|
exports.confirm = confirm;
|
|
963
963
|
exports.copy = copy;
|
|
964
964
|
exports.debounce = debounce;
|
|
965
|
+
exports.delay = delay;
|
|
965
966
|
exports.formatBytes = formatBytes;
|
|
966
967
|
exports.formatBytesConvert = formatBytesConvert;
|
|
967
968
|
exports.formatDurationTime = formatDurationTime;
|
|
@@ -977,15 +978,14 @@ exports.getVariable = getVariable;
|
|
|
977
978
|
exports.isEmpty = isEmpty;
|
|
978
979
|
exports.log = log;
|
|
979
980
|
exports.merge = merge;
|
|
981
|
+
exports.mockValue = mockValue;
|
|
980
982
|
exports.processWidth = processWidth;
|
|
981
983
|
exports.random = random;
|
|
982
984
|
exports.setStorage = setStorage;
|
|
983
|
-
exports.sleep = sleep;
|
|
984
985
|
exports.test = test;
|
|
985
986
|
exports.throttle = throttle;
|
|
986
987
|
exports.toLine = toLine;
|
|
987
988
|
exports.tryCatch = tryCatch;
|
|
988
|
-
exports.uuid = uuid;
|
|
989
|
-
exports.validForm = validForm;
|
|
990
989
|
exports.validate = validate;
|
|
990
|
+
exports.validateForm = validateForm;
|
|
991
991
|
exports.validateTrigger = validateTrigger;
|
|
@@ -373,7 +373,7 @@ function clearStorage(str = "") {
|
|
|
373
373
|
function _isObjectWithExclude(obj) {
|
|
374
374
|
return typeof obj === "object" && obj !== null && "exclude" in obj && Array.isArray(obj.exclude);
|
|
375
375
|
}
|
|
376
|
-
function
|
|
376
|
+
function validateForm(ref, { message = "\u8868\u5355\u6821\u9A8C\u9519\u8BEF, \u8BF7\u68C0\u67E5", detail = false, showMessage = true } = {}) {
|
|
377
377
|
return new Promise((resolve, reject) => {
|
|
378
378
|
unref(ref).validate((valid, status) => {
|
|
379
379
|
if (valid) {
|
|
@@ -455,7 +455,7 @@ function clone(data, times = 1) {
|
|
|
455
455
|
}
|
|
456
456
|
return result;
|
|
457
457
|
}
|
|
458
|
-
function
|
|
458
|
+
function mockValue(type = "", length = 4, options = {}) {
|
|
459
459
|
const { emailStr = "@qq.com", timeStr = "{y}-{m}-{d} {h}:{i}:{s}", startStr = "", optionsIndex = null } = options;
|
|
460
460
|
function isRef2(obj) {
|
|
461
461
|
return obj && typeof obj === "object" && obj._isRef === true;
|
|
@@ -487,11 +487,11 @@ function uuid(type = "", length = 4, options = {}) {
|
|
|
487
487
|
return result;
|
|
488
488
|
}
|
|
489
489
|
if (type === "email") {
|
|
490
|
-
result =
|
|
490
|
+
result = mockValue(startStr, length) + emailStr;
|
|
491
491
|
return result;
|
|
492
492
|
}
|
|
493
493
|
if (type === "time") {
|
|
494
|
-
return
|
|
494
|
+
return mockValue(startStr, length, options) + " " + formatTime(/* @__PURE__ */ new Date(), timeStr);
|
|
495
495
|
}
|
|
496
496
|
if (type === "number") {
|
|
497
497
|
const numChars = "123456789";
|
|
@@ -521,12 +521,12 @@ function getType(type) {
|
|
|
521
521
|
return typeof type;
|
|
522
522
|
}
|
|
523
523
|
}
|
|
524
|
-
function
|
|
524
|
+
function delay(delay2 = 0, fn) {
|
|
525
525
|
return new Promise(
|
|
526
526
|
(resolve) => setTimeout(() => {
|
|
527
527
|
fn?.();
|
|
528
528
|
resolve();
|
|
529
|
-
},
|
|
529
|
+
}, delay2)
|
|
530
530
|
);
|
|
531
531
|
}
|
|
532
532
|
function validateTrigger(type = "required", rules = {}, pureValid = false) {
|
|
@@ -782,18 +782,18 @@ function processWidth(initValue, isBase = false) {
|
|
|
782
782
|
}
|
|
783
783
|
return isBase ? res : { width: res };
|
|
784
784
|
}
|
|
785
|
-
function throttle(fn,
|
|
785
|
+
function throttle(fn, delay2 = 1e3) {
|
|
786
786
|
let last = 0;
|
|
787
787
|
let timer = void 0;
|
|
788
788
|
return function(...args) {
|
|
789
789
|
let context = this;
|
|
790
790
|
let now = +/* @__PURE__ */ new Date();
|
|
791
|
-
if (now - last <
|
|
791
|
+
if (now - last < delay2) {
|
|
792
792
|
clearTimeout(timer);
|
|
793
793
|
timer = setTimeout(function() {
|
|
794
794
|
last = now;
|
|
795
795
|
fn.apply(context, args);
|
|
796
|
-
},
|
|
796
|
+
}, delay2);
|
|
797
797
|
} else {
|
|
798
798
|
last = now;
|
|
799
799
|
fn.apply(context, args);
|
|
@@ -818,7 +818,7 @@ async function tryCatch(task, sendLoading) {
|
|
|
818
818
|
updateLoading(false);
|
|
819
819
|
}
|
|
820
820
|
}
|
|
821
|
-
function debounce(func,
|
|
821
|
+
function debounce(func, delay2 = 500, immediate, resultCallback) {
|
|
822
822
|
let timer = null;
|
|
823
823
|
let isInvoke = false;
|
|
824
824
|
const _debounce = function(...args) {
|
|
@@ -844,7 +844,7 @@ function debounce(func, delay = 500, immediate, resultCallback) {
|
|
|
844
844
|
}
|
|
845
845
|
isInvoke = false;
|
|
846
846
|
timer = null;
|
|
847
|
-
},
|
|
847
|
+
}, delay2);
|
|
848
848
|
}
|
|
849
849
|
});
|
|
850
850
|
};
|
|
@@ -946,11 +946,11 @@ function getVariable(propertyName, fallback = "") {
|
|
|
946
946
|
const DEFAULT_BUILD_TIME_FALLBACK = "\u672A\u6CE8\u5165";
|
|
947
947
|
function getUtilsBuildTime(fallback = DEFAULT_BUILD_TIME_FALLBACK) {
|
|
948
948
|
{
|
|
949
|
-
return "2026-
|
|
949
|
+
return "2026-07-01 13:13:26";
|
|
950
950
|
}
|
|
951
951
|
}
|
|
952
952
|
function test() {
|
|
953
953
|
return `build time: ${getUtilsBuildTime()}`;
|
|
954
954
|
}
|
|
955
955
|
|
|
956
|
-
export { $toast as $, formatDurationTime as A, formatImg as B, formatTextToHtml as C, formatThousands as D, formatTime as E, formatToFixed as F, clone as a, confirm as b, clearStorage as c, copy as d, debounce as e,
|
|
956
|
+
export { $toast as $, formatDurationTime as A, formatImg as B, formatTextToHtml as C, formatThousands as D, formatTime as E, formatToFixed as F, clone as a, confirm as b, clearStorage as c, copy as d, debounce as e, delay as f, getStorage as g, getType as h, getUtilsBuildTime as i, getVariable as j, isEmpty as k, log as l, merge as m, mockValue as n, throttle as o, processWidth as p, toLine as q, random as r, setStorage as s, test as t, tryCatch as u, validate as v, validateForm as w, validateTrigger as x, formatBytes as y, formatBytesConvert as z };
|