@oeos-components/utils 0.0.19 → 0.0.22

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.
@@ -0,0 +1,342 @@
1
+ import * as element_plus from 'element-plus';
2
+ import { MessageOptions } from 'element-plus';
3
+ import { VNode } from 'vue';
4
+ import { Ref } from '@vue/reactivity';
5
+
6
+ type Func = (...args: any[]) => any;
7
+ /**
8
+ * 现有方法如下
9
+ * $toast(message, type: string | object = 'success', otherParams: object = {})
10
+ * setStorage(storageName: string, params: any, isSession = false)
11
+ * getStorage(data, isSession = false)
12
+ * clearStorage(str: string | [] | object = '')
13
+ * validForm(ref, { message = '表单校验错误, 请检查', detail = false, showMessage = true } = {})
14
+ * isEmpty(data: any): boolean
15
+ * notEmpty(v: any): boolean
16
+ * merge(obj1: object, obj2: object): object
17
+ * clone(data, times = 1)
18
+ * uuid(type = '',length = 4,{ emailStr = '@qq.com', timeStr = '{m}-{d} {h}:{i}:{s}', startStr = '', optionsIndex = null } = {},)
19
+ * getType(type)
20
+ * sleep(delay = 0, fn?: () => void)
21
+ * validate(type = 'required', rules = {}, pureValid = false)
22
+ * asyncWrapper(func, ...args)
23
+ * copy = (text, toastParams = {})
24
+ * log(variableStr, variable, otherInfo = '')
25
+ * random(min = 0, max = 10)
26
+ * toLine(text, connect = '-')
27
+ * processWidth(initValue, isBase = false)
28
+ * throttle(fn, delay = 1000)
29
+ * debounce(fn, delay = 1000)
30
+ * confirm(message, options)
31
+ * getVariable('--green')
32
+ */
33
+ /**
34
+ * @example1
35
+ proxy.$toast('保存成功') // s:success; i: info; w: warning; e: error;
36
+ proxy.$toast('保存失败', 'e')
37
+ proxy.$toast('永不关闭', {duration: 0})
38
+ proxy.$toast({
39
+ message: 'andy',
40
+ type: 'warning',
41
+ duration: 300,
42
+ closeAll: true,
43
+ })
44
+ * $toast.success('This is a success message')
45
+ * @example2 显示对象
46
+ * $toast({
47
+ dangerouslyUseHTMLString: true,
48
+ message: `<h6>复制成功</h6><pre>${JSON.stringify(obj, null, 2)}</pre>`,
49
+ type: 'success',
50
+ duration: 5000,
51
+ })
52
+ */
53
+ type MessageType = 'success' | 'info' | 'error' | 'warning';
54
+ type ShortType = 's' | 'i' | 'e' | 'w';
55
+ type ToastType = MessageType | ShortType;
56
+ type ToastOptions = Partial<MessageOptions> & {
57
+ closeAll?: boolean;
58
+ };
59
+ declare function $toast(message: string | ToastOptions | VNode | (() => VNode), type?: ToastType | ToastOptions, otherParams?: ToastOptions): void;
60
+ declare namespace $toast {
61
+ var success: (message: any, otherParams?: {}) => void;
62
+ var info: (message: any, otherParams?: {}) => void;
63
+ var error: (message: any, otherParams?: {}) => void;
64
+ var warning: (message: any, otherParams?: {}) => void;
65
+ }
66
+ declare function setStorage(storageName: string, params: any, isSession?: boolean): void;
67
+ declare function getStorage(data: any, isSession?: boolean): string | null;
68
+ /**
69
+ *
70
+ * @param {*} str 需要清空的localStorage或sessionStorage, 如果不传清空所有
71
+ * @param {*} param1 需要排除的sessionStorage或者localStorage
72
+ * @example
73
+ * clearStorage()
74
+ * clearStorage('loginId')
75
+ * clearStorage(['loginId', 'token'])
76
+ * clearStorage({ exclude: ['loginId', 'token'] })
77
+ */
78
+ declare function clearStorage(str?: string | [] | object): void;
79
+ /**
80
+ * element-plus的form表单使用promise进行封装
81
+ * @param ref
82
+ * @param param1
83
+ * @returns Promise
84
+ * await proxy.validForm(formRef);
85
+ * await proxy.validForm(formRef, {message: '自定义错误'});
86
+ * await proxy.validForm(formRef, {showMessage: false});
87
+ * await proxy.validForm(formRef, {detail: true});
88
+ */
89
+ declare function validForm(ref: any, { message, detail, showMessage }?: {
90
+ message?: string | undefined;
91
+ detail?: boolean | undefined;
92
+ showMessage?: boolean | undefined;
93
+ }): Promise<unknown>;
94
+ /**
95
+ * 判断变量是否空值
96
+ * undefined, null, '', ' ', false, 0, [], {}, NaN, new Set(), new Map(), BigInt(0), new Date('无效日期') 均返回true,否则返回false
97
+ */
98
+ declare function isEmpty(data: any, strict?: boolean): boolean;
99
+ declare function notEmpty(v: any): boolean;
100
+ /**
101
+ * 将两个对象合并, 以第二个对象为准, 如果两个对象, 一个属性有值, 一个没值, 合并后有值; 如果两个属性都有值, 以第二个属性为准
102
+ * */
103
+ declare function merge(obj1: object, obj2: object): object;
104
+ /**
105
+ * 克隆数据并根据需要复制数组
106
+ * @param {any} data - 要克隆的数据
107
+ * @param {number} [times=1] - 如果是数组,要复制的次数
108
+ * @returns {any} - 克隆后的数据或复制后的数组
109
+ * clone(123) => 123
110
+ * clone([1,2, {name: 'andy'}], 2) => [1, 2, {name: 'andy'}, 1, 2, {name: 'andy'}]
111
+ */
112
+ declare function clone(data: any, times?: number): any;
113
+ /**
114
+ * 生成 UUID
115
+ * @param type - 生成 UUID 的类型,可以是 'phone', 'email', 'time', 'number', 'ip', 'port' 或空字符串
116
+ * @param length - 生成字符串的长度(默认为4)
117
+ * @param options - 额外的选项
118
+ * @param options.emailStr - 生成 email 时使用的后缀(默认为 '@qq.com')
119
+ * @param options.timeStr - 生成时间字符串的格式(默认为 '{y}-{m}-{d} {h}:{i}:{s}')
120
+ * @param options.startStr - 起始字符串(默认为空)
121
+ * @param options.optionsIndex - 数组索引(默认为随机)
122
+ * @returns 生成的 UUID (字符串或数字)
123
+ * * uuid("名字") => 名字hc8f
124
+ * uuid() => abcd
125
+ * uuid('time') => 25MR 10-27 17:34:01
126
+ * uuid('time', 0, {startStr:'andy', timeStr:"{h}:{i}:{s}"}) => andy 17:38:23
127
+ * uuid('phone') => 13603312460
128
+ * uuid('email') => cBZA@qq.com
129
+ * uuid('number') => 2319
130
+ * uuid([ { label: "小泽泽", value: "xzz" },{ label: "小月月", value: "xyy" }]) => xzz
131
+ */
132
+ declare function uuid(type?: string | Array<{
133
+ label: string;
134
+ value: any;
135
+ }>, length?: number, options?: {
136
+ emailStr?: string;
137
+ timeStr?: string;
138
+ startStr?: string;
139
+ optionsIndex?: number | null;
140
+ }): string | number;
141
+ /**
142
+ * 判断传入参数的类型
143
+ * @param {*} type
144
+ * getType(new RegExp()) regexp
145
+ * getType(new Date()) date
146
+ * getType([]) array
147
+ * getType({}) object
148
+ * getType(null) null
149
+ * getType(123) number
150
+ */
151
+ declare function getType(type: any): string;
152
+ /**
153
+ * 一个辅助函数,用于在代码中创建一个暂停(延迟)。
154
+ * 它返回一个 Promise,你可以在 `await` 后使用它来实现类似 "sleep" 的效果。
155
+ *
156
+ * @param delay - 等待的毫秒数。默认值为 0,表示不延迟。
157
+ * @param fn - (可选) 一个在延迟结束后立即执行的函数。
158
+ *
159
+ * @returns 一个 Promise,当延迟结束后解析(resolve)。
160
+ *
161
+ * @example
162
+ * // 基本用法:延迟 2 秒后打印消息
163
+ * console.log('开始');
164
+ * await sleep(2000);
165
+ * console.log('2秒后执行');
166
+ *
167
+ * @example
168
+ * // 带回调函数的用法:延迟 1 秒后执行清理工作
169
+ * sleep(1000, () => {
170
+ * console.log('执行清理操作...');
171
+ * // 清理代码...
172
+ * });
173
+ *
174
+ * @example
175
+ * // 在循环中使用:每次迭代后延迟 500 毫秒
176
+ * for (let i = 0; i < 5; i++) {
177
+ * console.log(`当前值: ${i}`);
178
+ * await sleep(500);
179
+ * }
180
+ */
181
+ declare function sleep(delay?: number, fn?: () => void): Promise<void>;
182
+ declare function validateTrigger(type?: string, rules?: {}, pureValid?: boolean): boolean | {
183
+ validator: (rule: any, value: any, callback: (error?: Error | undefined) => void) => void;
184
+ required: any;
185
+ trigger: any;
186
+ } | {
187
+ required: any;
188
+ message: any;
189
+ trigger: any;
190
+ validator?: undefined;
191
+ min?: undefined;
192
+ max?: undefined;
193
+ } | {
194
+ validator: (rule: any, value: any, callback: (error?: Error | undefined) => void) => void;
195
+ trigger: any;
196
+ required?: undefined;
197
+ message?: undefined;
198
+ min?: undefined;
199
+ max?: undefined;
200
+ } | {
201
+ min: any;
202
+ max: any;
203
+ message: any;
204
+ trigger: any;
205
+ required: any;
206
+ validator?: undefined;
207
+ } | undefined;
208
+ declare function validate(type?: string, rules?: Record<string, any>, pureValid?: boolean): boolean | {
209
+ validator: (rule: any, value: any, callback: (error?: Error) => void) => void;
210
+ required: any;
211
+ trigger: any;
212
+ } | {
213
+ required: any;
214
+ message: any;
215
+ trigger: any;
216
+ validator?: undefined;
217
+ min?: undefined;
218
+ max?: undefined;
219
+ } | {
220
+ validator: (rule: any, value: any, callback: (error?: Error) => void) => void;
221
+ trigger: any;
222
+ required?: undefined;
223
+ message?: undefined;
224
+ min?: undefined;
225
+ max?: undefined;
226
+ } | {
227
+ min: any;
228
+ max: any;
229
+ message: any;
230
+ trigger: any;
231
+ required: any;
232
+ validator?: undefined;
233
+ } | undefined;
234
+ /**
235
+ *
236
+ const { res, err } = await proxy.asyncWrapper(listTests, pickForm);
237
+ if (err) {
238
+ return;
239
+ }
240
+ */
241
+ declare function asyncWrapper(func: any, ...args: any[]): Promise<{
242
+ res: any;
243
+ err?: undefined;
244
+ } | {
245
+ err: unknown;
246
+ res?: undefined;
247
+ }>;
248
+ type ToastParams = {
249
+ hideToast?: boolean;
250
+ } | (Omit<ToastOptions, 'hideToast'> & {
251
+ hideToast: boolean;
252
+ });
253
+ /**
254
+ * 复制文本
255
+ *
256
+ * copy('这是要复制的文本');
257
+ *
258
+ * copy('这是要复制的文本', {duration: 500});
259
+ *
260
+ * copy('这是要复制的文本', {hideToast: true});
261
+ *
262
+ * */
263
+ declare const copy: (text: any, toastParams?: ToastParams) => boolean;
264
+ declare function log(variableStr: any, variable: any, otherInfo?: string): void;
265
+ /**
266
+ * 生成指定范围内的随机整数
267
+ *
268
+ * @param min 最小值,默认为0
269
+ * @param max 最大值,默认为10
270
+ * @returns 返回生成的随机整数
271
+ */
272
+ declare function random(min?: number, max?: number): number;
273
+ /**
274
+ * 将文本转换为带有连接符的行文本
275
+ *
276
+ * @param text 要转换的文本
277
+ * @param connect 连接符,默认为'-'
278
+ * @returns 返回转换后的行文本
279
+ * toLine('NameAndy') // name-andy
280
+ * toLine('nameAndy') // name-andy
281
+ * toLine('_nameAndy') // _name-andy
282
+ */
283
+ declare function toLine(text: any, connect?: string): any;
284
+ declare function processWidth(initValue: any, isBase?: boolean): any;
285
+ declare function throttle(fn: any, delay?: number): () => void;
286
+ /**
287
+ * 封装 Promise 执行,提供自动 loading 状态管理
288
+ * @param promise 需要执行的 Promise
289
+ * @param sendLoading 可选的 loading 状态(支持 Ref<boolean> 或 boolean)
290
+ * @returns Promise<{ data: T | null; error: any }>
291
+ * @example1
292
+ * const loading = ref(false);
293
+ * const { data, error } = await tryCatch(fetchUserData(), loading);
294
+ * @example2 // 无视 loading 状态
295
+ * const { data, error } = await tryCatch(fetchUserData());
296
+ */
297
+ declare function tryCatch<T>(promise: Promise<T>, sendLoading?: Ref<boolean> | null): Promise<{
298
+ data: T | null;
299
+ error: any;
300
+ }>;
301
+ /**
302
+ * 防抖函数
303
+ * @param { Function } func 函数
304
+ * @param { Number } delay 防抖时间
305
+ * @param { Boolean } immediate 是否立即执行
306
+ * @param { Function } resultCallback
307
+ */
308
+ declare function debounce(func: Func, delay?: number, immediate?: boolean, resultCallback?: Func): {
309
+ (this: unknown, ...args: any[]): Promise<unknown>;
310
+ cancel(): void;
311
+ };
312
+ /**
313
+ * proxy.confirm('确定删除吗?')
314
+ * proxy.confirm('哈哈', { icon: 'el-icon-plus' })
315
+ * close-on-click-modal: 是否可通过点击遮罩层关闭 MessageBox 默认true
316
+ * lock-scroll: 是否在 MessageBox 出现时将 body 滚动锁定. 默认true
317
+ * 设置宽度, 内容使用组件
318
+ import GWarning from '@/autoComponents/gWarning.vue'
319
+ await proxy.confirm('', {
320
+ dangerouslyUseHTMLString: true,
321
+ customStyle: {
322
+ maxWidth: '600px',
323
+ },
324
+ message: h(GWarning, {
325
+ content:
326
+ '对于光存储开启保持原始对象名称后,对象将作为独立文件在光存储介质直接存储。<br>注意:当桶内文件大小普遍较小(<100MB)或过大(>5GB)时不推荐打开此功能!您确定开启此功能吗?',
327
+ }),
328
+ showCancelButton: true,
329
+ cancelButtonText: '取消',
330
+ appendTo: '#highSettingsForm',
331
+ })
332
+ * 如果是多个dialog嵌套, 可以给上层的dom设置个id如highSettingsForm, 然后appendTo: '#highSettingsForm'
333
+ */
334
+ declare function confirm(message: any, options: any): Promise<element_plus.MessageBoxData>;
335
+ /** Function to get a CSS custom property value
336
+ *
337
+ * getVariable('--blue');
338
+ * */
339
+ declare function getVariable(propertyName: any): string;
340
+ declare function test(): string;
341
+
342
+ export { $toast, asyncWrapper, clearStorage, clone, confirm, copy, debounce, getStorage, getType, getVariable, isEmpty, log, merge, notEmpty, processWidth, random, setStorage, sleep, test, throttle, toLine, tryCatch, uuid, validForm, validate, validateTrigger };
@@ -0,0 +1,342 @@
1
+ import * as element_plus from 'element-plus';
2
+ import { MessageOptions } from 'element-plus';
3
+ import { VNode } from 'vue';
4
+ import { Ref } from '@vue/reactivity';
5
+
6
+ type Func = (...args: any[]) => any;
7
+ /**
8
+ * 现有方法如下
9
+ * $toast(message, type: string | object = 'success', otherParams: object = {})
10
+ * setStorage(storageName: string, params: any, isSession = false)
11
+ * getStorage(data, isSession = false)
12
+ * clearStorage(str: string | [] | object = '')
13
+ * validForm(ref, { message = '表单校验错误, 请检查', detail = false, showMessage = true } = {})
14
+ * isEmpty(data: any): boolean
15
+ * notEmpty(v: any): boolean
16
+ * merge(obj1: object, obj2: object): object
17
+ * clone(data, times = 1)
18
+ * uuid(type = '',length = 4,{ emailStr = '@qq.com', timeStr = '{m}-{d} {h}:{i}:{s}', startStr = '', optionsIndex = null } = {},)
19
+ * getType(type)
20
+ * sleep(delay = 0, fn?: () => void)
21
+ * validate(type = 'required', rules = {}, pureValid = false)
22
+ * asyncWrapper(func, ...args)
23
+ * copy = (text, toastParams = {})
24
+ * log(variableStr, variable, otherInfo = '')
25
+ * random(min = 0, max = 10)
26
+ * toLine(text, connect = '-')
27
+ * processWidth(initValue, isBase = false)
28
+ * throttle(fn, delay = 1000)
29
+ * debounce(fn, delay = 1000)
30
+ * confirm(message, options)
31
+ * getVariable('--green')
32
+ */
33
+ /**
34
+ * @example1
35
+ proxy.$toast('保存成功') // s:success; i: info; w: warning; e: error;
36
+ proxy.$toast('保存失败', 'e')
37
+ proxy.$toast('永不关闭', {duration: 0})
38
+ proxy.$toast({
39
+ message: 'andy',
40
+ type: 'warning',
41
+ duration: 300,
42
+ closeAll: true,
43
+ })
44
+ * $toast.success('This is a success message')
45
+ * @example2 显示对象
46
+ * $toast({
47
+ dangerouslyUseHTMLString: true,
48
+ message: `<h6>复制成功</h6><pre>${JSON.stringify(obj, null, 2)}</pre>`,
49
+ type: 'success',
50
+ duration: 5000,
51
+ })
52
+ */
53
+ type MessageType = 'success' | 'info' | 'error' | 'warning';
54
+ type ShortType = 's' | 'i' | 'e' | 'w';
55
+ type ToastType = MessageType | ShortType;
56
+ type ToastOptions = Partial<MessageOptions> & {
57
+ closeAll?: boolean;
58
+ };
59
+ declare function $toast(message: string | ToastOptions | VNode | (() => VNode), type?: ToastType | ToastOptions, otherParams?: ToastOptions): void;
60
+ declare namespace $toast {
61
+ var success: (message: any, otherParams?: {}) => void;
62
+ var info: (message: any, otherParams?: {}) => void;
63
+ var error: (message: any, otherParams?: {}) => void;
64
+ var warning: (message: any, otherParams?: {}) => void;
65
+ }
66
+ declare function setStorage(storageName: string, params: any, isSession?: boolean): void;
67
+ declare function getStorage(data: any, isSession?: boolean): string | null;
68
+ /**
69
+ *
70
+ * @param {*} str 需要清空的localStorage或sessionStorage, 如果不传清空所有
71
+ * @param {*} param1 需要排除的sessionStorage或者localStorage
72
+ * @example
73
+ * clearStorage()
74
+ * clearStorage('loginId')
75
+ * clearStorage(['loginId', 'token'])
76
+ * clearStorage({ exclude: ['loginId', 'token'] })
77
+ */
78
+ declare function clearStorage(str?: string | [] | object): void;
79
+ /**
80
+ * element-plus的form表单使用promise进行封装
81
+ * @param ref
82
+ * @param param1
83
+ * @returns Promise
84
+ * await proxy.validForm(formRef);
85
+ * await proxy.validForm(formRef, {message: '自定义错误'});
86
+ * await proxy.validForm(formRef, {showMessage: false});
87
+ * await proxy.validForm(formRef, {detail: true});
88
+ */
89
+ declare function validForm(ref: any, { message, detail, showMessage }?: {
90
+ message?: string | undefined;
91
+ detail?: boolean | undefined;
92
+ showMessage?: boolean | undefined;
93
+ }): Promise<unknown>;
94
+ /**
95
+ * 判断变量是否空值
96
+ * undefined, null, '', ' ', false, 0, [], {}, NaN, new Set(), new Map(), BigInt(0), new Date('无效日期') 均返回true,否则返回false
97
+ */
98
+ declare function isEmpty(data: any, strict?: boolean): boolean;
99
+ declare function notEmpty(v: any): boolean;
100
+ /**
101
+ * 将两个对象合并, 以第二个对象为准, 如果两个对象, 一个属性有值, 一个没值, 合并后有值; 如果两个属性都有值, 以第二个属性为准
102
+ * */
103
+ declare function merge(obj1: object, obj2: object): object;
104
+ /**
105
+ * 克隆数据并根据需要复制数组
106
+ * @param {any} data - 要克隆的数据
107
+ * @param {number} [times=1] - 如果是数组,要复制的次数
108
+ * @returns {any} - 克隆后的数据或复制后的数组
109
+ * clone(123) => 123
110
+ * clone([1,2, {name: 'andy'}], 2) => [1, 2, {name: 'andy'}, 1, 2, {name: 'andy'}]
111
+ */
112
+ declare function clone(data: any, times?: number): any;
113
+ /**
114
+ * 生成 UUID
115
+ * @param type - 生成 UUID 的类型,可以是 'phone', 'email', 'time', 'number', 'ip', 'port' 或空字符串
116
+ * @param length - 生成字符串的长度(默认为4)
117
+ * @param options - 额外的选项
118
+ * @param options.emailStr - 生成 email 时使用的后缀(默认为 '@qq.com')
119
+ * @param options.timeStr - 生成时间字符串的格式(默认为 '{y}-{m}-{d} {h}:{i}:{s}')
120
+ * @param options.startStr - 起始字符串(默认为空)
121
+ * @param options.optionsIndex - 数组索引(默认为随机)
122
+ * @returns 生成的 UUID (字符串或数字)
123
+ * * uuid("名字") => 名字hc8f
124
+ * uuid() => abcd
125
+ * uuid('time') => 25MR 10-27 17:34:01
126
+ * uuid('time', 0, {startStr:'andy', timeStr:"{h}:{i}:{s}"}) => andy 17:38:23
127
+ * uuid('phone') => 13603312460
128
+ * uuid('email') => cBZA@qq.com
129
+ * uuid('number') => 2319
130
+ * uuid([ { label: "小泽泽", value: "xzz" },{ label: "小月月", value: "xyy" }]) => xzz
131
+ */
132
+ declare function uuid(type?: string | Array<{
133
+ label: string;
134
+ value: any;
135
+ }>, length?: number, options?: {
136
+ emailStr?: string;
137
+ timeStr?: string;
138
+ startStr?: string;
139
+ optionsIndex?: number | null;
140
+ }): string | number;
141
+ /**
142
+ * 判断传入参数的类型
143
+ * @param {*} type
144
+ * getType(new RegExp()) regexp
145
+ * getType(new Date()) date
146
+ * getType([]) array
147
+ * getType({}) object
148
+ * getType(null) null
149
+ * getType(123) number
150
+ */
151
+ declare function getType(type: any): string;
152
+ /**
153
+ * 一个辅助函数,用于在代码中创建一个暂停(延迟)。
154
+ * 它返回一个 Promise,你可以在 `await` 后使用它来实现类似 "sleep" 的效果。
155
+ *
156
+ * @param delay - 等待的毫秒数。默认值为 0,表示不延迟。
157
+ * @param fn - (可选) 一个在延迟结束后立即执行的函数。
158
+ *
159
+ * @returns 一个 Promise,当延迟结束后解析(resolve)。
160
+ *
161
+ * @example
162
+ * // 基本用法:延迟 2 秒后打印消息
163
+ * console.log('开始');
164
+ * await sleep(2000);
165
+ * console.log('2秒后执行');
166
+ *
167
+ * @example
168
+ * // 带回调函数的用法:延迟 1 秒后执行清理工作
169
+ * sleep(1000, () => {
170
+ * console.log('执行清理操作...');
171
+ * // 清理代码...
172
+ * });
173
+ *
174
+ * @example
175
+ * // 在循环中使用:每次迭代后延迟 500 毫秒
176
+ * for (let i = 0; i < 5; i++) {
177
+ * console.log(`当前值: ${i}`);
178
+ * await sleep(500);
179
+ * }
180
+ */
181
+ declare function sleep(delay?: number, fn?: () => void): Promise<void>;
182
+ declare function validateTrigger(type?: string, rules?: {}, pureValid?: boolean): boolean | {
183
+ validator: (rule: any, value: any, callback: (error?: Error | undefined) => void) => void;
184
+ required: any;
185
+ trigger: any;
186
+ } | {
187
+ required: any;
188
+ message: any;
189
+ trigger: any;
190
+ validator?: undefined;
191
+ min?: undefined;
192
+ max?: undefined;
193
+ } | {
194
+ validator: (rule: any, value: any, callback: (error?: Error | undefined) => void) => void;
195
+ trigger: any;
196
+ required?: undefined;
197
+ message?: undefined;
198
+ min?: undefined;
199
+ max?: undefined;
200
+ } | {
201
+ min: any;
202
+ max: any;
203
+ message: any;
204
+ trigger: any;
205
+ required: any;
206
+ validator?: undefined;
207
+ } | undefined;
208
+ declare function validate(type?: string, rules?: Record<string, any>, pureValid?: boolean): boolean | {
209
+ validator: (rule: any, value: any, callback: (error?: Error) => void) => void;
210
+ required: any;
211
+ trigger: any;
212
+ } | {
213
+ required: any;
214
+ message: any;
215
+ trigger: any;
216
+ validator?: undefined;
217
+ min?: undefined;
218
+ max?: undefined;
219
+ } | {
220
+ validator: (rule: any, value: any, callback: (error?: Error) => void) => void;
221
+ trigger: any;
222
+ required?: undefined;
223
+ message?: undefined;
224
+ min?: undefined;
225
+ max?: undefined;
226
+ } | {
227
+ min: any;
228
+ max: any;
229
+ message: any;
230
+ trigger: any;
231
+ required: any;
232
+ validator?: undefined;
233
+ } | undefined;
234
+ /**
235
+ *
236
+ const { res, err } = await proxy.asyncWrapper(listTests, pickForm);
237
+ if (err) {
238
+ return;
239
+ }
240
+ */
241
+ declare function asyncWrapper(func: any, ...args: any[]): Promise<{
242
+ res: any;
243
+ err?: undefined;
244
+ } | {
245
+ err: unknown;
246
+ res?: undefined;
247
+ }>;
248
+ type ToastParams = {
249
+ hideToast?: boolean;
250
+ } | (Omit<ToastOptions, 'hideToast'> & {
251
+ hideToast: boolean;
252
+ });
253
+ /**
254
+ * 复制文本
255
+ *
256
+ * copy('这是要复制的文本');
257
+ *
258
+ * copy('这是要复制的文本', {duration: 500});
259
+ *
260
+ * copy('这是要复制的文本', {hideToast: true});
261
+ *
262
+ * */
263
+ declare const copy: (text: any, toastParams?: ToastParams) => boolean;
264
+ declare function log(variableStr: any, variable: any, otherInfo?: string): void;
265
+ /**
266
+ * 生成指定范围内的随机整数
267
+ *
268
+ * @param min 最小值,默认为0
269
+ * @param max 最大值,默认为10
270
+ * @returns 返回生成的随机整数
271
+ */
272
+ declare function random(min?: number, max?: number): number;
273
+ /**
274
+ * 将文本转换为带有连接符的行文本
275
+ *
276
+ * @param text 要转换的文本
277
+ * @param connect 连接符,默认为'-'
278
+ * @returns 返回转换后的行文本
279
+ * toLine('NameAndy') // name-andy
280
+ * toLine('nameAndy') // name-andy
281
+ * toLine('_nameAndy') // _name-andy
282
+ */
283
+ declare function toLine(text: any, connect?: string): any;
284
+ declare function processWidth(initValue: any, isBase?: boolean): any;
285
+ declare function throttle(fn: any, delay?: number): () => void;
286
+ /**
287
+ * 封装 Promise 执行,提供自动 loading 状态管理
288
+ * @param promise 需要执行的 Promise
289
+ * @param sendLoading 可选的 loading 状态(支持 Ref<boolean> 或 boolean)
290
+ * @returns Promise<{ data: T | null; error: any }>
291
+ * @example1
292
+ * const loading = ref(false);
293
+ * const { data, error } = await tryCatch(fetchUserData(), loading);
294
+ * @example2 // 无视 loading 状态
295
+ * const { data, error } = await tryCatch(fetchUserData());
296
+ */
297
+ declare function tryCatch<T>(promise: Promise<T>, sendLoading?: Ref<boolean> | null): Promise<{
298
+ data: T | null;
299
+ error: any;
300
+ }>;
301
+ /**
302
+ * 防抖函数
303
+ * @param { Function } func 函数
304
+ * @param { Number } delay 防抖时间
305
+ * @param { Boolean } immediate 是否立即执行
306
+ * @param { Function } resultCallback
307
+ */
308
+ declare function debounce(func: Func, delay?: number, immediate?: boolean, resultCallback?: Func): {
309
+ (this: unknown, ...args: any[]): Promise<unknown>;
310
+ cancel(): void;
311
+ };
312
+ /**
313
+ * proxy.confirm('确定删除吗?')
314
+ * proxy.confirm('哈哈', { icon: 'el-icon-plus' })
315
+ * close-on-click-modal: 是否可通过点击遮罩层关闭 MessageBox 默认true
316
+ * lock-scroll: 是否在 MessageBox 出现时将 body 滚动锁定. 默认true
317
+ * 设置宽度, 内容使用组件
318
+ import GWarning from '@/autoComponents/gWarning.vue'
319
+ await proxy.confirm('', {
320
+ dangerouslyUseHTMLString: true,
321
+ customStyle: {
322
+ maxWidth: '600px',
323
+ },
324
+ message: h(GWarning, {
325
+ content:
326
+ '对于光存储开启保持原始对象名称后,对象将作为独立文件在光存储介质直接存储。<br>注意:当桶内文件大小普遍较小(<100MB)或过大(>5GB)时不推荐打开此功能!您确定开启此功能吗?',
327
+ }),
328
+ showCancelButton: true,
329
+ cancelButtonText: '取消',
330
+ appendTo: '#highSettingsForm',
331
+ })
332
+ * 如果是多个dialog嵌套, 可以给上层的dom设置个id如highSettingsForm, 然后appendTo: '#highSettingsForm'
333
+ */
334
+ declare function confirm(message: any, options: any): Promise<element_plus.MessageBoxData>;
335
+ /** Function to get a CSS custom property value
336
+ *
337
+ * getVariable('--blue');
338
+ * */
339
+ declare function getVariable(propertyName: any): string;
340
+ declare function test(): string;
341
+
342
+ export { $toast, asyncWrapper, clearStorage, clone, confirm, copy, debounce, getStorage, getType, getVariable, isEmpty, log, merge, notEmpty, processWidth, random, setStorage, sleep, test, throttle, toLine, tryCatch, uuid, validForm, validate, validateTrigger };