@indfnd/utils 0.1.27 → 0.1.29
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/CHANGELOG.md +10 -0
- package/dist/ind-utils.es.js +323 -367
- package/dist/ind-utils.umd.cjs +19 -19
- package/package.json +1 -1
- package/src/utils/request/index.ts +13 -5
- package/types/api/com.d.ts +2 -2
- package/types/api/com.d.ts.map +1 -1
- package/types/api/index-desc.d.ts +2 -2
- package/types/api/index-desc.d.ts.map +1 -1
- package/types/api/item.d.ts +4 -4
- package/types/api/item.d.ts.map +1 -1
- package/types/api/platform/dict.d.ts +4 -4
- package/types/api/platform/dict.d.ts.map +1 -1
- package/types/api/platform/menu.d.ts +11 -17
- package/types/api/platform/menu.d.ts.map +1 -1
- package/types/api/platform/oss.d.ts +7 -15
- package/types/api/platform/oss.d.ts.map +1 -1
- package/types/api/platform/user.d.ts +12 -17
- package/types/api/platform/user.d.ts.map +1 -1
- package/types/api/user.d.ts +2 -2
- package/types/api/user.d.ts.map +1 -1
- package/types/utils/request/index.d.ts +2 -1
- package/types/utils/request/index.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import axios from 'axios'
|
|
2
2
|
import type { AxiosExtendsInstance } from './axios.extends'
|
|
3
|
-
import { requestInterceptors, responseInterceptors
|
|
3
|
+
import { inspectorError, requestInterceptors, responseInterceptors } from './interceptors'
|
|
4
4
|
import { CONTENT_TYPE, setContentType } from './content-type'
|
|
5
5
|
|
|
6
6
|
export * from './url-params'
|
|
@@ -21,9 +21,10 @@ instance.formPost = function (url, data, config) {
|
|
|
21
21
|
* 即上一次发起的网络请求将调用浏览器取消网络请求
|
|
22
22
|
* 注意:如果serviceApi是多个组件共同使用时,需要慎重使用本方法,避免导致由于请求被取消导致的功能异常
|
|
23
23
|
* @param {Function} api - 需要封装的API函数
|
|
24
|
+
* @param {boolean} isPost - 是否是post请求
|
|
24
25
|
* @returns {Function} 封装后可取消的api
|
|
25
26
|
*/
|
|
26
|
-
export const wrapApi = (api) => {
|
|
27
|
+
export const wrapApi = (api, isPost = false) => {
|
|
27
28
|
// 每个函数都有自己的 controller,避免互相干扰
|
|
28
29
|
let currentController = null
|
|
29
30
|
|
|
@@ -43,10 +44,13 @@ export const wrapApi = (api) => {
|
|
|
43
44
|
const newArgs = [...args]
|
|
44
45
|
const lastIndex = newArgs.length - 1
|
|
45
46
|
|
|
47
|
+
// 如果isPost是true,如果参数只有一个和两个,需要新增config参数,如果参数有三个,需要往最后一个参数增加signal
|
|
48
|
+
// 如果isPost是false,如果参数只有一个,需要新增config参数,如果参数有个,需要往最后一个参数增加signal
|
|
49
|
+
|
|
46
50
|
try {
|
|
47
51
|
// 处理配置参数
|
|
48
52
|
if (
|
|
49
|
-
|
|
53
|
+
(isPost ? lastIndex > 1 : lastIndex > 0) &&
|
|
50
54
|
typeof newArgs[lastIndex] === 'object' &&
|
|
51
55
|
!Array.isArray(newArgs[lastIndex])
|
|
52
56
|
) {
|
|
@@ -81,6 +85,9 @@ export const wrapApi = (api) => {
|
|
|
81
85
|
signal: controller.signal,
|
|
82
86
|
}
|
|
83
87
|
}
|
|
88
|
+
} else if (isPost && lastIndex === 0) {
|
|
89
|
+
// 没有配置对象且没有data,添加一个
|
|
90
|
+
newArgs.push(null, { signal: controller.signal })
|
|
84
91
|
} else {
|
|
85
92
|
// 没有配置对象,添加一个
|
|
86
93
|
newArgs.push({ signal: controller.signal })
|
|
@@ -129,8 +136,9 @@ export const wrapApi = (api) => {
|
|
|
129
136
|
}
|
|
130
137
|
|
|
131
138
|
// 对axios进行封装,返回单例模式的Api
|
|
139
|
+
|
|
132
140
|
instance.getSingleton = wrapApi(instance.get)
|
|
133
|
-
instance.postSingleton = wrapApi(instance.post)
|
|
134
|
-
instance.formPostSingleton = wrapApi(instance.formPost)
|
|
141
|
+
instance.postSingleton = wrapApi(instance.post, true)
|
|
142
|
+
instance.formPostSingleton = wrapApi(instance.formPost, true)
|
|
135
143
|
|
|
136
144
|
export { instance as axios }
|
package/types/api/com.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function listComTreeApi(params: any): Promise<import(
|
|
2
|
-
//# sourceMappingURL=com.d.ts.map
|
|
1
|
+
export declare function listComTreeApi(params: any): Promise<import("axios").AxiosResponse<any, any>>;
|
|
2
|
+
//# sourceMappingURL=com.d.ts.map
|
package/types/api/com.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"com.d.ts","sourceRoot":"","sources":["../../src/api/com.ts"],"names":[],"mappings":"AAKA,wBAAgB,cAAc,CAAC,MAAM,KAAA
|
|
1
|
+
{"version":3,"file":"com.d.ts","sourceRoot":"","sources":["../../src/api/com.ts"],"names":[],"mappings":"AAKA,wBAAgB,cAAc,CAAC,MAAM,KAAA,oDAKpC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function listIndexDescApi(params: any): Promise<import(
|
|
2
|
-
//# sourceMappingURL=index-desc.d.ts.map
|
|
1
|
+
export declare function listIndexDescApi(params: any): Promise<import("axios").AxiosResponse<any, any>>;
|
|
2
|
+
//# sourceMappingURL=index-desc.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-desc.d.ts","sourceRoot":"","sources":["../../src/api/index-desc.ts"],"names":[],"mappings":"AAKA,wBAAgB,gBAAgB,CAAC,MAAM,KAAA
|
|
1
|
+
{"version":3,"file":"index-desc.d.ts","sourceRoot":"","sources":["../../src/api/index-desc.ts"],"names":[],"mappings":"AAKA,wBAAgB,gBAAgB,CAAC,MAAM,KAAA,oDAEtC"}
|
package/types/api/item.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function listItemTreeApi(params: any): Promise<import(
|
|
2
|
-
export declare function getPriceInfo(): Promise<import(
|
|
3
|
-
export declare function getItem(params: any): Promise<import(
|
|
4
|
-
//# sourceMappingURL=item.d.ts.map
|
|
1
|
+
export declare function listItemTreeApi(params: any): Promise<import("axios").AxiosResponse<any, any>>;
|
|
2
|
+
export declare function getPriceInfo(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
3
|
+
export declare function getItem(params: any): Promise<import("axios").AxiosResponse<any, any>>;
|
|
4
|
+
//# sourceMappingURL=item.d.ts.map
|
package/types/api/item.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../src/api/item.ts"],"names":[],"mappings":"AAKA,wBAAgB,eAAe,CAAC,MAAM,KAAA
|
|
1
|
+
{"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../src/api/item.ts"],"names":[],"mappings":"AAKA,wBAAgB,eAAe,CAAC,MAAM,KAAA,oDAOrC;AACD,wBAAgB,YAAY,qDAE3B;AACD,wBAAgB,OAAO,CAAC,MAAM,KAAA,oDAE7B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function getDictsMapApi(dictId: string): Promise<import(
|
|
2
|
-
export declare function getDictApi(dictId: string): Promise<any
|
|
3
|
-
export declare function getDictMapApi(dictIdArr: string[]): Promise<{}
|
|
4
|
-
//# sourceMappingURL=dict.d.ts.map
|
|
1
|
+
export declare function getDictsMapApi(dictId: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
2
|
+
export declare function getDictApi(dictId: string): Promise<any>;
|
|
3
|
+
export declare function getDictMapApi(dictIdArr: string[]): Promise<{}>;
|
|
4
|
+
//# sourceMappingURL=dict.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dict.d.ts","sourceRoot":"","sources":["../../../src/api/platform/dict.ts"],"names":[],"mappings":"AAMA,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM
|
|
1
|
+
{"version":3,"file":"dict.d.ts","sourceRoot":"","sources":["../../../src/api/platform/dict.ts"],"names":[],"mappings":"AAMA,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,oDAE5C;AAED,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,gBAgB9C;AAkBD,wBAAsB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,eActD"}
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
export declare function getPermissionApi(): Promise<import(
|
|
2
|
-
export declare function getMenuHistoryApi(): Promise<import(
|
|
3
|
-
export declare function menuHistoryApi(params: any): Promise<import(
|
|
4
|
-
export declare function deleteMenuHistoryApi(
|
|
5
|
-
|
|
6
|
-
): Promise<import(
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export declare function removeMenuCollectApi(
|
|
13
|
-
params: any,
|
|
14
|
-
): Promise<import('axios').AxiosResponse<any>>
|
|
15
|
-
export declare function getAppListApi(): Promise<import('axios').AxiosResponse<any>>
|
|
16
|
-
export declare function getMaxTabNumValueApi(): Promise<import('axios').AxiosResponse<any>>
|
|
17
|
-
//# sourceMappingURL=menu.d.ts.map
|
|
1
|
+
export declare function getPermissionApi(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
2
|
+
export declare function getMenuHistoryApi(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
3
|
+
export declare function menuHistoryApi(params: any): Promise<import("axios").AxiosResponse<any, any>>;
|
|
4
|
+
export declare function deleteMenuHistoryApi(historyId: any): Promise<import("axios").AxiosResponse<any, any>>;
|
|
5
|
+
export declare function getMenuCollectApi(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
6
|
+
export declare function addMenuCollectApi(params: any): Promise<import("axios").AxiosResponse<any, any>>;
|
|
7
|
+
export declare function deleteMenuCollectApi(collectId: any): Promise<import("axios").AxiosResponse<any, any>>;
|
|
8
|
+
export declare function removeMenuCollectApi(params: any): Promise<import("axios").AxiosResponse<any, any>>;
|
|
9
|
+
export declare function getAppListApi(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
10
|
+
export declare function getMaxTabNumValueApi(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
11
|
+
//# sourceMappingURL=menu.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu.d.ts","sourceRoot":"","sources":["../../../src/api/platform/menu.ts"],"names":[],"mappings":"AAKA,wBAAgB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"menu.d.ts","sourceRoot":"","sources":["../../../src/api/platform/menu.ts"],"names":[],"mappings":"AAKA,wBAAgB,gBAAgB,qDAE/B;AAED,wBAAgB,iBAAiB,qDAEhC;AAED,wBAAgB,cAAc,CAAC,MAAM,KAAA,oDAEpC;AAED,wBAAgB,oBAAoB,CAAC,SAAS,KAAA,oDAE7C;AAED,wBAAgB,iBAAiB,qDAEhC;AAED,wBAAgB,iBAAiB,CAAC,MAAM,KAAA,oDAEvC;AAED,wBAAgB,oBAAoB,CAAC,SAAS,KAAA,oDAE7C;AAED,wBAAgB,oBAAoB,CAAC,MAAM,KAAA,oDAE1C;AAED,wBAAgB,aAAa,qDAE5B;AAED,wBAAgB,oBAAoB,qDAEnC"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { ResponseType } from 'axios'
|
|
1
|
+
import { ResponseType } from 'axios';
|
|
2
2
|
/**
|
|
3
3
|
* 文档中心下载文件的url,主要用于图片等直接写在 href 里
|
|
4
4
|
*
|
|
5
5
|
* @param fileId 文件Id
|
|
6
6
|
* @returns url
|
|
7
7
|
*/
|
|
8
|
-
export declare function getOssFileUrl(fileId?: string): string
|
|
8
|
+
export declare function getOssFileUrl(fileId?: string): string;
|
|
9
9
|
/**
|
|
10
10
|
* 文档中心上传文件的url
|
|
11
11
|
*
|
|
12
12
|
* @returns url
|
|
13
13
|
*/
|
|
14
|
-
export declare function putOssFileUrl(): string
|
|
14
|
+
export declare function putOssFileUrl(): string;
|
|
15
15
|
/**
|
|
16
16
|
* 获取文档中心文件
|
|
17
17
|
*
|
|
@@ -19,10 +19,7 @@ export declare function putOssFileUrl(): string
|
|
|
19
19
|
* @param responseType 数据类型,支持 arraybuffer | blob | document | json | text | stream
|
|
20
20
|
* @returns 文件内容
|
|
21
21
|
*/
|
|
22
|
-
export declare function getOssFileApi(
|
|
23
|
-
fileId: string,
|
|
24
|
-
responseType?: ResponseType,
|
|
25
|
-
): Promise<import('axios').AxiosResponse<any>>
|
|
22
|
+
export declare function getOssFileApi(fileId: string, responseType?: ResponseType): Promise<import("axios").AxiosResponse<any, any>>;
|
|
26
23
|
/**
|
|
27
24
|
* 将文件上传到文档中心
|
|
28
25
|
*
|
|
@@ -30,17 +27,12 @@ export declare function getOssFileApi(
|
|
|
30
27
|
* @param blob 文件的Blob数据
|
|
31
28
|
* @returns 文件Id
|
|
32
29
|
*/
|
|
33
|
-
export declare function putOssFileApi(
|
|
34
|
-
filename: string,
|
|
35
|
-
blob: Blob,
|
|
36
|
-
): import('axios').AxiosPromise<any>
|
|
30
|
+
export declare function putOssFileApi(filename: string, blob: Blob): import("axios").AxiosPromise<any>;
|
|
37
31
|
/**
|
|
38
32
|
* 获取文档中心预览URL
|
|
39
33
|
*
|
|
40
34
|
* @param fileId 文件Id
|
|
41
35
|
* @returns 文件内容
|
|
42
36
|
*/
|
|
43
|
-
export declare function getPreviewUrlApi(
|
|
44
|
-
|
|
45
|
-
): Promise<import('axios').AxiosResponse<any>>
|
|
46
|
-
//# sourceMappingURL=oss.d.ts.map
|
|
37
|
+
export declare function getPreviewUrlApi(fileId: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
38
|
+
//# sourceMappingURL=oss.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oss.d.ts","sourceRoot":"","sources":["../../../src/api/platform/oss.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,YAAY,EAAE,MAAM,OAAO,CAAA;AAIxD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,MAAM,SAAK,UAExC;AAED;;;;GAIG;AACH,wBAAgB,aAAa,WAE5B;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,YAAY
|
|
1
|
+
{"version":3,"file":"oss.d.ts","sourceRoot":"","sources":["../../../src/api/platform/oss.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,YAAY,EAAE,MAAM,OAAO,CAAA;AAIxD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,MAAM,SAAK,UAExC;AAED;;;;GAIG;AACH,wBAAgB,aAAa,WAE5B;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,YAAY,oDAMxE;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,qCAUzD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,oDAQ9C"}
|
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
export declare function loginApi({
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export declare function getGlobalPolicyApi(): Promise<import('axios').AxiosResponse<any>>
|
|
14
|
-
export declare function updatePasswordApi(data: any): Promise<import('axios').AxiosResponse<any>>
|
|
15
|
-
export declare function getCaptchaURL(validCodeId: string): string
|
|
16
|
-
export declare function logoutApi(): Promise<import('axios').AxiosResponse<any>>
|
|
17
|
-
//# sourceMappingURL=user.d.ts.map
|
|
1
|
+
export declare function loginApi({ userName, password, validCodeId, validCodeInput }: {
|
|
2
|
+
userName: any;
|
|
3
|
+
password: any;
|
|
4
|
+
validCodeId: any;
|
|
5
|
+
validCodeInput: any;
|
|
6
|
+
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
7
|
+
export declare function getUserInfoApi(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
8
|
+
export declare function getGlobalPolicyApi(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
9
|
+
export declare function updatePasswordApi(data: any): Promise<import("axios").AxiosResponse<any, any>>;
|
|
10
|
+
export declare function getCaptchaURL(validCodeId: string): string;
|
|
11
|
+
export declare function logoutApi(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
12
|
+
//# sourceMappingURL=user.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../../src/api/platform/user.ts"],"names":[],"mappings":"AAMA,wBAAgB,QAAQ,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE;;;;;CAAA
|
|
1
|
+
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../../src/api/platform/user.ts"],"names":[],"mappings":"AAMA,wBAAgB,QAAQ,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE;;;;;CAAA,oDAQ3E;AAED,wBAAgB,cAAc,qDAE7B;AAED,wBAAgB,kBAAkB,qDAEjC;AAED,wBAAgB,iBAAiB,CAAC,IAAI,KAAA,oDAErC;AAED,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,UAEhD;AAED,wBAAgB,SAAS,qDAExB"}
|
package/types/api/user.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function listUserTreeApi(params: any): Promise<import(
|
|
2
|
-
//# sourceMappingURL=user.d.ts.map
|
|
1
|
+
export declare function listUserTreeApi(params: any): Promise<import("axios").AxiosResponse<any, any>>;
|
|
2
|
+
//# sourceMappingURL=user.d.ts.map
|
package/types/api/user.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/api/user.ts"],"names":[],"mappings":"AAKA,wBAAgB,eAAe,CAAC,MAAM,KAAA
|
|
1
|
+
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/api/user.ts"],"names":[],"mappings":"AAKA,wBAAgB,eAAe,CAAC,MAAM,KAAA,oDAErC"}
|
|
@@ -9,9 +9,10 @@ declare const instance: AxiosExtendsInstance;
|
|
|
9
9
|
* 即上一次发起的网络请求将调用浏览器取消网络请求
|
|
10
10
|
* 注意:如果serviceApi是多个组件共同使用时,需要慎重使用本方法,避免导致由于请求被取消导致的功能异常
|
|
11
11
|
* @param {Function} api - 需要封装的API函数
|
|
12
|
+
* @param {boolean} isPost - 是否是post请求
|
|
12
13
|
* @returns {Function} 封装后可取消的api
|
|
13
14
|
*/
|
|
14
|
-
export declare const wrapApi: (api: any) => {
|
|
15
|
+
export declare const wrapApi: (api: any, isPost?: boolean) => {
|
|
15
16
|
(...args: any[]): Promise<any>;
|
|
16
17
|
cancel(reason: any): void;
|
|
17
18
|
isPending(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/request/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAC3D,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/request/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAC3D,OAAO,EAAuC,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAG1F,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA;AAC9B,OAAO,EAAE,oBAAoB,EAAE,CAAA;AAE/B,QAAA,MAAM,QAAQ,EAAE,oBAA+D,CAAA;AAS/E;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO;;;;CA6GnB,CAAA;AAQD,OAAO,EAAE,QAAQ,IAAI,KAAK,EAAE,CAAA"}
|