@jhqn/utils-core 0.0.1-beta.23 → 0.0.1-beta.25
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/index.cjs +130 -23
- package/dist/index.d.cts +757 -0
- package/dist/index.d.mts +757 -0
- package/dist/index.d.ts +173 -29
- package/dist/index.mjs +122 -25
- package/package.json +9 -5
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,757 @@
|
|
|
1
|
+
/// <reference types="dayjs/plugin/localeData" />
|
|
2
|
+
/// <reference types="dayjs/plugin/duration" />
|
|
3
|
+
/// <reference types="dayjs/plugin/relativeTime" />
|
|
4
|
+
/// <reference types="dayjs/plugin/customParseFormat" />
|
|
5
|
+
/// <reference types="dayjs/plugin/objectSupport" />
|
|
6
|
+
import * as detect_browser from 'detect-browser';
|
|
7
|
+
import { ConfigType } from 'dayjs';
|
|
8
|
+
export { Dayjs, default as dayjs } from 'dayjs';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* snake2Kebab
|
|
12
|
+
* @param {string} str 字符串
|
|
13
|
+
* @returns {string} 转换后的字符串
|
|
14
|
+
* @example snake2Kebab('hello_world') // hello_world => hello-world
|
|
15
|
+
*/
|
|
16
|
+
declare const snake2Kebab: (str: string) => string;
|
|
17
|
+
/**
|
|
18
|
+
* snake2Pascal
|
|
19
|
+
* @param {string} str 字符串
|
|
20
|
+
* @returns {string} 转换后的字符串
|
|
21
|
+
* @example snake2Pascal('hello_world') // hello_world => HelloWorld
|
|
22
|
+
*/
|
|
23
|
+
declare const snake2Pascal: (str: string) => string;
|
|
24
|
+
/**
|
|
25
|
+
* snake2Camel
|
|
26
|
+
* @param {string} str 字符串
|
|
27
|
+
* @returns {string} 转换后的字符串
|
|
28
|
+
* @example snake2Camel('hello_world') // hello_world => helloWorld
|
|
29
|
+
*/
|
|
30
|
+
declare const snake2Camel: (str: string) => string;
|
|
31
|
+
/**
|
|
32
|
+
* snake2Title
|
|
33
|
+
* @param {string} str 字符串
|
|
34
|
+
* @returns {string} 转换后的字符串
|
|
35
|
+
* @example snake2Title('hello_world') // hello_world => Hello World
|
|
36
|
+
*/
|
|
37
|
+
declare const snake2Title: (str: string) => string;
|
|
38
|
+
/**
|
|
39
|
+
* kebab2Snake
|
|
40
|
+
* @param {string} str 字符串
|
|
41
|
+
* @returns {string} 转换后的字符串
|
|
42
|
+
* @example kebab2Snake('hello-world') // hello-world => hello_world
|
|
43
|
+
*/
|
|
44
|
+
declare const kebab2Snake: (str: string) => string;
|
|
45
|
+
/**
|
|
46
|
+
* kebab2Pascal
|
|
47
|
+
* @param {string} str 字符串
|
|
48
|
+
* @returns {string} 转换后的字符串
|
|
49
|
+
* @example kebab2Pascal('hello-world') // hello-world => HelloWorld
|
|
50
|
+
*/
|
|
51
|
+
declare const kebab2Pascal: (str: string) => string;
|
|
52
|
+
/**
|
|
53
|
+
* kebab2Camel
|
|
54
|
+
* @param {string} str 字符串
|
|
55
|
+
* @returns {string} 转换后的字符串
|
|
56
|
+
* @example kebab2Camel('hello-world') // hello-world => helloWorld
|
|
57
|
+
*/
|
|
58
|
+
declare const kebab2Camel: (str: string) => string;
|
|
59
|
+
/**
|
|
60
|
+
* kebab2Title
|
|
61
|
+
* @param {string} str 字符串
|
|
62
|
+
* @returns {string} 转换后的字符串
|
|
63
|
+
* @example kebab2Title('hello-world') // hello-world => Hello World
|
|
64
|
+
*/
|
|
65
|
+
declare const kebab2Title: (str: string) => string;
|
|
66
|
+
/**
|
|
67
|
+
* pascal2Snake
|
|
68
|
+
* @param {string} str 字符串
|
|
69
|
+
* @returns {string} 转换后的字符串
|
|
70
|
+
* @example pascal2Snake('HelloWorld') // HelloWorld => hello_world
|
|
71
|
+
*/
|
|
72
|
+
declare const pascal2Snake: (str: string) => string;
|
|
73
|
+
/**
|
|
74
|
+
* pascal2Kebab
|
|
75
|
+
* @param {string} str 字符串
|
|
76
|
+
* @returns {string} 转换后的字符串
|
|
77
|
+
* @example pascal2Kebab('HelloWorld') // HelloWorld => hello-world
|
|
78
|
+
*/
|
|
79
|
+
declare const pascal2Kebab: (str: string) => string;
|
|
80
|
+
/**
|
|
81
|
+
* pascal2Camel
|
|
82
|
+
* @param {string} str 字符串
|
|
83
|
+
* @returns {string} 转换后的字符串
|
|
84
|
+
* @example pascal2Camel('HelloWorld') // HelloWorld => helloWorld
|
|
85
|
+
*/
|
|
86
|
+
declare const pascal2Camel: (str: string) => string;
|
|
87
|
+
/**
|
|
88
|
+
* pascal2Title
|
|
89
|
+
* @param {string} str 字符串
|
|
90
|
+
* @returns {string} 转换后的字符串
|
|
91
|
+
* @example pascal2Title('HelloWorld') // HelloWorld => Hello World
|
|
92
|
+
*/
|
|
93
|
+
declare const pascal2Title: (str: string) => string;
|
|
94
|
+
/**
|
|
95
|
+
* camel2Snake
|
|
96
|
+
* @param {string} str 字符串
|
|
97
|
+
* @returns {string} 转换后的字符串
|
|
98
|
+
* @example camel2Snake('helloWorld') // helloWorld => hello_world
|
|
99
|
+
*/
|
|
100
|
+
declare const camel2Snake: (str: string) => string;
|
|
101
|
+
/**
|
|
102
|
+
* camel2Kebab
|
|
103
|
+
* @param {string} str 字符串
|
|
104
|
+
* @returns {string} 转换后的字符串
|
|
105
|
+
* @example camel2Kebab('helloWorld') // helloWorld => hello-world
|
|
106
|
+
*/
|
|
107
|
+
declare const camel2Kebab: (str: string) => string;
|
|
108
|
+
/**
|
|
109
|
+
* camel2Pascal
|
|
110
|
+
* @param {string} str 字符串
|
|
111
|
+
* @returns {string} 转换后的字符串
|
|
112
|
+
* @example camel2Pascal('helloWorld') // helloWorld => HelloWorld
|
|
113
|
+
*/
|
|
114
|
+
declare const camel2Pascal: (str: string) => string;
|
|
115
|
+
/**
|
|
116
|
+
* camel2Title
|
|
117
|
+
* @param {string} str 字符串
|
|
118
|
+
* @returns {string} 转换后的字符串
|
|
119
|
+
* @example camel2Title('helloWorld') // helloWorld => Hello World
|
|
120
|
+
*/
|
|
121
|
+
declare const camel2Title: (str: string) => string;
|
|
122
|
+
/**
|
|
123
|
+
* title2Snake
|
|
124
|
+
* @param {string} str 字符串
|
|
125
|
+
* @returns {string} 转换后的字符串
|
|
126
|
+
* @example title2Snake('Hello World') // Hello World => hello_world
|
|
127
|
+
*/
|
|
128
|
+
declare const title2Snake: (str: string) => string;
|
|
129
|
+
/**
|
|
130
|
+
* title2Kebab
|
|
131
|
+
* @param {string} str 字符串
|
|
132
|
+
* @returns {string} 转换后的字符串
|
|
133
|
+
* @example title2Kebab('Hello World') // Hello World => hello-world
|
|
134
|
+
*/
|
|
135
|
+
declare const title2Kebab: (str: string) => string;
|
|
136
|
+
/**
|
|
137
|
+
* title2Pascal
|
|
138
|
+
* @param {string} str 字符串
|
|
139
|
+
* @returns {string} 转换后的字符串
|
|
140
|
+
* @example title2Pascal('Hello World') // Hello World => HelloWorld
|
|
141
|
+
*/
|
|
142
|
+
declare const title2Pascal: (str: string) => string;
|
|
143
|
+
/**
|
|
144
|
+
* title2Camel
|
|
145
|
+
* @param {string} str 字符串
|
|
146
|
+
* @returns {string} 转换后的字符串
|
|
147
|
+
* @example title2Camel('Hello World') // Hello World => helloWorld
|
|
148
|
+
*/
|
|
149
|
+
declare const title2Camel: (str: string) => string;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* jade console.log
|
|
153
|
+
* only for development
|
|
154
|
+
* @param {...any} args
|
|
155
|
+
*/
|
|
156
|
+
declare const jLog: (...args: any[]) => void | (() => void);
|
|
157
|
+
/**
|
|
158
|
+
* jade console.debug
|
|
159
|
+
* @param {...any} args
|
|
160
|
+
*/
|
|
161
|
+
declare const jDebug: (...args: any[]) => void;
|
|
162
|
+
/**
|
|
163
|
+
* jade console.warn
|
|
164
|
+
*/
|
|
165
|
+
declare const jWarn: (...args: any[]) => void;
|
|
166
|
+
/**
|
|
167
|
+
* jade console.error
|
|
168
|
+
*/
|
|
169
|
+
declare const jError: (...args: any[]) => void;
|
|
170
|
+
/**
|
|
171
|
+
* jade console.info
|
|
172
|
+
* @param {...any} args
|
|
173
|
+
*/
|
|
174
|
+
declare const jInfo: (...args: any[]) => void;
|
|
175
|
+
/**
|
|
176
|
+
* jade console.group
|
|
177
|
+
*/
|
|
178
|
+
declare const jGroup: (...args: any[]) => void;
|
|
179
|
+
/**
|
|
180
|
+
* jade console.groupCollapsed
|
|
181
|
+
*/
|
|
182
|
+
declare const jGroupC: (...args: any[]) => void;
|
|
183
|
+
/**
|
|
184
|
+
* jade console.groupEnd
|
|
185
|
+
*/
|
|
186
|
+
declare const jGroupE: {
|
|
187
|
+
(): void;
|
|
188
|
+
(): void;
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* jade console.time
|
|
192
|
+
* @param str
|
|
193
|
+
*/
|
|
194
|
+
declare const jTime: (str: string) => void;
|
|
195
|
+
/**
|
|
196
|
+
* jade console.timeEnd
|
|
197
|
+
* @param str
|
|
198
|
+
*/
|
|
199
|
+
declare const jTimeEnd: (str: string) => void;
|
|
200
|
+
/**
|
|
201
|
+
* jade console.clear
|
|
202
|
+
*/
|
|
203
|
+
declare const jClear: {
|
|
204
|
+
(): void;
|
|
205
|
+
(): void;
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* 数字或字符串
|
|
210
|
+
*/
|
|
211
|
+
declare type Numeric = number | string;
|
|
212
|
+
/**
|
|
213
|
+
* 可 Null
|
|
214
|
+
*/
|
|
215
|
+
declare type Nullable<T> = T | null;
|
|
216
|
+
/**
|
|
217
|
+
* 可 Undefined
|
|
218
|
+
*/
|
|
219
|
+
declare type Undefinable<T> = T | undefined;
|
|
220
|
+
/**
|
|
221
|
+
* 可 Null 或 Undefined
|
|
222
|
+
*/
|
|
223
|
+
declare type NullOrUndefinable<T> = Nullable<Undefinable<T>>;
|
|
224
|
+
/**
|
|
225
|
+
* alias for NullOrUndefinable
|
|
226
|
+
*/
|
|
227
|
+
declare type UnDef<T> = NullOrUndefinable<T>;
|
|
228
|
+
/**
|
|
229
|
+
* 请求结果
|
|
230
|
+
*/
|
|
231
|
+
declare type Res<T = any> = Service.Response<T>;
|
|
232
|
+
/**
|
|
233
|
+
* 分页请求结果数据
|
|
234
|
+
*/
|
|
235
|
+
declare type PageResData<T = any> = Service.PageResponseData<T>;
|
|
236
|
+
/**
|
|
237
|
+
* 分页请求结果
|
|
238
|
+
*/
|
|
239
|
+
declare type PageRes<T = any> = Service.PageResponse<T>;
|
|
240
|
+
/**
|
|
241
|
+
* 可能是数组
|
|
242
|
+
*/
|
|
243
|
+
declare type MaybeArray<T = any> = T | Array<T>;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* 隐藏中间部分
|
|
247
|
+
* @param {string} str 需要隐藏的字符串
|
|
248
|
+
*/
|
|
249
|
+
declare const hideMiddle: (str: UnDef<string>) => string;
|
|
250
|
+
/**
|
|
251
|
+
* 隐藏首尾仅保留中间3分之1
|
|
252
|
+
* @param {string} str 需要隐藏的字符串
|
|
253
|
+
*/
|
|
254
|
+
declare const hideThird: (str: UnDef<string>) => string;
|
|
255
|
+
/**
|
|
256
|
+
* 隐藏首部
|
|
257
|
+
* @param {string} str 需要隐藏的字符串
|
|
258
|
+
* @param {number} count 隐藏的字符数
|
|
259
|
+
*/
|
|
260
|
+
declare const hideHead: (str: UnDef<string>, count?: number) => string;
|
|
261
|
+
/**
|
|
262
|
+
* 隐藏尾部
|
|
263
|
+
* @param {string} str 需要隐藏的字符串
|
|
264
|
+
* @param {number} count 隐藏的字符数
|
|
265
|
+
*/
|
|
266
|
+
declare const hideTail: (str: UnDef<string>, count?: number) => string;
|
|
267
|
+
/**
|
|
268
|
+
* 隐藏手机号
|
|
269
|
+
* @param {string} phone 手机号
|
|
270
|
+
*/
|
|
271
|
+
declare const hidePhone: (phone: UnDef<string>) => string;
|
|
272
|
+
/**
|
|
273
|
+
* 隐藏身份证号
|
|
274
|
+
* @param {string} cardNo 身份证号
|
|
275
|
+
* @param {boolean} strong 是否强化隐藏
|
|
276
|
+
*/
|
|
277
|
+
declare const hideCardNo: (cardNo: UnDef<string>, strong?: boolean) => string;
|
|
278
|
+
/**
|
|
279
|
+
* 隐藏姓名第一个字
|
|
280
|
+
* @param {string} name 姓名
|
|
281
|
+
* @deprecated 请使用 hideSurname
|
|
282
|
+
*/
|
|
283
|
+
declare const hideName: (name: UnDef<string>) => string;
|
|
284
|
+
/**
|
|
285
|
+
* 隐藏姓氏
|
|
286
|
+
* @param {string} name 姓名
|
|
287
|
+
*/
|
|
288
|
+
declare const hideSurname: (name: UnDef<string>) => string;
|
|
289
|
+
/**
|
|
290
|
+
* 隐藏名字
|
|
291
|
+
* @param {string} name 姓名
|
|
292
|
+
*/
|
|
293
|
+
declare const hideFirstName: (name: UnDef<string>) => string;
|
|
294
|
+
/**
|
|
295
|
+
* 隐藏邮箱
|
|
296
|
+
* @param {string} email 邮箱
|
|
297
|
+
*/
|
|
298
|
+
declare const hideEmail: (email: UnDef<string>) => string;
|
|
299
|
+
/**
|
|
300
|
+
* 隐藏银行卡号
|
|
301
|
+
* @param {string} bankCard 银行卡号
|
|
302
|
+
*/
|
|
303
|
+
declare const hideBankCard: (bankCard: UnDef<string>) => string;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* 判断是否是浏览器环境
|
|
307
|
+
*/
|
|
308
|
+
declare const inBrowser: boolean;
|
|
309
|
+
/**
|
|
310
|
+
* 等待一段时间
|
|
311
|
+
* @param time
|
|
312
|
+
*/
|
|
313
|
+
declare const waitTime: (time?: number) => Promise<unknown>;
|
|
314
|
+
/**
|
|
315
|
+
* 防止 iOS 因输入框字体小于16px 而在 focus 时页面缩放变大需要手动回正的情况。
|
|
316
|
+
* iOS 10+ 允许 pinch-zoom, 即使 viewport 是不可伸缩的。
|
|
317
|
+
* 只对这些浏览器添加额外规则
|
|
318
|
+
*/
|
|
319
|
+
declare const fixiOSInputAutoZoomIn: () => void;
|
|
320
|
+
/**
|
|
321
|
+
* 用户代理
|
|
322
|
+
*/
|
|
323
|
+
declare const userAgent: string;
|
|
324
|
+
/**
|
|
325
|
+
* 获取宿主环境信息
|
|
326
|
+
*/
|
|
327
|
+
declare const getHostEnv: () => {
|
|
328
|
+
/**
|
|
329
|
+
* 是否是浙里办
|
|
330
|
+
*/
|
|
331
|
+
zlb: boolean;
|
|
332
|
+
/**
|
|
333
|
+
* 是否是专有钉
|
|
334
|
+
*/
|
|
335
|
+
zyd: boolean;
|
|
336
|
+
/**
|
|
337
|
+
* 是否是浙政钉
|
|
338
|
+
*/
|
|
339
|
+
zzd: boolean;
|
|
340
|
+
/**
|
|
341
|
+
* 是否是微信
|
|
342
|
+
*/
|
|
343
|
+
wx: boolean;
|
|
344
|
+
/**
|
|
345
|
+
* 是否是支付宝
|
|
346
|
+
*/
|
|
347
|
+
zfb: boolean;
|
|
348
|
+
/**
|
|
349
|
+
* 是否是小程序
|
|
350
|
+
*/
|
|
351
|
+
mini: boolean;
|
|
352
|
+
} | {
|
|
353
|
+
/**
|
|
354
|
+
* 是否是浙里办
|
|
355
|
+
*/
|
|
356
|
+
zlb: boolean;
|
|
357
|
+
/**
|
|
358
|
+
* 是否是专有钉
|
|
359
|
+
*/
|
|
360
|
+
zyd: boolean;
|
|
361
|
+
/**
|
|
362
|
+
* 是否是浙政钉
|
|
363
|
+
*/
|
|
364
|
+
zzd: boolean;
|
|
365
|
+
/**
|
|
366
|
+
* 是否是微信
|
|
367
|
+
*/
|
|
368
|
+
wx: boolean;
|
|
369
|
+
/**
|
|
370
|
+
* 是否是支付宝
|
|
371
|
+
*/
|
|
372
|
+
zfb: boolean;
|
|
373
|
+
/**
|
|
374
|
+
* 是否是小程序
|
|
375
|
+
*/
|
|
376
|
+
mini: boolean;
|
|
377
|
+
name: detect_browser.Browser;
|
|
378
|
+
version: string;
|
|
379
|
+
os: detect_browser.OperatingSystem | null;
|
|
380
|
+
type: "browser";
|
|
381
|
+
} | {
|
|
382
|
+
/**
|
|
383
|
+
* 是否是浙里办
|
|
384
|
+
*/
|
|
385
|
+
zlb: boolean;
|
|
386
|
+
/**
|
|
387
|
+
* 是否是专有钉
|
|
388
|
+
*/
|
|
389
|
+
zyd: boolean;
|
|
390
|
+
/**
|
|
391
|
+
* 是否是浙政钉
|
|
392
|
+
*/
|
|
393
|
+
zzd: boolean;
|
|
394
|
+
/**
|
|
395
|
+
* 是否是微信
|
|
396
|
+
*/
|
|
397
|
+
wx: boolean;
|
|
398
|
+
/**
|
|
399
|
+
* 是否是支付宝
|
|
400
|
+
*/
|
|
401
|
+
zfb: boolean;
|
|
402
|
+
/**
|
|
403
|
+
* 是否是小程序
|
|
404
|
+
*/
|
|
405
|
+
mini: boolean;
|
|
406
|
+
name: detect_browser.Browser;
|
|
407
|
+
version: string;
|
|
408
|
+
os: detect_browser.OperatingSystem | null;
|
|
409
|
+
bot: string;
|
|
410
|
+
type: "bot-device";
|
|
411
|
+
} | {
|
|
412
|
+
/**
|
|
413
|
+
* 是否是浙里办
|
|
414
|
+
*/
|
|
415
|
+
zlb: boolean;
|
|
416
|
+
/**
|
|
417
|
+
* 是否是专有钉
|
|
418
|
+
*/
|
|
419
|
+
zyd: boolean;
|
|
420
|
+
/**
|
|
421
|
+
* 是否是浙政钉
|
|
422
|
+
*/
|
|
423
|
+
zzd: boolean;
|
|
424
|
+
/**
|
|
425
|
+
* 是否是微信
|
|
426
|
+
*/
|
|
427
|
+
wx: boolean;
|
|
428
|
+
/**
|
|
429
|
+
* 是否是支付宝
|
|
430
|
+
*/
|
|
431
|
+
zfb: boolean;
|
|
432
|
+
/**
|
|
433
|
+
* 是否是小程序
|
|
434
|
+
*/
|
|
435
|
+
mini: boolean;
|
|
436
|
+
type: "bot";
|
|
437
|
+
bot: true;
|
|
438
|
+
name: "bot";
|
|
439
|
+
version: null;
|
|
440
|
+
os: null;
|
|
441
|
+
} | {
|
|
442
|
+
/**
|
|
443
|
+
* 是否是浙里办
|
|
444
|
+
*/
|
|
445
|
+
zlb: boolean;
|
|
446
|
+
/**
|
|
447
|
+
* 是否是专有钉
|
|
448
|
+
*/
|
|
449
|
+
zyd: boolean;
|
|
450
|
+
/**
|
|
451
|
+
* 是否是浙政钉
|
|
452
|
+
*/
|
|
453
|
+
zzd: boolean;
|
|
454
|
+
/**
|
|
455
|
+
* 是否是微信
|
|
456
|
+
*/
|
|
457
|
+
wx: boolean;
|
|
458
|
+
/**
|
|
459
|
+
* 是否是支付宝
|
|
460
|
+
*/
|
|
461
|
+
zfb: boolean;
|
|
462
|
+
/**
|
|
463
|
+
* 是否是小程序
|
|
464
|
+
*/
|
|
465
|
+
mini: boolean;
|
|
466
|
+
version: string;
|
|
467
|
+
type: "node";
|
|
468
|
+
name: "node";
|
|
469
|
+
os: NodeJS.Platform;
|
|
470
|
+
} | {
|
|
471
|
+
/**
|
|
472
|
+
* 是否是浙里办
|
|
473
|
+
*/
|
|
474
|
+
zlb: boolean;
|
|
475
|
+
/**
|
|
476
|
+
* 是否是专有钉
|
|
477
|
+
*/
|
|
478
|
+
zyd: boolean;
|
|
479
|
+
/**
|
|
480
|
+
* 是否是浙政钉
|
|
481
|
+
*/
|
|
482
|
+
zzd: boolean;
|
|
483
|
+
/**
|
|
484
|
+
* 是否是微信
|
|
485
|
+
*/
|
|
486
|
+
wx: boolean;
|
|
487
|
+
/**
|
|
488
|
+
* 是否是支付宝
|
|
489
|
+
*/
|
|
490
|
+
zfb: boolean;
|
|
491
|
+
/**
|
|
492
|
+
* 是否是小程序
|
|
493
|
+
*/
|
|
494
|
+
mini: boolean;
|
|
495
|
+
type: "react-native";
|
|
496
|
+
name: "react-native";
|
|
497
|
+
version: null;
|
|
498
|
+
os: null;
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Json字符串转对象
|
|
503
|
+
* @param str
|
|
504
|
+
* @param reviver
|
|
505
|
+
*/
|
|
506
|
+
declare const parseToJSON: <T = any>(str: string, reviver?: ((this: any, key: string, value: any) => any) | undefined) => Nullable<T>;
|
|
507
|
+
/**
|
|
508
|
+
* JSON.stringify() second param
|
|
509
|
+
* @param _
|
|
510
|
+
* @param value
|
|
511
|
+
*/
|
|
512
|
+
declare const replacer: (_: any, value: any) => any;
|
|
513
|
+
/**
|
|
514
|
+
* JSON.parse() second param
|
|
515
|
+
* @param _
|
|
516
|
+
* @param value
|
|
517
|
+
*/
|
|
518
|
+
declare const reviver: (_: any, value: any) => any;
|
|
519
|
+
/**
|
|
520
|
+
* 过滤obj中仅包括keys的部分
|
|
521
|
+
* @param {Record<string,any>} obj 对象
|
|
522
|
+
* @param {string[]} keys 属性
|
|
523
|
+
* @param {boolean} reverse 为true时过滤取反
|
|
524
|
+
*/
|
|
525
|
+
declare const filterObj: (obj: Record<string, any>, keys: string[], reverse?: boolean) => {
|
|
526
|
+
[k: string]: any;
|
|
527
|
+
};
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* 格式化时间
|
|
531
|
+
* @param {import('dayjs').ConfigType} date 时间
|
|
532
|
+
* @param {string} format 格式
|
|
533
|
+
* @returns {string} 格式化后的时间
|
|
534
|
+
*/
|
|
535
|
+
declare const dateFmt: (date: ConfigType, format?: string | 'date' | 'datetime') => string;
|
|
536
|
+
/**
|
|
537
|
+
* 格式化时间间隔
|
|
538
|
+
* @param {import('dayjs').ConfigType} start 开始时间
|
|
539
|
+
* @param {import('dayjs').ConfigType} end 结束时间
|
|
540
|
+
*/
|
|
541
|
+
declare const dateDuration: (start: ConfigType, end: ConfigType) => string;
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* 设置文件基本路径
|
|
545
|
+
* @param key
|
|
546
|
+
* @param baseUrl
|
|
547
|
+
*/
|
|
548
|
+
declare function setBaseAttachUrl(baseUrl: string): void;
|
|
549
|
+
/**
|
|
550
|
+
* 获取文件基本路径
|
|
551
|
+
*/
|
|
552
|
+
declare function getBaseAttachUrl(): string;
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* 千位分隔符
|
|
556
|
+
* @param num
|
|
557
|
+
*/
|
|
558
|
+
declare const toThousands: (num: number) => string | undefined;
|
|
559
|
+
/**
|
|
560
|
+
* 货币格式化
|
|
561
|
+
* @param currency
|
|
562
|
+
* @param fraction
|
|
563
|
+
*/
|
|
564
|
+
declare const currencyFmt: (currency: UnDef<number | bigint>, fraction?: number) => string;
|
|
565
|
+
|
|
566
|
+
type VantUploadFileStatus = '' | 'uploading' | 'done' | 'failed'
|
|
567
|
+
type AntdUploadFileStatus = 'removed' | 'uploading' | 'done' | 'error'
|
|
568
|
+
type ElementPlusUploadFileStatus = 'ready' | 'uploading' | 'success' | 'fail'
|
|
569
|
+
|
|
570
|
+
interface Resource {
|
|
571
|
+
/** origin */
|
|
572
|
+
group: string
|
|
573
|
+
id: string
|
|
574
|
+
name: string
|
|
575
|
+
uri: string
|
|
576
|
+
/** extend */
|
|
577
|
+
url?: string
|
|
578
|
+
size?: number
|
|
579
|
+
uid?: string
|
|
580
|
+
status?: VantUploadFileStatus | AntdUploadFileStatus | ElementPlusUploadFileStatus
|
|
581
|
+
/** vant */
|
|
582
|
+
objectUrl?: string
|
|
583
|
+
content?: string
|
|
584
|
+
isImage?: boolean
|
|
585
|
+
message?: string
|
|
586
|
+
deletable?: boolean
|
|
587
|
+
reupload?: boolean
|
|
588
|
+
/** antd */
|
|
589
|
+
fileName?: string
|
|
590
|
+
percent?: number
|
|
591
|
+
thumbUrl?: string
|
|
592
|
+
/** element-plus */
|
|
593
|
+
percentage?: number
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* 获取文件完整地址
|
|
598
|
+
* @param url
|
|
599
|
+
*/
|
|
600
|
+
declare const resUrl: (url: Undefinable<string>) => string | undefined;
|
|
601
|
+
/**
|
|
602
|
+
* 统一文件字段内容
|
|
603
|
+
* @param resource
|
|
604
|
+
*/
|
|
605
|
+
declare const recoverFile: (resource: Resource) => {
|
|
606
|
+
url: string | undefined;
|
|
607
|
+
content: string | undefined;
|
|
608
|
+
uri: string;
|
|
609
|
+
status: string;
|
|
610
|
+
percent: number;
|
|
611
|
+
group: string;
|
|
612
|
+
id: string;
|
|
613
|
+
name: string;
|
|
614
|
+
size?: number | undefined;
|
|
615
|
+
uid?: string | undefined;
|
|
616
|
+
objectUrl?: string | undefined;
|
|
617
|
+
isImage?: boolean | undefined;
|
|
618
|
+
message?: string | undefined;
|
|
619
|
+
deletable?: boolean | undefined;
|
|
620
|
+
reupload?: boolean | undefined;
|
|
621
|
+
fileName?: string | undefined;
|
|
622
|
+
thumbUrl?: string | undefined; /**
|
|
623
|
+
* 统一文件字段内容
|
|
624
|
+
* @param resource
|
|
625
|
+
*/
|
|
626
|
+
percentage?: number | undefined;
|
|
627
|
+
};
|
|
628
|
+
/**
|
|
629
|
+
* 附件格式
|
|
630
|
+
* @param data
|
|
631
|
+
*/
|
|
632
|
+
declare const attachFmt: (data: UnDef<MaybeArray<Resource>> | string) => {
|
|
633
|
+
url: string | undefined;
|
|
634
|
+
content: string | undefined;
|
|
635
|
+
uri: string;
|
|
636
|
+
status: string;
|
|
637
|
+
percent: number;
|
|
638
|
+
group: string;
|
|
639
|
+
id: string;
|
|
640
|
+
name: string;
|
|
641
|
+
size?: number | undefined;
|
|
642
|
+
uid?: string | undefined;
|
|
643
|
+
objectUrl?: string | undefined;
|
|
644
|
+
isImage?: boolean | undefined;
|
|
645
|
+
message?: string | undefined;
|
|
646
|
+
deletable?: boolean | undefined;
|
|
647
|
+
reupload?: boolean | undefined;
|
|
648
|
+
fileName?: string | undefined;
|
|
649
|
+
thumbUrl?: string | undefined; /**
|
|
650
|
+
* 统一文件字段内容
|
|
651
|
+
* @param resource
|
|
652
|
+
*/
|
|
653
|
+
percentage?: number | undefined;
|
|
654
|
+
}[];
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* 是否有意义的值
|
|
658
|
+
* @param val
|
|
659
|
+
*/
|
|
660
|
+
declare const isDef: <T>(val: T) => val is NonNullable<T>;
|
|
661
|
+
/**
|
|
662
|
+
* 是否是数字或字符
|
|
663
|
+
* @param val
|
|
664
|
+
*/
|
|
665
|
+
declare const isNumeric: (val: Numeric) => val is string;
|
|
666
|
+
/**
|
|
667
|
+
* 是否是需要的图片格式
|
|
668
|
+
* @param ext
|
|
669
|
+
*/
|
|
670
|
+
declare const checkImg: (ext?: string) => boolean;
|
|
671
|
+
/**
|
|
672
|
+
* 是否是空值/空数组/空对象 null undefined '' [] {} Set Map
|
|
673
|
+
* @param val
|
|
674
|
+
*/
|
|
675
|
+
declare const isEmpty: (val: UnDef<Numeric | boolean | Record<any, any> | Array<any> | Set<any> | Map<any, any>>) => boolean;
|
|
676
|
+
/**
|
|
677
|
+
* 判断是否合法JSON字符串
|
|
678
|
+
* @param str
|
|
679
|
+
*/
|
|
680
|
+
declare const isJSONStr: (str: string) => boolean;
|
|
681
|
+
/**
|
|
682
|
+
* 判断是否合法JSON数组字符串
|
|
683
|
+
* @param str
|
|
684
|
+
*/
|
|
685
|
+
declare const isArrStr: (str: string) => boolean;
|
|
686
|
+
/**
|
|
687
|
+
* 判断是否有效的key
|
|
688
|
+
* @param {string | number | symbol} key 键名
|
|
689
|
+
* @param {object} object 对象
|
|
690
|
+
* @example
|
|
691
|
+
*
|
|
692
|
+
* ```ts
|
|
693
|
+
* const obj = { a: 1, b: 2 }
|
|
694
|
+
* isValidKey('a', obj) // true
|
|
695
|
+
* ```
|
|
696
|
+
* @returns {boolean} boolean
|
|
697
|
+
*/
|
|
698
|
+
declare const isValidKey: (key: string | number | symbol, object: object) => key is never;
|
|
699
|
+
/**
|
|
700
|
+
* 是否是中国手机号
|
|
701
|
+
* @param val
|
|
702
|
+
*/
|
|
703
|
+
declare const isPhone: (val: UnDef<Numeric>) => boolean;
|
|
704
|
+
/**
|
|
705
|
+
* 是否是中国座机号
|
|
706
|
+
* @param val
|
|
707
|
+
*/
|
|
708
|
+
declare const isTel: (val: UnDef<Numeric>) => boolean;
|
|
709
|
+
/**
|
|
710
|
+
* 是否是邮箱
|
|
711
|
+
* @param val
|
|
712
|
+
*/
|
|
713
|
+
declare const isEmail: (val: UnDef<string>) => boolean;
|
|
714
|
+
/**
|
|
715
|
+
* 是否是身份证
|
|
716
|
+
* @param {string|null|undefined} val 身份证号
|
|
717
|
+
* @param {boolean} compatible 兼容15位
|
|
718
|
+
*/
|
|
719
|
+
declare const isIdCard: (val: UnDef<string>, compatible?: boolean) => boolean;
|
|
720
|
+
/**
|
|
721
|
+
* 包含非ASCII字符
|
|
722
|
+
* @param text
|
|
723
|
+
*/
|
|
724
|
+
declare const nonASCII: (text: string) => boolean;
|
|
725
|
+
/**
|
|
726
|
+
* 校验接口返回code
|
|
727
|
+
* @param res
|
|
728
|
+
* @param code
|
|
729
|
+
*/
|
|
730
|
+
declare const isValidResCode: (res: Res, code?: number) => boolean;
|
|
731
|
+
/**
|
|
732
|
+
* 校验接口返回内容
|
|
733
|
+
* @param res
|
|
734
|
+
* @param code
|
|
735
|
+
*/
|
|
736
|
+
declare const isValidRes: (res: Res, code?: number) => boolean;
|
|
737
|
+
/**
|
|
738
|
+
* 校验接口数组返回内容
|
|
739
|
+
* @param res
|
|
740
|
+
* @param code
|
|
741
|
+
*/
|
|
742
|
+
declare const isValidArrRes: (res: Res<any[]>, code?: number) => boolean;
|
|
743
|
+
/**
|
|
744
|
+
* 校验接口分页返回内容
|
|
745
|
+
* @param res
|
|
746
|
+
* @param code
|
|
747
|
+
*/
|
|
748
|
+
declare const isValidPageRes: (res: PageRes, code?: number) => boolean;
|
|
749
|
+
/**
|
|
750
|
+
* 校验文件类型
|
|
751
|
+
* 1. XXX/YYY 2. .xxx 3. XXX/* 4.*
|
|
752
|
+
* @param {File} file 需要校验的文件
|
|
753
|
+
* @param {string} type 文件类型, 与input.accept一致
|
|
754
|
+
*/
|
|
755
|
+
declare const isValidFileType: (file: File, type: string) => boolean;
|
|
756
|
+
|
|
757
|
+
export { type MaybeArray, type NullOrUndefinable, type Nullable, type Numeric, type PageRes, type PageResData, type Res, type UnDef, type Undefinable, attachFmt, camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, currencyFmt, dateDuration, dateFmt, filterObj, fixiOSInputAutoZoomIn, getBaseAttachUrl, getHostEnv, hideBankCard, hideCardNo, hideEmail, hideFirstName, hideHead, hideMiddle, hideName, hidePhone, hideSurname, hideTail, hideThird, inBrowser, isArrStr, isDef, isEmail, isEmpty, isIdCard, isJSONStr, isNumeric, isPhone, isTel, isValidArrRes, isValidFileType, isValidKey, isValidPageRes, isValidRes, isValidResCode, jClear, jDebug, jError, jGroup, jGroupC, jGroupE, jInfo, jLog, jTime, jTimeEnd, jWarn, kebab2Camel, kebab2Pascal, kebab2Snake, kebab2Title, nonASCII, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, recoverFile, replacer, resUrl, reviver, setBaseAttachUrl, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, title2Camel, title2Kebab, title2Pascal, title2Snake, toThousands, userAgent, waitTime };
|