@ibiz-template/core 0.0.1-alpha.3 → 0.0.1-alpha.32

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 (74) 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 +3 -0
  6. package/out/constant/index.d.ts.map +1 -1
  7. package/out/constant/index.js +3 -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/context/index.d.ts +2 -39
  15. package/out/context/index.d.ts.map +1 -1
  16. package/out/context/index.js +34 -65
  17. package/out/environment/environment.d.ts.map +1 -1
  18. package/out/environment/environment.js +9 -1
  19. package/out/error/http-error/http-error.d.ts +18 -0
  20. package/out/error/http-error/http-error.d.ts.map +1 -0
  21. package/out/error/http-error/http-error.js +36 -0
  22. package/out/error/index.d.ts +3 -0
  23. package/out/error/index.d.ts.map +1 -0
  24. package/out/error/index.js +2 -0
  25. package/out/error/runtime-error/runtime-error.d.ts +15 -0
  26. package/out/error/runtime-error/runtime-error.d.ts.map +1 -0
  27. package/out/error/runtime-error/runtime-error.js +15 -0
  28. package/out/factory-center.d.ts +11 -0
  29. package/out/factory-center.d.ts.map +1 -0
  30. package/out/factory-center.js +10 -0
  31. package/out/index.d.ts +3 -1
  32. package/out/index.d.ts.map +1 -1
  33. package/out/index.js +3 -1
  34. package/out/install.d.ts.map +1 -1
  35. package/out/install.js +2 -0
  36. package/out/interface/i-environment/i-environment.d.ts +59 -0
  37. package/out/interface/i-environment/i-environment.d.ts.map +1 -1
  38. package/out/types.d.ts +20 -0
  39. package/out/types.d.ts.map +1 -1
  40. package/out/utils/index.d.ts +1 -0
  41. package/out/utils/index.d.ts.map +1 -1
  42. package/out/utils/index.js +1 -0
  43. package/out/utils/net/http-response.d.ts +4 -9
  44. package/out/utils/net/http-response.d.ts.map +1 -1
  45. package/out/utils/net/http-response.js +0 -7
  46. package/out/utils/net/net.d.ts +18 -11
  47. package/out/utils/net/net.d.ts.map +1 -1
  48. package/out/utils/net/net.js +57 -24
  49. package/out/utils/url-helper/url-helper.d.ts +51 -0
  50. package/out/utils/url-helper/url-helper.d.ts.map +1 -0
  51. package/out/utils/url-helper/url-helper.js +59 -0
  52. package/out/utils/util/util.d.ts +29 -0
  53. package/out/utils/util/util.d.ts.map +1 -1
  54. package/out/utils/util/util.js +50 -0
  55. package/package.json +19 -7
  56. package/src/constant/http-status-message/http-status-message.ts +20 -0
  57. package/src/constant/index.ts +3 -0
  58. package/src/constant/login-mode/login-mode.ts +23 -0
  59. package/src/constant/menu-permission-mode/menu-permission-mode.ts +23 -0
  60. package/src/context/index.ts +35 -69
  61. package/src/environment/environment.ts +9 -1
  62. package/src/error/http-error/http-error.ts +43 -0
  63. package/src/error/index.ts +2 -0
  64. package/src/error/runtime-error/runtime-error.ts +14 -0
  65. package/src/factory-center.ts +9 -0
  66. package/src/index.ts +3 -1
  67. package/src/install.ts +2 -0
  68. package/src/interface/i-environment/i-environment.ts +67 -0
  69. package/src/types.ts +21 -0
  70. package/src/utils/index.ts +1 -0
  71. package/src/utils/net/http-response.ts +6 -9
  72. package/src/utils/net/net.ts +66 -33
  73. package/src/utils/url-helper/url-helper.ts +62 -0
  74. package/src/utils/util/util.ts +64 -0
@@ -0,0 +1,23 @@
1
+ /* eslint-disable no-shadow */
2
+ /**
3
+ * 登录模式
4
+ *
5
+ * @author lxm
6
+ * @date 2022-10-12 14:10:56
7
+ * @export
8
+ * @enum {number}
9
+ */
10
+ export enum LoginMode {
11
+ /**
12
+ * 默认标准登录
13
+ */
14
+ DEFAULT = 'DEFAULT',
15
+ /**
16
+ * 自定义登录
17
+ */
18
+ CUSTOM = 'CUSTOM',
19
+ /**
20
+ * 中央认证登录
21
+ */
22
+ CAS = 'CAS',
23
+ }
@@ -0,0 +1,23 @@
1
+ /* eslint-disable no-shadow */
2
+ /**
3
+ * 菜单权限校验模式
4
+ *
5
+ * @author lxm
6
+ * @date 2022-10-12 14:10:56
7
+ * @export
8
+ * @enum {number}
9
+ */
10
+ export enum MenuPermissionMode {
11
+ /**
12
+ * 混合模式(默认)
13
+ */
14
+ MIXIN = 'MIXIN',
15
+ /**
16
+ * 统一资源模式
17
+ */
18
+ RESOURCE = 'RESOURCE',
19
+ /**
20
+ * RT模式
21
+ */
22
+ RT = 'RT',
23
+ }
@@ -1,36 +1,3 @@
1
- /* eslint-disable no-param-reassign */
2
- /* eslint-disable no-constructor-return */
3
- /* eslint-disable no-underscore-dangle */
4
- /* eslint-disable max-classes-per-file */
5
- /**
6
- * 上下文代理处理
7
- *
8
- * @author chitanda
9
- * @date 2022-07-14 10:07:45
10
- * @class IBizContextProxyHandle
11
- * @implements {ProxyHandler<IBizContext>}
12
- */
13
- export class IBizContextProxyHandle implements ProxyHandler<IBizContext> {
14
- set(target: IBizContext, p: string | symbol, value: unknown): boolean {
15
- target.context[p] = value;
16
- return true;
17
- }
18
-
19
- get(target: IBizContext, p: string | symbol, _receiver: unknown): unknown {
20
- if (target[p] !== undefined) {
21
- return target[p];
22
- }
23
- if (target.context[p] !== undefined) {
24
- return target.context[p];
25
- }
26
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
- if ((target as any)._parent && (target as any)._parent[p] !== undefined) {
28
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
- return (target as any)._parent[p];
30
- }
31
- }
32
- }
33
-
34
1
  /**
35
2
  * 上下文处理类
36
3
  *
@@ -43,51 +10,50 @@ export class IBizContext implements IContext {
43
10
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
11
  [key: string | symbol]: any;
45
12
 
46
- /**
47
- * 父上下文
48
- *
49
- * @author chitanda
50
- * @date 2022-07-14 10:07:06
51
- * @protected
52
- * @type {(IBizContext | null)}
53
- */
54
- protected _parent: IBizContext | null = null;
13
+ protected _context!: IContext;
55
14
 
56
15
  /**
57
16
  * Creates an instance of IBizContext.
58
17
  *
59
18
  * @author chitanda
60
19
  * @date 2022-07-14 10:07:15
61
- * @param {IContext} [context={}]
20
+ * @param {IContext} [context={}] 自身的上下文
62
21
  * @param {IBizContext} [parent]
63
22
  */
64
- constructor(public context: IContext = {}, parent?: IBizContext) {
23
+ // eslint-disable-next-line default-param-last
24
+ constructor(context: IContext = {}, parent?: IBizContext) {
65
25
  if (parent) {
66
- this._parent = parent;
26
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
27
+ const self = this;
28
+ // 定义私有变量,用于存储父已有上下文,方便覆盖
29
+ Object.defineProperty(this, '_context', {
30
+ enumerable: false,
31
+ value: {},
32
+ });
33
+ // 监控父上下文参数,自身不存在时从父取
34
+ const properties: { [key: string]: PropertyDescriptor } = {};
35
+ const keys = Object.keys(parent);
36
+ keys.forEach(key => {
37
+ properties[key] = {
38
+ enumerable: true,
39
+ set(val: unknown) {
40
+ if (val == null) {
41
+ self._context[key] = null;
42
+ } else {
43
+ self._context[key] = val;
44
+ }
45
+ },
46
+ get() {
47
+ if (self._context[key] !== undefined) {
48
+ return self._context[key];
49
+ }
50
+ return parent[key];
51
+ },
52
+ };
53
+ });
54
+ Object.defineProperties(this, properties);
67
55
  }
68
- return this.createProxy();
69
- }
70
-
71
- /**
72
- * 创建代理
73
- *
74
- * @author chitanda
75
- * @date 2022-07-14 11:07:37
76
- * @protected
77
- * @return {*} {IBizContext}
78
- */
79
- protected createProxy(): IBizContext {
80
- return new Proxy(this, new IBizContextProxyHandle());
81
- }
82
-
83
- /**
84
- * 销毁上下文,避免内存泄漏
85
- *
86
- * @author chitanda
87
- * @date 2022-07-14 11:07:45
88
- */
89
- destroy(): void {
90
- this.context = {};
91
- this._parent = null;
56
+ // 合并给入上下文
57
+ Object.assign(this, context);
92
58
  }
93
59
  }
@@ -1,12 +1,20 @@
1
+ import { LoginMode, MenuPermissionMode } from '../constant';
1
2
  import { IEnvironment } from '../interface';
2
3
 
3
4
  /**
4
5
  * 环境变量
5
6
  */
6
7
  export const Environment: IEnvironment = {
8
+ dev: false,
9
+ jsCdn: 'https://cdn.jsdelivr.net',
7
10
  baseUrl: '',
8
- assetsUrl: '/assets/',
11
+ remoteModelUrl: '/remotemodel',
12
+ assetsUrl: './assets',
9
13
  dcSystem: '',
10
14
  ExportFile: '/ibizutil/download',
11
15
  UploadFile: '/ibizutil/upload',
16
+ casLoginUrl: '',
17
+ loginMode: LoginMode.DEFAULT,
18
+ menuPermissionMode: MenuPermissionMode.MIXIN,
19
+ enablePermission: true,
12
20
  };
@@ -0,0 +1,43 @@
1
+ import { AxiosError, AxiosResponse } from 'axios';
2
+ import { HttpStatusMessageConst } from '../../constant';
3
+
4
+ /**
5
+ * 请求异常
6
+ *
7
+ * @author chitanda
8
+ * @date 2022-09-18 17:09:10
9
+ * @export
10
+ * @class HttpError
11
+ * @implements {Error}
12
+ */
13
+ export class HttpError implements Error {
14
+ name: string = 'HttpError';
15
+
16
+ message: string;
17
+
18
+ status: number;
19
+
20
+ response?: AxiosResponse;
21
+
22
+ constructor(err: AxiosError) {
23
+ const res = err.response;
24
+ this.response = err.response;
25
+ if (res) {
26
+ if (res.data) {
27
+ this.message = (res.data as IData).message;
28
+ } else {
29
+ this.message = res.statusText;
30
+ }
31
+ if (!this.message) {
32
+ this.message = HttpStatusMessageConst[res.status];
33
+ }
34
+ if (!this.message) {
35
+ this.message = '网络异常,请稍后重试!';
36
+ }
37
+ this.status = res.status;
38
+ } else {
39
+ this.message = err.message;
40
+ this.status = 500;
41
+ }
42
+ }
43
+ }
@@ -0,0 +1,2 @@
1
+ export { HttpError } from './http-error/http-error';
2
+ export { RuntimeError } from './runtime-error/runtime-error';
@@ -0,0 +1,14 @@
1
+ /**
2
+ * 运行时异常
3
+ *
4
+ * @author lxm
5
+ * @date 2022-09-21 18:09:09
6
+ * @export
7
+ * @class RuntimeError
8
+ * @implements {Error}
9
+ */
10
+ export class RuntimeError implements Error {
11
+ name: string = 'Runtime Error';
12
+
13
+ constructor(public message: string) {}
14
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 工厂类挂载中心,挂载各种解耦用创建工厂
3
+ *
4
+ * @author lxm
5
+ * @date 2022-10-17 15:10:04
6
+ * @export
7
+ * @class FactoryCenter
8
+ */
9
+ export class FactoryCenter {}
package/src/index.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  import './types';
2
2
 
3
3
  export * from './constant';
4
- export { IBizContext, IBizContextProxyHandle } from './context';
4
+ export { IBizContext } from './context';
5
5
  export { Environment } from './environment/environment';
6
+ export * from './error';
6
7
  export * from './interface';
7
8
  export * from './utils';
8
9
  export { IBizSys } from './ibizsys';
10
+ export { FactoryCenter } from './factory-center';
9
11
  export { install } from './install';
package/src/install.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { FactoryCenter } from './factory-center';
1
2
  import { IBizSys } from './ibizsys';
2
3
  import { Interceptor } from './utils';
3
4
 
@@ -13,5 +14,6 @@ export function install(): void {
13
14
  throw new Error('ibiz 已经存在, 无需重复安装');
14
15
  }
15
16
  window.ibiz = new IBizSys();
17
+ window.___fc = new FactoryCenter();
16
18
  new Interceptor();
17
19
  }
@@ -1,3 +1,5 @@
1
+ import { LoginMode, MenuPermissionMode } from '../../constant';
2
+
1
3
  /**
2
4
  * 配置参数
3
5
  *
@@ -16,6 +18,26 @@ export interface IEnvironment {
16
18
  */
17
19
  namespace?: string;
18
20
 
21
+ /**
22
+ * 是否为开发模式
23
+ *
24
+ * @default false
25
+ * @author chitanda
26
+ * @date 2022-10-21 11:10:29
27
+ * @type {boolean}
28
+ */
29
+ dev: boolean;
30
+
31
+ /**
32
+ * js 静态文件 cdn 地址
33
+ *
34
+ * @default https://cdn.jsdelivr.net/
35
+ * @author chitanda
36
+ * @date 2022-10-24 11:10:14
37
+ * @type {string}
38
+ */
39
+ jsCdn: string;
40
+
19
41
  /**
20
42
  * 请求根路径
21
43
  *
@@ -25,6 +47,33 @@ export interface IEnvironment {
25
47
  */
26
48
  baseUrl: string;
27
49
 
50
+ /**
51
+ * 登录模式
52
+ *
53
+ * @author lxm
54
+ * @date 2022-10-12 14:10:51
55
+ * @type {LoginMode}
56
+ */
57
+ loginMode: LoginMode;
58
+
59
+ /**
60
+ * 中央认证登录地址
61
+ *
62
+ * @author lxm
63
+ * @date 2022-10-11 12:10:21
64
+ * @type {string}
65
+ */
66
+ casLoginUrl: string;
67
+
68
+ /**
69
+ * 远程模型路径
70
+ *
71
+ * @author chitanda
72
+ * @date 2022-09-22 18:09:25
73
+ * @type {string}
74
+ */
75
+ remoteModelUrl: string;
76
+
28
77
  /**
29
78
  * 资源文件根路径
30
79
  *
@@ -60,4 +109,22 @@ export interface IEnvironment {
60
109
  * @type {string}
61
110
  */
62
111
  UploadFile: string;
112
+
113
+ /**
114
+ * 是否启用权限校验(默认true)
115
+ *
116
+ * @author lxm
117
+ * @date 2022-10-12 18:10:25
118
+ * @type {boolean}
119
+ */
120
+ enablePermission: boolean;
121
+
122
+ /**
123
+ * 菜单权限校验模式(默认MIXIN)
124
+ *
125
+ * @author lxm
126
+ * @date 2022-10-12 18:10:27
127
+ * @type {MenuPermissionMode}
128
+ */
129
+ menuPermissionMode: MenuPermissionMode;
63
130
  }
package/src/types.ts CHANGED
@@ -1,11 +1,21 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { FactoryCenter } from './factory-center';
2
3
  import { IBizSys } from './ibizsys';
3
4
 
4
5
  declare global {
5
6
  const ibiz: IBizSys;
7
+ const ___fc: FactoryCenter;
6
8
 
7
9
  interface Window {
8
10
  ibiz: IBizSys;
11
+ /**
12
+ * 全局工厂中心
13
+ *
14
+ * @author lxm
15
+ * @date 2022-10-17 15:10:43
16
+ * @type {FactoryCenter}
17
+ */
18
+ ___fc: FactoryCenter;
9
19
  }
10
20
 
11
21
  /**
@@ -40,4 +50,15 @@ declare global {
40
50
  interface IData {
41
51
  [key: string | symbol]: any;
42
52
  }
53
+
54
+ /**
55
+ * 任意对象结构
56
+ *
57
+ * @author chitanda
58
+ * @date 2022-09-21 15:09:30
59
+ * @interface IObject
60
+ */
61
+ interface IObject {
62
+ [key: string | symbol]: any;
63
+ }
43
64
  }
@@ -4,3 +4,4 @@ export { IHttpResponse, HttpResponse } from './net/http-response';
4
4
  export { Net } from './net/net';
5
5
  export { plural, pluralLower } from './plural/plural';
6
6
  export * from './util/util';
7
+ export * from './url-helper/url-helper';
@@ -28,7 +28,7 @@ export interface IHttpResponse<T = IData> extends AxiosResponse {
28
28
  * @date 2022-08-18 15:08:44
29
29
  * @type {boolean}
30
30
  */
31
- local?: boolean;
31
+ local: boolean;
32
32
 
33
33
  data: T;
34
34
 
@@ -75,14 +75,11 @@ export class HttpResponse<T = IData> implements IHttpResponse<T> {
75
75
 
76
76
  statusText: string;
77
77
 
78
- /**
79
- * header 本地仿造时值为空
80
- *
81
- * @author chitanda
82
- * @date 2022-08-18 15:08:46
83
- * @type {AxiosResponseHeaders}
84
- */
85
- headers: AxiosResponseHeaders = {};
78
+ headers:
79
+ | AxiosResponseHeaders
80
+ | Partial<
81
+ Record<string, string> & { 'set-cookie'?: string[] | undefined }
82
+ > = {};
86
83
 
87
84
  /**
88
85
  * AxiosResponse 本地仿造时值为空
@@ -1,6 +1,11 @@
1
- import axios, { AxiosRequestHeaders, AxiosResponse } from 'axios';
1
+ import axios, {
2
+ AxiosError,
3
+ RawAxiosRequestHeaders,
4
+ AxiosResponse,
5
+ } from 'axios';
2
6
  import { stringify } from 'qs';
3
7
  import { notNilEmpty } from 'qx-util';
8
+ import { HttpError } from '../../error';
4
9
  import { IHttpResponse } from './http-response';
5
10
 
6
11
  /**
@@ -43,44 +48,52 @@ export class Net {
43
48
  * Post 请求
44
49
  *
45
50
  * @author chitanda
46
- * @date 2022-07-14 15:07:01
51
+ * @date 2022-10-19 11:10:30
47
52
  * @param {string} url
53
+ * @param {IData} data
48
54
  * @param {IParams} [params={}]
55
+ * @param {RawAxiosRequestHeaders} [headers={}]
49
56
  * @return {*} {Promise<IHttpResponse>}
50
57
  */
51
58
  async post(
52
59
  url: string,
53
60
  data: IData,
54
61
  params: IParams = {},
55
- headers: AxiosRequestHeaders = {},
62
+ headers: RawAxiosRequestHeaders = {},
56
63
  ): Promise<IHttpResponse> {
57
64
  url = this.handleAppPresetParam(url, params);
58
- const response = await axios({
59
- method: 'post',
60
- url,
61
- data,
62
- headers: {
63
- 'Content-Type': 'application/json;charset=UTF-8',
64
- Accept: 'application/json',
65
- ...headers,
66
- },
67
- });
68
- return this.doResponseResult(response);
65
+ try {
66
+ const response = await axios({
67
+ method: 'post',
68
+ url,
69
+ data,
70
+ headers: {
71
+ 'Content-Type': 'application/json;charset=UTF-8',
72
+ Accept: 'application/json',
73
+ ...headers,
74
+ },
75
+ });
76
+ return this.doResponseResult(response);
77
+ } catch (error) {
78
+ throw new HttpError(error as AxiosError);
79
+ }
69
80
  }
70
81
 
71
82
  /**
72
83
  * Get 请求
73
84
  *
74
85
  * @author chitanda
75
- * @date 2022-07-14 15:07:08
86
+ * @date 2022-10-19 11:10:24
76
87
  * @param {string} url
77
88
  * @param {IParams} [params={}]
89
+ * @param {RawAxiosRequestHeaders} [headers={}]
90
+ * @param {IParams} [option={}]
78
91
  * @return {*} {Promise<IHttpResponse>}
79
92
  */
80
93
  async get(
81
94
  url: string,
82
95
  params: IParams = {},
83
- headers: AxiosRequestHeaders = {},
96
+ headers: RawAxiosRequestHeaders = {},
84
97
  option: IParams = {},
85
98
  ): Promise<IHttpResponse> {
86
99
  // if (params.srfparentdata) {
@@ -88,46 +101,62 @@ export class Net {
88
101
  // delete params.srfparentdata;
89
102
  // }
90
103
  url = this.attachUrlParam(url, params);
91
- const response = await axios.get(url, { headers, ...option });
92
- return this.doResponseResult(response);
104
+ try {
105
+ const response = await axios.get(url, { headers, ...option });
106
+ return this.doResponseResult(response);
107
+ } catch (error) {
108
+ throw new HttpError(error as AxiosError);
109
+ }
93
110
  }
94
111
 
95
112
  /**
96
113
  * Delete 请求
97
114
  *
98
115
  * @author chitanda
99
- * @date 2022-07-14 15:07:43
116
+ * @date 2022-10-19 11:10:17
100
117
  * @param {string} url
101
118
  * @param {IParams} [params]
119
+ * @param {RawAxiosRequestHeaders} [headers={}]
102
120
  * @return {*} {Promise<IHttpResponse>}
103
121
  */
104
122
  async delete(
105
123
  url: string,
106
124
  params?: IParams,
107
- headers: AxiosRequestHeaders = {},
125
+ headers: RawAxiosRequestHeaders = {},
108
126
  ): Promise<IHttpResponse> {
109
127
  url = this.handleAppPresetParam(url, params);
110
- const response = await axios.delete(url, { headers });
111
- return this.doResponseResult(response);
128
+ try {
129
+ const response = await axios.delete(url, { headers });
130
+ return this.doResponseResult(response);
131
+ } catch (error) {
132
+ throw new HttpError(error as AxiosError);
133
+ }
112
134
  }
113
135
 
114
136
  /**
115
137
  * Put 请求
116
138
  *
117
139
  * @author chitanda
118
- * @date 2022-07-14 15:07:49
140
+ * @date 2022-10-19 11:10:11
119
141
  * @param {string} url
120
142
  * @param {IData} data
143
+ * @param {IParams} [params={}]
144
+ * @param {RawAxiosRequestHeaders} [headers={}]
121
145
  * @return {*} {Promise<IHttpResponse>}
122
146
  */
123
147
  async put(
124
148
  url: string,
125
149
  data: IData,
126
- headers: AxiosRequestHeaders = {},
150
+ params: IParams = {},
151
+ headers: RawAxiosRequestHeaders = {},
127
152
  ): Promise<IHttpResponse> {
128
- url = this.handleAppPresetParam(url, data);
129
- const response = await axios.put(url, data, { headers });
130
- return this.doResponseResult(response);
153
+ url = this.handleAppPresetParam(url, params);
154
+ try {
155
+ const response = await axios.put(url, data, { headers });
156
+ return this.doResponseResult(response);
157
+ } catch (error) {
158
+ throw new HttpError(error as AxiosError);
159
+ }
131
160
  }
132
161
 
133
162
  /**
@@ -136,17 +165,21 @@ export class Net {
136
165
  * @author chitanda
137
166
  * @date 2022-07-14 15:07:15
138
167
  * @param {string} url
139
- * @param {AxiosRequestHeaders} [headers={}]
168
+ * @param {RawAxiosRequestHeaders} [headers={}]
140
169
  * @return {*} {Promise<IHttpResponse>}
141
170
  */
142
171
  async getModel(
143
172
  url: string,
144
- headers: AxiosRequestHeaders = {},
173
+ headers: RawAxiosRequestHeaders = {},
145
174
  ): Promise<IHttpResponse> {
146
- const response = await axios.get(url, {
147
- headers,
148
- });
149
- return this.doResponseResult(response);
175
+ try {
176
+ const response = await axios.get(url, {
177
+ headers,
178
+ });
179
+ return this.doResponseResult(response);
180
+ } catch (error) {
181
+ throw new HttpError(error as AxiosError);
182
+ }
150
183
  }
151
184
 
152
185
  /**