@ibiz-template/core 0.0.1-alpha.5 → 0.0.1-beta.1

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.
Files changed (113) hide show
  1. package/dist/system/index.system.js +1 -0
  2. package/out/constant/http-status-message/http-status-message.d.ts +5 -0
  3. package/out/constant/http-status-message/http-status-message.d.ts.map +1 -0
  4. package/out/constant/http-status-message/http-status-message.js +20 -0
  5. package/out/constant/index.d.ts +4 -0
  6. package/out/constant/index.d.ts.map +1 -1
  7. package/out/constant/index.js +4 -0
  8. package/out/constant/login-mode/login-mode.d.ts +23 -0
  9. package/out/constant/login-mode/login-mode.d.ts.map +1 -0
  10. package/out/constant/login-mode/login-mode.js +24 -0
  11. package/out/constant/menu-permission-mode/menu-permission-mode.d.ts +23 -0
  12. package/out/constant/menu-permission-mode/menu-permission-mode.d.ts.map +1 -0
  13. package/out/constant/menu-permission-mode/menu-permission-mode.js +24 -0
  14. package/out/constant/util/util.d.ts +5 -0
  15. package/out/constant/util/util.d.ts.map +1 -0
  16. package/out/constant/util/util.js +5 -0
  17. package/out/context/index.d.ts +2 -39
  18. package/out/context/index.d.ts.map +1 -1
  19. package/out/context/index.js +33 -64
  20. package/out/environment/environment.d.ts.map +1 -1
  21. package/out/environment/environment.js +11 -2
  22. package/out/error/http-error/http-error.d.ts.map +1 -1
  23. package/out/error/http-error/http-error.js +7 -0
  24. package/out/factory-center.d.ts +11 -0
  25. package/out/factory-center.d.ts.map +1 -0
  26. package/out/factory-center.js +10 -0
  27. package/out/ibizsys.d.ts +8 -1
  28. package/out/ibizsys.d.ts.map +1 -1
  29. package/out/ibizsys.js +8 -1
  30. package/out/index.d.ts +2 -1
  31. package/out/index.d.ts.map +1 -1
  32. package/out/index.js +2 -1
  33. package/out/install.d.ts.map +1 -1
  34. package/out/install.js +4 -2
  35. package/out/interface/click-outside/click-outside.d.ts +70 -0
  36. package/out/interface/click-outside/click-outside.d.ts.map +1 -0
  37. package/out/interface/click-outside/click-outside.js +1 -0
  38. package/out/interface/i-environment/i-environment.d.ts +72 -4
  39. package/out/interface/i-environment/i-environment.d.ts.map +1 -1
  40. package/out/interface/index.d.ts +1 -0
  41. package/out/interface/index.d.ts.map +1 -1
  42. package/out/interface/index.js +1 -1
  43. package/out/types.d.ts +10 -0
  44. package/out/types.d.ts.map +1 -1
  45. package/out/utils/click-outside/click-outside.d.ts +14 -0
  46. package/out/utils/click-outside/click-outside.d.ts.map +1 -0
  47. package/out/utils/click-outside/click-outside.js +85 -0
  48. package/out/utils/color/color.d.ts +13 -0
  49. package/out/utils/color/color.d.ts.map +1 -0
  50. package/out/utils/color/color.js +76 -0
  51. package/out/utils/download-file/download-file.d.ts +21 -0
  52. package/out/utils/download-file/download-file.d.ts.map +1 -0
  53. package/out/utils/download-file/download-file.js +87 -0
  54. package/out/utils/event/event.d.ts +34 -0
  55. package/out/utils/event/event.d.ts.map +1 -0
  56. package/out/utils/event/event.js +60 -0
  57. package/out/utils/index.d.ts +7 -1
  58. package/out/utils/index.d.ts.map +1 -1
  59. package/out/utils/index.js +7 -1
  60. package/out/utils/interceptor/core-interceptor.d.ts +15 -0
  61. package/out/utils/interceptor/core-interceptor.d.ts.map +1 -0
  62. package/out/utils/interceptor/core-interceptor.js +30 -0
  63. package/out/utils/interceptor/index.d.ts +3 -0
  64. package/out/utils/interceptor/index.d.ts.map +1 -0
  65. package/out/utils/interceptor/index.js +2 -0
  66. package/out/utils/interceptor/interceptor.d.ts +74 -3
  67. package/out/utils/interceptor/interceptor.d.ts.map +1 -1
  68. package/out/utils/interceptor/interceptor.js +73 -22
  69. package/out/utils/logger/logger.d.ts +3 -0
  70. package/out/utils/logger/logger.d.ts.map +1 -0
  71. package/out/utils/logger/logger.js +2 -0
  72. package/out/utils/net/http-response.d.ts +4 -9
  73. package/out/utils/net/http-response.d.ts.map +1 -1
  74. package/out/utils/net/http-response.js +0 -7
  75. package/out/utils/net/net.d.ts +82 -31
  76. package/out/utils/net/net.d.ts.map +1 -1
  77. package/out/utils/net/net.js +109 -40
  78. package/out/utils/url-helper/url-helper.d.ts +51 -0
  79. package/out/utils/url-helper/url-helper.d.ts.map +1 -0
  80. package/out/utils/url-helper/url-helper.js +59 -0
  81. package/out/utils/util/util.d.ts +20 -4
  82. package/out/utils/util/util.d.ts.map +1 -1
  83. package/out/utils/util/util.js +59 -5
  84. package/package.json +21 -9
  85. package/src/constant/http-status-message/http-status-message.ts +20 -0
  86. package/src/constant/index.ts +4 -0
  87. package/src/constant/login-mode/login-mode.ts +23 -0
  88. package/src/constant/menu-permission-mode/menu-permission-mode.ts +23 -0
  89. package/src/constant/util/util.ts +5 -0
  90. package/src/context/index.ts +34 -68
  91. package/src/environment/environment.ts +11 -2
  92. package/src/error/http-error/http-error.ts +7 -0
  93. package/src/factory-center.ts +9 -0
  94. package/src/ibizsys.ts +9 -1
  95. package/src/index.ts +2 -1
  96. package/src/install.ts +4 -2
  97. package/src/interface/click-outside/click-outside.ts +71 -0
  98. package/src/interface/i-environment/i-environment.ts +81 -4
  99. package/src/interface/index.ts +1 -0
  100. package/src/types.ts +10 -0
  101. package/src/utils/click-outside/click-outside.ts +110 -0
  102. package/src/utils/color/color.ts +84 -0
  103. package/src/utils/download-file/download-file.ts +88 -0
  104. package/src/utils/event/event.ts +77 -0
  105. package/src/utils/index.ts +7 -1
  106. package/src/utils/interceptor/core-interceptor.ts +35 -0
  107. package/src/utils/interceptor/index.ts +2 -0
  108. package/src/utils/interceptor/interceptor.ts +109 -22
  109. package/src/utils/logger/logger.ts +3 -0
  110. package/src/utils/net/http-response.ts +6 -9
  111. package/src/utils/net/net.ts +144 -51
  112. package/src/utils/url-helper/url-helper.ts +62 -0
  113. package/src/utils/util/util.ts +72 -14
@@ -1,6 +1,12 @@
1
- export { Interceptor } from './interceptor/interceptor';
1
+ export * from './interceptor';
2
+ export { Logger } from './logger/logger';
2
3
  export { Namespace } from './namespace/namespace';
3
4
  export { HttpResponse } from './net/http-response';
4
5
  export { Net } from './net/net';
5
6
  export { plural, pluralLower } from './plural/plural';
6
7
  export * from './util/util';
8
+ export * from './url-helper/url-helper';
9
+ export * from './event/event';
10
+ export * from './click-outside/click-outside';
11
+ export * from './color/color';
12
+ export * from './download-file/download-file';
@@ -0,0 +1,15 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import { Interceptor } from './interceptor';
3
+ /**
4
+ * 核心包拦截器
5
+ *
6
+ * @author lxm
7
+ * @date 2022-10-27 17:10:48
8
+ * @export
9
+ * @class CoreInterceptor
10
+ * @extends {Interceptor}
11
+ */
12
+ export declare class CoreInterceptor extends Interceptor {
13
+ protected onBeforeRequest(config: AxiosRequestConfig): Promise<AxiosRequestConfig>;
14
+ }
15
+ //# sourceMappingURL=core-interceptor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-interceptor.d.ts","sourceRoot":"","sources":["../../../src/utils/interceptor/core-interceptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;;;;;;GAQG;AACH,qBAAa,eAAgB,SAAQ,WAAW;cAC9B,eAAe,CAC7B,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,kBAAkB,CAAC;CAkB/B"}
@@ -0,0 +1,30 @@
1
+ import { getToken } from '../util/util';
2
+ import { Interceptor } from './interceptor';
3
+ /**
4
+ * 核心包拦截器
5
+ *
6
+ * @author lxm
7
+ * @date 2022-10-27 17:10:48
8
+ * @export
9
+ * @class CoreInterceptor
10
+ * @extends {Interceptor}
11
+ */
12
+ export class CoreInterceptor extends Interceptor {
13
+ async onBeforeRequest(config) {
14
+ await super.onBeforeRequest(config);
15
+ if (!config.headers) {
16
+ config.headers = {};
17
+ }
18
+ config.headers.Authorization = `Bearer ${getToken()}`;
19
+ const { orgData } = ibiz;
20
+ if (orgData) {
21
+ if (orgData.systemid) {
22
+ config.headers.srfsystemid = orgData.systemid;
23
+ }
24
+ if (orgData.orgid) {
25
+ config.headers.srforgid = orgData.orgid;
26
+ }
27
+ }
28
+ return config;
29
+ }
30
+ }
@@ -0,0 +1,3 @@
1
+ export * from './core-interceptor';
2
+ export * from './interceptor';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/interceptor/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './core-interceptor';
2
+ export * from './interceptor';
@@ -1,5 +1,6 @@
1
+ import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
1
2
  /**
2
- * 默认请求拦截器
3
+ * 拦截器基类
3
4
  *
4
5
  * @author chitanda
5
6
  * @date 2022-07-20 18:07:11
@@ -7,7 +8,77 @@
7
8
  * @class Interceptor
8
9
  */
9
10
  export declare class Interceptor {
10
- constructor();
11
- protected init(): void;
11
+ /**
12
+ * 请求拦截器绑定标识
13
+ *
14
+ * @author lxm
15
+ * @date 2022-10-27 17:10:20
16
+ * @private
17
+ * @type {number}
18
+ */
19
+ private requestTag?;
20
+ /**
21
+ * 响应拦截器绑定标识
22
+ *
23
+ * @author lxm
24
+ * @date 2022-10-27 17:10:19
25
+ * @private
26
+ * @type {number}
27
+ */
28
+ private responseTag?;
29
+ /**
30
+ * 请求之前处理
31
+ *
32
+ * @author lxm
33
+ * @date 2022-10-27 17:10:41
34
+ * @protected
35
+ * @param {AxiosRequestConfig} config
36
+ * @returns {*} {Promise<AxiosRequestConfig>}
37
+ */
38
+ protected onBeforeRequest(config: AxiosRequestConfig): Promise<AxiosRequestConfig>;
39
+ /**
40
+ * 请求失败之后处理
41
+ *
42
+ * @author lxm
43
+ * @date 2022-10-27 17:10:40
44
+ * @protected
45
+ * @param {*} error
46
+ */
47
+ protected onRequestError(error: any): Promise<never>;
48
+ /**
49
+ * 响应成功之后处理
50
+ *
51
+ * @author lxm
52
+ * @date 2022-10-27 17:10:38
53
+ * @protected
54
+ * @param {AxiosResponse} config
55
+ * @returns {*} {Promise<AxiosRequestConfig>}
56
+ */
57
+ protected onResponseSuccess(config: AxiosResponse): Promise<AxiosResponse>;
58
+ /**
59
+ * 响应失败之后处理
60
+ *
61
+ * @author lxm
62
+ * @date 2022-10-27 17:10:37
63
+ * @protected
64
+ * @param {*} _error
65
+ */
66
+ protected onResponseError(error: any): Promise<never>;
67
+ /**
68
+ * 使用拦截器
69
+ *
70
+ * @author lxm
71
+ * @date 2022-10-27 17:10:28
72
+ * @param {AxiosInstance} instance
73
+ */
74
+ use(instance: AxiosInstance): void;
75
+ /**
76
+ * 移出拦截器
77
+ *
78
+ * @author lxm
79
+ * @date 2022-10-27 17:10:27
80
+ * @param {AxiosInstance} instance
81
+ */
82
+ eject(instance: AxiosInstance): void;
12
83
  }
13
84
  //# sourceMappingURL=interceptor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"interceptor.d.ts","sourceRoot":"","sources":["../../../src/utils/interceptor/interceptor.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,qBAAa,WAAW;;IAKtB,SAAS,CAAC,IAAI,IAAI,IAAI;CAkBvB"}
1
+ {"version":3,"file":"interceptor.d.ts","sourceRoot":"","sources":["../../../src/utils/interceptor/interceptor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEzE;;;;;;;GAOG;AACH,qBAAa,WAAW;IACtB;;;;;;;OAOG;IACH,OAAO,CAAC,UAAU,CAAC,CAAS;IAE5B;;;;;;;OAOG;IACH,OAAO,CAAC,WAAW,CAAC,CAAS;IAE7B;;;;;;;;OAQG;cACa,eAAe,CAC7B,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,kBAAkB,CAAC;IAI9B;;;;;;;OAOG;IACH,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,GAAG;IAKnC;;;;;;;;OAQG;cACa,iBAAiB,CAC/B,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,aAAa,CAAC;IAIzB;;;;;;;OAOG;IACH,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,GAAG;IAKpC;;;;;;OAMG;IACH,GAAG,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI;IAWlC;;;;;;OAMG;IACH,KAAK,CAAC,QAAQ,EAAE,aAAa;CAQ9B"}
@@ -1,7 +1,5 @@
1
- import axios from 'axios';
2
- import { getToken } from '../util/util';
3
1
  /**
4
- * 默认请求拦截器
2
+ * 拦截器基类
5
3
  *
6
4
  * @author chitanda
7
5
  * @date 2022-07-20 18:07:11
@@ -9,25 +7,78 @@ import { getToken } from '../util/util';
9
7
  * @class Interceptor
10
8
  */
11
9
  export class Interceptor {
12
- constructor() {
13
- this.init();
10
+ /**
11
+ * 请求之前处理
12
+ *
13
+ * @author lxm
14
+ * @date 2022-10-27 17:10:41
15
+ * @protected
16
+ * @param {AxiosRequestConfig} config
17
+ * @returns {*} {Promise<AxiosRequestConfig>}
18
+ */
19
+ async onBeforeRequest(config) {
20
+ return config;
14
21
  }
15
- init() {
16
- axios.interceptors.request.use(config => {
17
- if (!config.headers) {
18
- config.headers = {};
19
- }
20
- config.headers.Authorization = `Bearer ${getToken()}`;
21
- const { orgData } = ibiz;
22
- if (orgData) {
23
- if (orgData.systemid) {
24
- config.headers.srfsystemid = orgData.systemid;
25
- }
26
- if (orgData.orgid) {
27
- config.headers.srforgid = orgData.orgid;
28
- }
29
- }
30
- return config;
31
- });
22
+ /**
23
+ * 请求失败之后处理
24
+ *
25
+ * @author lxm
26
+ * @date 2022-10-27 17:10:40
27
+ * @protected
28
+ * @param {*} error
29
+ */
30
+ onRequestError(error) {
31
+ // 处理请求错误
32
+ return Promise.reject(error);
33
+ }
34
+ /**
35
+ * 响应成功之后处理
36
+ *
37
+ * @author lxm
38
+ * @date 2022-10-27 17:10:38
39
+ * @protected
40
+ * @param {AxiosResponse} config
41
+ * @returns {*} {Promise<AxiosRequestConfig>}
42
+ */
43
+ async onResponseSuccess(config) {
44
+ return config;
45
+ }
46
+ /**
47
+ * 响应失败之后处理
48
+ *
49
+ * @author lxm
50
+ * @date 2022-10-27 17:10:37
51
+ * @protected
52
+ * @param {*} _error
53
+ */
54
+ onResponseError(error) {
55
+ // 处理响应错误
56
+ return Promise.reject(error);
57
+ }
58
+ /**
59
+ * 使用拦截器
60
+ *
61
+ * @author lxm
62
+ * @date 2022-10-27 17:10:28
63
+ * @param {AxiosInstance} instance
64
+ */
65
+ use(instance) {
66
+ this.requestTag = instance.interceptors.request.use(this.onBeforeRequest, this.onRequestError);
67
+ this.responseTag = instance.interceptors.response.use(this.onResponseSuccess, this.onResponseError);
68
+ }
69
+ /**
70
+ * 移出拦截器
71
+ *
72
+ * @author lxm
73
+ * @date 2022-10-27 17:10:27
74
+ * @param {AxiosInstance} instance
75
+ */
76
+ eject(instance) {
77
+ if (this.requestTag) {
78
+ instance.interceptors.request.eject(this.requestTag);
79
+ }
80
+ if (this.responseTag) {
81
+ instance.interceptors.response.eject(this.responseTag);
82
+ }
32
83
  }
33
84
  }
@@ -0,0 +1,3 @@
1
+ import * as Logger from 'loglevel';
2
+ export { Logger };
3
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/utils/logger/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AAEnC,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ import * as Logger from 'loglevel';
2
+ export { Logger };
@@ -27,7 +27,7 @@ export interface IHttpResponse<T = IData> extends AxiosResponse {
27
27
  * @date 2022-08-18 15:08:44
28
28
  * @type {boolean}
29
29
  */
30
- local?: boolean;
30
+ local: boolean;
31
31
  data: T;
32
32
  /**
33
33
  * 当前页
@@ -64,14 +64,9 @@ export declare class HttpResponse<T = IData> implements IHttpResponse<T> {
64
64
  data: T;
65
65
  status: number;
66
66
  statusText: string;
67
- /**
68
- * header 本地仿造时值为空
69
- *
70
- * @author chitanda
71
- * @date 2022-08-18 15:08:46
72
- * @type {AxiosResponseHeaders}
73
- */
74
- headers: AxiosResponseHeaders;
67
+ headers: AxiosResponseHeaders | Partial<Record<string, string> & {
68
+ 'set-cookie'?: string[] | undefined;
69
+ }>;
75
70
  /**
76
71
  * AxiosResponse 本地仿造时值为空
77
72
  *
@@ -1 +1 @@
1
- {"version":3,"file":"http-response.d.ts","sourceRoot":"","sources":["../../../src/utils/net/http-response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAEhF;;;;;;;;;GASG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,KAAK,CAAE,SAAQ,aAAa;IAC7D;;;;;;;OAOG;IACH,EAAE,EAAE,OAAO,CAAC;IACZ;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,IAAI,EAAE,CAAC,CAAC;IAER;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;GASG;AACH,qBAAa,YAAY,CAAC,CAAC,GAAG,KAAK,CAAE,YAAW,aAAa,CAAC,CAAC,CAAC;IAC9D;;;;;OAKG;IACH,KAAK,UAAQ;IAEb,EAAE,UAAS;IAEX,IAAI,EAAE,CAAC,CAAC;IAER,MAAM,EAAE,MAAM,CAAC;IAEf,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;;OAMG;IACH,OAAO,EAAE,oBAAoB,CAAM;IAEnC;;;;;;OAMG;IACH,MAAM,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAA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@ -27,13 +27,6 @@ export class HttpResponse {
27
27
  */
28
28
  this.local = true;
29
29
  this.ok = false;
30
- /**
31
- * header 本地仿造时值为空
32
- *
33
- * @author chitanda
34
- * @date 2022-08-18 15:08:46
35
- * @type {AxiosResponseHeaders}
36
- */
37
30
  this.headers = {};
38
31
  /**
39
32
  * AxiosResponse 本地仿造时值为空
@@ -1,4 +1,5 @@
1
- import { AxiosRequestHeaders } from 'axios';
1
+ import { RawAxiosRequestHeaders, AxiosRequestConfig, AxiosInstance, CreateAxiosDefaults } from 'axios';
2
+ import { Interceptor } from '../interceptor/interceptor';
2
3
  import { IHttpResponse } from './http-response';
3
4
  /**
4
5
  * 全局请求工具类
@@ -10,73 +11,133 @@ import { IHttpResponse } from './http-response';
10
11
  */
11
12
  export declare class Net {
12
13
  /**
13
- * 标准请求前缀
14
+ * axios实例
14
15
  *
15
- * @author chitanda
16
- * @date 2022-07-21 10:07:48
16
+ * @author lxm
17
+ * @date 2022-10-27 17:10:18
17
18
  * @protected
18
- * @type {string}
19
+ * @type {AxiosInstance}
19
20
  */
20
- protected _prefix: string;
21
- get prefix(): string;
21
+ protected instance: AxiosInstance;
22
22
  /**
23
23
  * Creates an instance of Net.
24
+ * @author lxm
25
+ * @date 2022-10-27 16:10:05
26
+ * @param {CreateAxiosDefaults} [config] 创建实例用的默认配置
27
+ */
28
+ constructor(config?: CreateAxiosDefaults);
29
+ /**
30
+ * 注册的拦截器
24
31
  *
25
- * @author chitanda
26
- * @date 2022-07-21 10:07:27
27
- * @param {string} [prefix] 请求前缀
32
+ * @author lxm
33
+ * @date 2022-10-27 17:10:18
34
+ * @type {Map<string, Interceptor>}
35
+ */
36
+ interceptors: Map<string, Interceptor>;
37
+ /**
38
+ * 添加拦截器
39
+ *
40
+ * @author lxm
41
+ * @date 2022-10-27 17:10:42
42
+ * @param {string} name 唯一标识
43
+ * @param {Interceptor} interceptor 拦截器
44
+ */
45
+ addInterceptor(name: string, interceptor: Interceptor): void;
46
+ /**
47
+ * 删除拦截器
48
+ *
49
+ * @author lxm
50
+ * @date 2022-10-27 17:10:27
51
+ * @param {string} name 唯一标识
52
+ */
53
+ removeInterceptor(name: string): void;
54
+ /**
55
+ * 预置config,绑定动态的配置
56
+ *
57
+ * @author lxm
58
+ * @date 2022-10-27 16:10:48
59
+ * @readonly
60
+ * @protected
61
+ * @type {AxiosRequestConfig}
28
62
  */
29
- constructor(prefix?: string);
63
+ protected get presetConfig(): AxiosRequestConfig;
64
+ /**
65
+ * 从左到右递归合并配置参数(内置第一个合并的预置参数)
66
+ *
67
+ * @author lxm
68
+ * @date 2022-10-27 16:10:09
69
+ * @protected
70
+ * @param {...AxiosRequestConfig[]} configs
71
+ * @returns {*}
72
+ */
73
+ protected mergeConfig(...configs: AxiosRequestConfig[]): any;
30
74
  /**
31
75
  * Post 请求
32
76
  *
33
77
  * @author chitanda
34
- * @date 2022-07-14 15:07:01
78
+ * @date 2022-10-19 11:10:30
35
79
  * @param {string} url
80
+ * @param {IData} data
36
81
  * @param {IParams} [params={}]
82
+ * @param {RawAxiosRequestHeaders} [headers={}]
37
83
  * @return {*} {Promise<IHttpResponse>}
38
84
  */
39
- post(url: string, data: IData, params?: IParams, headers?: AxiosRequestHeaders): Promise<IHttpResponse>;
85
+ post(url: string, data: IData, params?: IParams, headers?: RawAxiosRequestHeaders): Promise<IHttpResponse>;
40
86
  /**
41
87
  * Get 请求
42
88
  *
43
89
  * @author chitanda
44
- * @date 2022-07-14 15:07:08
90
+ * @date 2022-10-19 11:10:24
45
91
  * @param {string} url
46
92
  * @param {IParams} [params={}]
93
+ * @param {RawAxiosRequestHeaders} [headers={}]
94
+ * @param {IParams} [option={}]
47
95
  * @return {*} {Promise<IHttpResponse>}
48
96
  */
49
- get(url: string, params?: IParams, headers?: AxiosRequestHeaders, option?: IParams): Promise<IHttpResponse>;
97
+ get(url: string, params?: IParams, headers?: RawAxiosRequestHeaders, option?: AxiosRequestConfig): Promise<IHttpResponse>;
50
98
  /**
51
99
  * Delete 请求
52
100
  *
53
101
  * @author chitanda
54
- * @date 2022-07-14 15:07:43
102
+ * @date 2022-10-19 11:10:17
55
103
  * @param {string} url
56
104
  * @param {IParams} [params]
105
+ * @param {RawAxiosRequestHeaders} [headers={}]
57
106
  * @return {*} {Promise<IHttpResponse>}
58
107
  */
59
- delete(url: string, params?: IParams, headers?: AxiosRequestHeaders): Promise<IHttpResponse>;
108
+ delete(url: string, params?: IParams, headers?: RawAxiosRequestHeaders): Promise<IHttpResponse>;
60
109
  /**
61
110
  * Put 请求
62
111
  *
63
112
  * @author chitanda
64
- * @date 2022-07-14 15:07:49
113
+ * @date 2022-10-19 11:10:11
65
114
  * @param {string} url
66
115
  * @param {IData} data
116
+ * @param {IParams} [params={}]
117
+ * @param {RawAxiosRequestHeaders} [headers={}]
67
118
  * @return {*} {Promise<IHttpResponse>}
68
119
  */
69
- put(url: string, data: IData, params?: IParams, headers?: AxiosRequestHeaders): Promise<IHttpResponse>;
120
+ put(url: string, data: IData, params?: IParams, headers?: RawAxiosRequestHeaders): Promise<IHttpResponse>;
70
121
  /**
71
122
  * 获取模型数据
72
123
  *
73
124
  * @author chitanda
74
125
  * @date 2022-07-14 15:07:15
75
126
  * @param {string} url
76
- * @param {AxiosRequestHeaders} [headers={}]
127
+ * @param {RawAxiosRequestHeaders} [headers={}]
77
128
  * @return {*} {Promise<IHttpResponse>}
78
129
  */
79
- getModel(url: string, headers?: AxiosRequestHeaders): Promise<IHttpResponse>;
130
+ getModel(url: string, headers?: RawAxiosRequestHeaders): Promise<IHttpResponse>;
131
+ /**
132
+ * 基础请求方法,会合并预置配置
133
+ *
134
+ * @author lxm
135
+ * @date 2022-10-27 14:10:06
136
+ * @param {string} url
137
+ * @param {AxiosRequestConfig} [config={}]
138
+ * @returns {*} {Promise<IHttpResponse>}
139
+ */
140
+ request(url: string, config?: AxiosRequestConfig): Promise<IHttpResponse>;
80
141
  /**
81
142
  * 统一处理请求返回
82
143
  *
@@ -109,15 +170,5 @@ export declare class Net {
109
170
  * @return {*} {string}
110
171
  */
111
172
  private attachUrlParam;
112
- /**
113
- * 处理 url 参数
114
- *
115
- * @author chitanda
116
- * @date 2022-07-20 20:07:17
117
- * @private
118
- * @param {string} url
119
- * @return {*} {string}
120
- */
121
- private attachUrl;
122
173
  }
123
174
  //# sourceMappingURL=net.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"net.d.ts","sourceRoot":"","sources":["../../../src/utils/net/net.ts"],"names":[],"mappings":"AAAA,OAAc,EAAc,mBAAmB,EAAiB,MAAM,OAAO,CAAC;AAI9E,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;;;GAOG;AACH,qBAAa,GAAG;IACd;;;;;;;OAOG;IACH,SAAS,CAAC,OAAO,EAAE,MAAM,CAAM;IAE/B,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;;;;;OAMG;gBACS,MAAM,CAAC,EAAE,MAAM;IAM3B;;;;;;;;OAQG;IACG,IAAI,CACR,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,KAAK,EACX,MAAM,GAAE,OAAY,EACpB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,aAAa,CAAC;IAmBzB;;;;;;;;OAQG;IACG,GAAG,CACP,GAAG,EAAE,MAAM,EACX,MAAM,GAAE,OAAY,EACpB,OAAO,GAAE,mBAAwB,EACjC,MAAM,GAAE,OAAY,GACnB,OAAO,CAAC,aAAa,CAAC;IAczB;;;;;;;;OAQG;IACG,MAAM,CACV,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,OAAO,EAChB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,aAAa,CAAC;IAUzB;;;;;;;;OAQG;IACG,GAAG,CACP,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,KAAK,EACX,MAAM,GAAE,OAAY,EACpB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,aAAa,CAAC;IAUzB;;;;;;;;OAQG;IACG,QAAQ,CACZ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