@whitesev/utils 1.2.0 → 1.2.2
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.amd.js.map +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/src/Httpx.d.ts +2 -2
- package/dist/src/Utils.d.ts +43 -1
- package/package.json +1 -1
- package/src/Httpx.ts +2 -2
- package/src/Utils.ts +47 -8
package/dist/src/Httpx.d.ts
CHANGED
|
@@ -1028,7 +1028,7 @@ export declare interface HttpxDetailsConfig extends HttpxDetails {
|
|
|
1028
1028
|
/**
|
|
1029
1029
|
* 响应的数据的data
|
|
1030
1030
|
*/
|
|
1031
|
-
export declare interface HttpxAsyncResultData<T
|
|
1031
|
+
export declare interface HttpxAsyncResultData<T = HttpxDetails> {
|
|
1032
1032
|
/**
|
|
1033
1033
|
* 如果fetch为true,且返回的headers中的Content-Type存在text/event-stream或者是主动设置的responseType为stream
|
|
1034
1034
|
* 则存在该属性为true
|
|
@@ -1089,7 +1089,7 @@ export declare interface HttpxAsyncResultData<T extends HttpxDetails> {
|
|
|
1089
1089
|
/**
|
|
1090
1090
|
* 响应的数据
|
|
1091
1091
|
*/
|
|
1092
|
-
export declare interface HttpxAsyncResult<T
|
|
1092
|
+
export declare interface HttpxAsyncResult<T = HttpxDetails> {
|
|
1093
1093
|
/**
|
|
1094
1094
|
* 请求状态,状态码为200为成功true,否则false
|
|
1095
1095
|
*/
|
package/dist/src/Utils.d.ts
CHANGED
|
@@ -309,7 +309,30 @@ declare class Utils {
|
|
|
309
309
|
* Utils.formatTime()
|
|
310
310
|
* > '2023-1-1 00:00:00'
|
|
311
311
|
**/
|
|
312
|
-
formatTime(text?: string | number | Date, formatType?:
|
|
312
|
+
formatTime(text?: string | number | Date, formatType?: string): string;
|
|
313
|
+
/**
|
|
314
|
+
* 获取格式化后的时间
|
|
315
|
+
* @param text (可选)需要格式化的字符串或者时间戳,默认:new Date()
|
|
316
|
+
* @param formatType (可选)格式化成的显示类型,默认:yyyy-MM-dd HH:mm:ss
|
|
317
|
+
* + yyyy 年
|
|
318
|
+
* + MM 月
|
|
319
|
+
* + dd 天
|
|
320
|
+
* + HH 时 (24小时制)
|
|
321
|
+
* + hh 时 (12小时制)
|
|
322
|
+
* + mm 分
|
|
323
|
+
* + ss 秒
|
|
324
|
+
* @returns {string} 返回格式化后的时间
|
|
325
|
+
* @example
|
|
326
|
+
* Utils.formatTime("2022-08-21 23:59:00","HH:mm:ss");
|
|
327
|
+
* > '23:59:00'
|
|
328
|
+
* @example
|
|
329
|
+
* Utils.formatTime(1899187424988,"HH:mm:ss");
|
|
330
|
+
* > '15:10:13'
|
|
331
|
+
* @example
|
|
332
|
+
* Utils.formatTime()
|
|
333
|
+
* > '2023-1-1 00:00:00'
|
|
334
|
+
**/
|
|
335
|
+
formatTime(text?: string | number | Date, formatType?: "yyyy-MM-dd HH:mm:ss" | "yyyy/MM/dd HH:mm:ss" | "yyyy_MM_dd_HH_mm_ss" | "yyyy年MM月dd日 HH时mm分ss秒" | "yyyy年MM月dd日 hh:mm:ss" | "yyyy年MM月dd日 HH:mm:ss" | "yyyy-MM-dd" | "yyyyMMdd" | "HH:mm:ss"): string;
|
|
313
336
|
/**
|
|
314
337
|
* 字符串格式的时间转时间戳
|
|
315
338
|
* @param text 字符串格式的时间,例如:
|
|
@@ -1506,6 +1529,25 @@ declare class Utils {
|
|
|
1506
1529
|
* })
|
|
1507
1530
|
*/
|
|
1508
1531
|
waitNodeList<T extends HTMLElement>(nodeSelector: string): Promise<T>;
|
|
1532
|
+
/**
|
|
1533
|
+
* 等待指定元素出现
|
|
1534
|
+
* @param nodeSelectors
|
|
1535
|
+
* @returns 当nodeSelectors为数组多个时,
|
|
1536
|
+
* 返回如:[ NodeList, NodeList ],
|
|
1537
|
+
* 当nodeSelectors为单个时,
|
|
1538
|
+
* 返回如:NodeList。
|
|
1539
|
+
* NodeList元素与页面存在强绑定,当已获取该NodeList,但是页面中却删除了,该元素在NodeList中会被自动删除
|
|
1540
|
+
* @example
|
|
1541
|
+
* Utils.waitNodeList("div.xxx").then( nodeList =>{
|
|
1542
|
+
* console.log(nodeList) // div.xxx => NodeList
|
|
1543
|
+
* })
|
|
1544
|
+
* @example
|
|
1545
|
+
* Utils.waitNodeList("div.xxx","a.xxx").then( nodeListArray =>{
|
|
1546
|
+
* console.log(nodeListArray[0]) // div.xxx => NodeList
|
|
1547
|
+
* console.log(nodeListArray[1]) // a.xxx => NodeList
|
|
1548
|
+
* })
|
|
1549
|
+
*/
|
|
1550
|
+
waitNodeList<T extends HTMLElement[]>(nodeSelector: string): Promise<T>;
|
|
1509
1551
|
/**
|
|
1510
1552
|
* 等待指定元素出现,支持多个selector
|
|
1511
1553
|
* @param nodeSelectors
|
package/package.json
CHANGED
package/src/Httpx.ts
CHANGED
|
@@ -1124,7 +1124,7 @@ export declare interface HttpxDetailsConfig extends HttpxDetails {
|
|
|
1124
1124
|
/**
|
|
1125
1125
|
* 响应的数据的data
|
|
1126
1126
|
*/
|
|
1127
|
-
export declare interface HttpxAsyncResultData<T
|
|
1127
|
+
export declare interface HttpxAsyncResultData<T = HttpxDetails> {
|
|
1128
1128
|
/**
|
|
1129
1129
|
* 如果fetch为true,且返回的headers中的Content-Type存在text/event-stream或者是主动设置的responseType为stream
|
|
1130
1130
|
* 则存在该属性为true
|
|
@@ -1185,7 +1185,7 @@ export declare interface HttpxAsyncResultData<T extends HttpxDetails> {
|
|
|
1185
1185
|
/**
|
|
1186
1186
|
* 响应的数据
|
|
1187
1187
|
*/
|
|
1188
|
-
export declare interface HttpxAsyncResult<T
|
|
1188
|
+
export declare interface HttpxAsyncResult<T = HttpxDetails> {
|
|
1189
1189
|
/**
|
|
1190
1190
|
* 请求状态,状态码为200为成功true,否则false
|
|
1191
1191
|
*/
|
package/src/Utils.ts
CHANGED
|
@@ -807,6 +807,29 @@ class Utils {
|
|
|
807
807
|
}
|
|
808
808
|
return resultValue;
|
|
809
809
|
}
|
|
810
|
+
/**
|
|
811
|
+
* 获取格式化后的时间
|
|
812
|
+
* @param text (可选)需要格式化的字符串或者时间戳,默认:new Date()
|
|
813
|
+
* @param formatType (可选)格式化成的显示类型,默认:yyyy-MM-dd HH:mm:ss
|
|
814
|
+
* + yyyy 年
|
|
815
|
+
* + MM 月
|
|
816
|
+
* + dd 天
|
|
817
|
+
* + HH 时 (24小时制)
|
|
818
|
+
* + hh 时 (12小时制)
|
|
819
|
+
* + mm 分
|
|
820
|
+
* + ss 秒
|
|
821
|
+
* @returns {string} 返回格式化后的时间
|
|
822
|
+
* @example
|
|
823
|
+
* Utils.formatTime("2022-08-21 23:59:00","HH:mm:ss");
|
|
824
|
+
* > '23:59:00'
|
|
825
|
+
* @example
|
|
826
|
+
* Utils.formatTime(1899187424988,"HH:mm:ss");
|
|
827
|
+
* > '15:10:13'
|
|
828
|
+
* @example
|
|
829
|
+
* Utils.formatTime()
|
|
830
|
+
* > '2023-1-1 00:00:00'
|
|
831
|
+
**/
|
|
832
|
+
formatTime(text?: string | number | Date, formatType?: string): string;
|
|
810
833
|
/**
|
|
811
834
|
* 获取格式化后的时间
|
|
812
835
|
* @param text (可选)需要格式化的字符串或者时间戳,默认:new Date()
|
|
@@ -834,11 +857,12 @@ class Utils {
|
|
|
834
857
|
formatType?:
|
|
835
858
|
| "yyyy-MM-dd HH:mm:ss"
|
|
836
859
|
| "yyyy/MM/dd HH:mm:ss"
|
|
837
|
-
| "yyyy年MM月dd日 HH时mm分ss秒"
|
|
838
|
-
| "yyyyMMdd"
|
|
839
860
|
| "yyyy_MM_dd_HH_mm_ss"
|
|
861
|
+
| "yyyy年MM月dd日 HH时mm分ss秒"
|
|
840
862
|
| "yyyy年MM月dd日 hh:mm:ss"
|
|
863
|
+
| "yyyy年MM月dd日 HH:mm:ss"
|
|
841
864
|
| "yyyy-MM-dd"
|
|
865
|
+
| "yyyyMMdd"
|
|
842
866
|
| "HH:mm:ss"
|
|
843
867
|
): string;
|
|
844
868
|
formatTime(text = new Date(), formatType = "yyyy-MM-dd HH:mm:ss") {
|
|
@@ -4155,6 +4179,25 @@ class Utils {
|
|
|
4155
4179
|
* })
|
|
4156
4180
|
*/
|
|
4157
4181
|
waitNodeList<T extends HTMLElement>(nodeSelector: string): Promise<T>;
|
|
4182
|
+
/**
|
|
4183
|
+
* 等待指定元素出现
|
|
4184
|
+
* @param nodeSelectors
|
|
4185
|
+
* @returns 当nodeSelectors为数组多个时,
|
|
4186
|
+
* 返回如:[ NodeList, NodeList ],
|
|
4187
|
+
* 当nodeSelectors为单个时,
|
|
4188
|
+
* 返回如:NodeList。
|
|
4189
|
+
* NodeList元素与页面存在强绑定,当已获取该NodeList,但是页面中却删除了,该元素在NodeList中会被自动删除
|
|
4190
|
+
* @example
|
|
4191
|
+
* Utils.waitNodeList("div.xxx").then( nodeList =>{
|
|
4192
|
+
* console.log(nodeList) // div.xxx => NodeList
|
|
4193
|
+
* })
|
|
4194
|
+
* @example
|
|
4195
|
+
* Utils.waitNodeList("div.xxx","a.xxx").then( nodeListArray =>{
|
|
4196
|
+
* console.log(nodeListArray[0]) // div.xxx => NodeList
|
|
4197
|
+
* console.log(nodeListArray[1]) // a.xxx => NodeList
|
|
4198
|
+
* })
|
|
4199
|
+
*/
|
|
4200
|
+
waitNodeList<T extends HTMLElement[]>(nodeSelector: string): Promise<T>;
|
|
4158
4201
|
/**
|
|
4159
4202
|
* 等待指定元素出现,支持多个selector
|
|
4160
4203
|
* @param nodeSelectors
|
|
@@ -4407,18 +4450,14 @@ class Utils {
|
|
|
4407
4450
|
* )
|
|
4408
4451
|
*/
|
|
4409
4452
|
waitVueByInterval(
|
|
4410
|
-
element:
|
|
4411
|
-
| HTMLElement
|
|
4412
|
-
| (() => any),
|
|
4453
|
+
element: HTMLElement | (() => any),
|
|
4413
4454
|
propertyName: string | ((__vue__: any) => boolean),
|
|
4414
4455
|
timer?: number,
|
|
4415
4456
|
maxTime?: number,
|
|
4416
4457
|
vueName?: "__vue__" | string
|
|
4417
4458
|
): Promise<boolean>;
|
|
4418
4459
|
async waitVueByInterval(
|
|
4419
|
-
element:
|
|
4420
|
-
| HTMLElement
|
|
4421
|
-
| (() => any),
|
|
4460
|
+
element: HTMLElement | (() => any),
|
|
4422
4461
|
propertyName: string | ((__vue__: any) => boolean),
|
|
4423
4462
|
timer = 250,
|
|
4424
4463
|
maxTime = -1,
|