@ibiz-template/core 0.0.1-alpha.0 → 0.0.1-alpha.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 (63) hide show
  1. package/LICENSE +21 -0
  2. package/out/constant/core/core.d.ts +23 -0
  3. package/out/constant/core/core.d.ts.map +1 -0
  4. package/out/constant/core/core.js +22 -0
  5. package/out/constant/index.d.ts +2 -0
  6. package/out/constant/index.d.ts.map +1 -0
  7. package/out/constant/index.js +1 -0
  8. package/out/context/index.d.ts +29 -2
  9. package/out/context/index.d.ts.map +1 -1
  10. package/out/context/index.js +34 -3
  11. package/out/environment/environment.d.ts +6 -0
  12. package/out/environment/environment.d.ts.map +1 -0
  13. package/out/environment/environment.js +6 -0
  14. package/out/ibizsys.d.ts +51 -0
  15. package/out/ibizsys.d.ts.map +1 -0
  16. package/out/ibizsys.js +37 -0
  17. package/out/index.d.ts +9 -1
  18. package/out/index.d.ts.map +1 -1
  19. package/out/index.js +9 -8
  20. package/out/install.d.ts +9 -0
  21. package/out/install.d.ts.map +1 -0
  22. package/out/install.js +15 -0
  23. package/out/interface/i-environment/i-environment.d.ts +20 -0
  24. package/out/interface/i-environment/i-environment.d.ts.map +1 -0
  25. package/out/interface/{i-context/i-context.js → i-environment/i-environment.js} +0 -0
  26. package/out/interface/index.d.ts +2 -1
  27. package/out/interface/index.d.ts.map +1 -1
  28. package/out/interface/org-data/org-data.d.ts +43 -0
  29. package/out/interface/org-data/org-data.d.ts.map +1 -0
  30. package/out/interface/org-data/org-data.js +1 -0
  31. package/out/types.d.ts +38 -0
  32. package/out/types.d.ts.map +1 -0
  33. package/out/types.js +1 -0
  34. package/out/utils/index.d.ts +4 -0
  35. package/out/utils/index.d.ts.map +1 -0
  36. package/out/utils/index.js +3 -0
  37. package/out/utils/interceptor/interceptor.d.ts +13 -0
  38. package/out/utils/interceptor/interceptor.d.ts.map +1 -0
  39. package/out/utils/interceptor/interceptor.js +33 -0
  40. package/out/utils/net/net.d.ts +141 -0
  41. package/out/utils/net/net.d.ts.map +1 -0
  42. package/out/utils/net/net.js +194 -0
  43. package/out/utils/util/util.d.ts +10 -0
  44. package/out/utils/util/util.d.ts.map +1 -0
  45. package/out/utils/util/util.js +13 -0
  46. package/package.json +17 -5
  47. package/src/constant/core/core.ts +23 -0
  48. package/src/constant/index.ts +1 -0
  49. package/src/context/index.ts +93 -0
  50. package/src/environment/environment.ts +8 -0
  51. package/src/ibizsys.ts +57 -0
  52. package/src/index.ts +11 -0
  53. package/src/install.ts +16 -0
  54. package/src/interface/i-environment/i-environment.ts +20 -0
  55. package/src/interface/index.ts +2 -0
  56. package/src/interface/org-data/org-data.ts +42 -0
  57. package/src/types.ts +43 -0
  58. package/src/utils/index.ts +3 -0
  59. package/src/utils/interceptor/interceptor.ts +35 -0
  60. package/src/utils/net/net.ts +247 -0
  61. package/src/utils/util/util.ts +14 -0
  62. package/out/interface/i-context/i-context.d.ts +0 -12
  63. package/out/interface/i-context/i-context.d.ts.map +0 -1
@@ -0,0 +1,141 @@
1
+ import { AxiosRequestHeaders, AxiosResponse } from 'axios';
2
+ /**
3
+ * 返回值扩展
4
+ *
5
+ * @author chitanda
6
+ * @date 2022-07-14 16:07:50
7
+ * @export
8
+ * @interface NetResponse
9
+ * @extends {AxiosResponse}
10
+ */
11
+ export interface NetResponse extends AxiosResponse {
12
+ /**
13
+ * 是否请求成功
14
+ *
15
+ * @description 当状态码为 200-299 时认为成功
16
+ * @author chitanda
17
+ * @date 2022-07-14 16:07:59
18
+ * @type {boolean}
19
+ */
20
+ ok: boolean;
21
+ }
22
+ /**
23
+ * 全局请求工具类
24
+ *
25
+ * @author chitanda
26
+ * @date 2022-07-14 15:07:42
27
+ * @export
28
+ * @class Net
29
+ */
30
+ export declare class Net {
31
+ /**
32
+ * 标准请求前缀
33
+ *
34
+ * @author chitanda
35
+ * @date 2022-07-21 10:07:48
36
+ * @protected
37
+ * @type {string}
38
+ */
39
+ protected prefix: string;
40
+ /**
41
+ * Creates an instance of Net.
42
+ *
43
+ * @author chitanda
44
+ * @date 2022-07-21 10:07:27
45
+ * @param {string} [prefix] 请求前缀
46
+ */
47
+ constructor(prefix?: string);
48
+ /**
49
+ * Post 请求
50
+ *
51
+ * @author chitanda
52
+ * @date 2022-07-14 15:07:01
53
+ * @param {string} url
54
+ * @param {IParams} [params={}]
55
+ * @return {*} {Promise<NetResponse>}
56
+ */
57
+ post(url: string, data: IData, params?: IParams, headers?: AxiosRequestHeaders): Promise<NetResponse>;
58
+ /**
59
+ * Get 请求
60
+ *
61
+ * @author chitanda
62
+ * @date 2022-07-14 15:07:08
63
+ * @param {string} url
64
+ * @param {IParams} [params={}]
65
+ * @return {*} {Promise<NetResponse>}
66
+ */
67
+ get(url: string, params?: IParams, headers?: AxiosRequestHeaders): Promise<NetResponse>;
68
+ /**
69
+ * Delete 请求
70
+ *
71
+ * @author chitanda
72
+ * @date 2022-07-14 15:07:43
73
+ * @param {string} url
74
+ * @param {IParams} [params]
75
+ * @return {*} {Promise<NetResponse>}
76
+ */
77
+ delete(url: string, params?: IParams, headers?: AxiosRequestHeaders): Promise<NetResponse>;
78
+ /**
79
+ * Put 请求
80
+ *
81
+ * @author chitanda
82
+ * @date 2022-07-14 15:07:49
83
+ * @param {string} url
84
+ * @param {IParams} params
85
+ * @return {*} {Promise<NetResponse>}
86
+ */
87
+ put(url: string, params: IParams, headers?: AxiosRequestHeaders): Promise<NetResponse>;
88
+ /**
89
+ * 获取模型数据
90
+ *
91
+ * @author chitanda
92
+ * @date 2022-07-14 15:07:15
93
+ * @param {string} url
94
+ * @param {AxiosRequestHeaders} [headers={}]
95
+ * @return {*} {Promise<NetResponse>}
96
+ */
97
+ getModel(url: string, headers?: AxiosRequestHeaders): Promise<NetResponse>;
98
+ /**
99
+ * 统一处理请求返回
100
+ *
101
+ * @author chitanda
102
+ * @date 2022-07-14 16:07:23
103
+ * @private
104
+ * @param {AxiosResponse} response
105
+ * @return {*} {NetResponse}
106
+ */
107
+ private doResponseResult;
108
+ /**
109
+ * 处理平台预定义参数
110
+ *
111
+ * @author chitanda
112
+ * @date 2022-07-14 15:07:12
113
+ * @private
114
+ * @param {string} url
115
+ * @param {IParams} [params]
116
+ * @return {*} {string}
117
+ */
118
+ private handleAppPresetParam;
119
+ /**
120
+ * url 附加请求参数
121
+ *
122
+ * @author chitanda
123
+ * @date 2022-07-14 15:07:34
124
+ * @private
125
+ * @param {string} url
126
+ * @param {IParams} params
127
+ * @return {*} {string}
128
+ */
129
+ private attachUrlParam;
130
+ /**
131
+ * 处理 url 参数
132
+ *
133
+ * @author chitanda
134
+ * @date 2022-07-20 20:07:17
135
+ * @private
136
+ * @param {string} url
137
+ * @return {*} {string}
138
+ */
139
+ private attachUrl;
140
+ }
141
+ //# sourceMappingURL=net.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"net.d.ts","sourceRoot":"","sources":["../../../src/utils/net/net.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAIlE;;;;;;;;GAQG;AACH,MAAM,WAAW,WAAY,SAAQ,aAAa;IAChD;;;;;;;OAOG;IACH,EAAE,EAAE,OAAO,CAAC;CACb;AAED;;;;;;;GAOG;AACH,qBAAa,GAAG;IACd;;;;;;;OAOG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,CAAM;IAE9B;;;;;;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,WAAW,CAAC;IAevB;;;;;;;;OAQG;IACG,GAAG,CACP,GAAG,EAAE,MAAM,EACX,MAAM,GAAE,OAAY,EACpB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,WAAW,CAAC;IAUvB;;;;;;;;OAQG;IACG,MAAM,CACV,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,OAAO,EAChB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,WAAW,CAAC;IAMvB;;;;;;;;OAQG;IACG,GAAG,CACP,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,OAAO,EACf,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,WAAW,CAAC;IAMvB;;;;;;;;OAQG;IACG,QAAQ,CACZ,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,WAAW,CAAC;IAOvB;;;;;;;;OAQG;IACH,OAAO,CAAC,gBAAgB;IAQxB;;;;;;;;;OASG;IACH,OAAO,CAAC,oBAAoB;IAc5B;;;;;;;;;OASG;IACH,OAAO,CAAC,cAAc;IAiBtB;;;;;;;;OAQG;IACH,OAAO,CAAC,SAAS;CAGlB"}
@@ -0,0 +1,194 @@
1
+ import axios from 'axios';
2
+ import { stringify } from 'qs';
3
+ import { notNilEmpty } from 'qx-util';
4
+ /**
5
+ * 全局请求工具类
6
+ *
7
+ * @author chitanda
8
+ * @date 2022-07-14 15:07:42
9
+ * @export
10
+ * @class Net
11
+ */
12
+ export class Net {
13
+ /**
14
+ * Creates an instance of Net.
15
+ *
16
+ * @author chitanda
17
+ * @date 2022-07-21 10:07:27
18
+ * @param {string} [prefix] 请求前缀
19
+ */
20
+ constructor(prefix) {
21
+ /**
22
+ * 标准请求前缀
23
+ *
24
+ * @author chitanda
25
+ * @date 2022-07-21 10:07:48
26
+ * @protected
27
+ * @type {string}
28
+ */
29
+ this.prefix = '';
30
+ if (prefix) {
31
+ this.prefix = prefix;
32
+ }
33
+ }
34
+ /**
35
+ * Post 请求
36
+ *
37
+ * @author chitanda
38
+ * @date 2022-07-14 15:07:01
39
+ * @param {string} url
40
+ * @param {IParams} [params={}]
41
+ * @return {*} {Promise<NetResponse>}
42
+ */
43
+ async post(url, data, params = {}, headers = {}) {
44
+ url = this.handleAppPresetParam(url, params);
45
+ const response = await axios({
46
+ method: 'post',
47
+ url,
48
+ data,
49
+ headers: Object.assign({ 'Content-Type': 'application/json;charset=UTF-8', Accept: 'application/json' }, headers),
50
+ });
51
+ return this.doResponseResult(response);
52
+ }
53
+ /**
54
+ * Get 请求
55
+ *
56
+ * @author chitanda
57
+ * @date 2022-07-14 15:07:08
58
+ * @param {string} url
59
+ * @param {IParams} [params={}]
60
+ * @return {*} {Promise<NetResponse>}
61
+ */
62
+ async get(url, params = {}, headers = {}) {
63
+ // if (params.srfparentdata) {
64
+ // Object.assign(params, params.srfparentdata);
65
+ // delete params.srfparentdata;
66
+ // }
67
+ url = this.attachUrlParam(url, params);
68
+ const response = await axios.get(url, { headers });
69
+ return this.doResponseResult(response);
70
+ }
71
+ /**
72
+ * Delete 请求
73
+ *
74
+ * @author chitanda
75
+ * @date 2022-07-14 15:07:43
76
+ * @param {string} url
77
+ * @param {IParams} [params]
78
+ * @return {*} {Promise<NetResponse>}
79
+ */
80
+ async delete(url, params, headers = {}) {
81
+ url = this.handleAppPresetParam(url, params);
82
+ const response = await axios.delete(url, { headers });
83
+ return this.doResponseResult(response);
84
+ }
85
+ /**
86
+ * Put 请求
87
+ *
88
+ * @author chitanda
89
+ * @date 2022-07-14 15:07:49
90
+ * @param {string} url
91
+ * @param {IParams} params
92
+ * @return {*} {Promise<NetResponse>}
93
+ */
94
+ async put(url, params, headers = {}) {
95
+ url = this.handleAppPresetParam(url, params);
96
+ const response = await axios.put(url, params, { headers });
97
+ return this.doResponseResult(response);
98
+ }
99
+ /**
100
+ * 获取模型数据
101
+ *
102
+ * @author chitanda
103
+ * @date 2022-07-14 15:07:15
104
+ * @param {string} url
105
+ * @param {AxiosRequestHeaders} [headers={}]
106
+ * @return {*} {Promise<NetResponse>}
107
+ */
108
+ async getModel(url, headers = {}) {
109
+ const response = await axios.get(url, {
110
+ headers,
111
+ });
112
+ return this.doResponseResult(response);
113
+ }
114
+ /**
115
+ * 统一处理请求返回
116
+ *
117
+ * @author chitanda
118
+ * @date 2022-07-14 16:07:23
119
+ * @private
120
+ * @param {AxiosResponse} response
121
+ * @return {*} {NetResponse}
122
+ */
123
+ doResponseResult(response) {
124
+ const res = response;
125
+ if (res.status >= 200 && res.status <= 299) {
126
+ res.ok = true;
127
+ }
128
+ return res;
129
+ }
130
+ /**
131
+ * 处理平台预定义参数
132
+ *
133
+ * @author chitanda
134
+ * @date 2022-07-14 15:07:12
135
+ * @private
136
+ * @param {string} url
137
+ * @param {IParams} [params]
138
+ * @return {*} {string}
139
+ */
140
+ handleAppPresetParam(url, params) {
141
+ if (params) {
142
+ const keys = Object.keys(params);
143
+ const tempParam = {};
144
+ keys.forEach((item) => {
145
+ if (item.startsWith('srf') && notNilEmpty(params[item])) {
146
+ tempParam[item] = params[item];
147
+ }
148
+ });
149
+ return this.attachUrlParam(url, params);
150
+ }
151
+ return url;
152
+ }
153
+ /**
154
+ * url 附加请求参数
155
+ *
156
+ * @author chitanda
157
+ * @date 2022-07-14 15:07:34
158
+ * @private
159
+ * @param {string} url
160
+ * @param {IParams} params
161
+ * @return {*} {string}
162
+ */
163
+ attachUrlParam(url, params) {
164
+ url = this.attachUrl(url);
165
+ const strParams = stringify(params);
166
+ if (notNilEmpty(strParams)) {
167
+ if (url.endsWith('?')) {
168
+ url = `${url}${strParams}`;
169
+ }
170
+ else if (url.indexOf('?') !== -1 && url.endsWith('&')) {
171
+ url = `${url}${strParams}`;
172
+ }
173
+ else if (url.indexOf('?') !== -1 && !url.endsWith('&')) {
174
+ url = `${url}&${strParams}`;
175
+ }
176
+ else {
177
+ url = `${url}?${strParams}`;
178
+ }
179
+ }
180
+ return url;
181
+ }
182
+ /**
183
+ * 处理 url 参数
184
+ *
185
+ * @author chitanda
186
+ * @date 2022-07-20 20:07:17
187
+ * @private
188
+ * @param {string} url
189
+ * @return {*} {string}
190
+ */
191
+ attachUrl(url) {
192
+ return `${this.prefix}${url}`;
193
+ }
194
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 获取认证令牌
3
+ *
4
+ * @author chitanda
5
+ * @date 2022-07-20 18:07:39
6
+ * @export
7
+ * @return {*} {(string | null)}
8
+ */
9
+ export declare function getToken(): string | null;
10
+ //# sourceMappingURL=util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/utils/util/util.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,wBAAgB,QAAQ,IAAI,MAAM,GAAG,IAAI,CAExC"}
@@ -0,0 +1,13 @@
1
+ import { getCookie } from 'qx-util';
2
+ import { CoreConst } from '../../constant';
3
+ /**
4
+ * 获取认证令牌
5
+ *
6
+ * @author chitanda
7
+ * @date 2022-07-20 18:07:39
8
+ * @export
9
+ * @return {*} {(string | null)}
10
+ */
11
+ export function getToken() {
12
+ return getCookie(CoreConst.TOKEN);
13
+ }
package/package.json CHANGED
@@ -1,21 +1,33 @@
1
1
  {
2
2
  "name": "@ibiz-template/core",
3
- "version": "0.0.1-alpha.0",
4
- "description": "核心逻辑包",
3
+ "version": "0.0.1-alpha.1",
4
+ "description": "核心包",
5
5
  "main": "out/index.js",
6
- "types": "out/types/index.d.ts",
6
+ "types": "out/index.d.ts",
7
7
  "files": [
8
- "out"
8
+ "out",
9
+ "src"
9
10
  ],
10
11
  "scripts": {
11
12
  "dev": "tsc --watch",
12
13
  "build": "npm run lint && npm run clean && tsc --build",
13
14
  "lint": "eslint src/**/*.ts",
15
+ "lint:fix": "eslint --fix src/**/*.ts",
14
16
  "clean": "rimraf out",
15
17
  "publish:next": "npm run build && npm publish --access public --tag next",
16
18
  "publish:npm": "npm run build && npm publish --access public"
17
19
  },
18
20
  "author": "chitanda",
19
21
  "license": "MIT",
20
- "dependencies": {}
22
+ "dependencies": {
23
+ "@ibiz-template/command": "^0.0.1-alpha.1",
24
+ "@ibiz-template/model": "^0.0.1-alpha.1",
25
+ "axios": "^0.27.2",
26
+ "qs": "^6.11.0",
27
+ "qx-util": "^0.1.2"
28
+ },
29
+ "devDependencies": {
30
+ "@types/qs": "^6.9.7"
31
+ },
32
+ "gitHead": "4ea59555405794d91b25e807a92bbefa080108fb"
21
33
  }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * 核心全局静态变量
3
+ *
4
+ * @author chitanda
5
+ * @date 2022-07-14 17:07:25
6
+ * @export
7
+ * @enum {number}
8
+ */
9
+ export class CoreConst {
10
+ /**
11
+ * 默认模型服务标识
12
+ */
13
+ static readonly DEFAULT_MODEL_SERVICE_TAG = 'default';
14
+
15
+ /**
16
+ * 访问令牌标识
17
+ *
18
+ * @author chitanda
19
+ * @date 2022-07-20 15:07:28
20
+ * @static
21
+ */
22
+ static readonly TOKEN = 'access_token';
23
+ }
@@ -0,0 +1 @@
1
+ export { CoreConst } from './core/core';
@@ -0,0 +1,93 @@
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]) {
21
+ return target[p];
22
+ }
23
+ if (target.context[p]) {
24
+ return target.context[p];
25
+ }
26
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
+ if ((target as any)._parent) {
28
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
+ return (target as any)._parent[p];
30
+ }
31
+ }
32
+ }
33
+
34
+ /**
35
+ * 上下文处理类
36
+ *
37
+ * @author chitanda
38
+ * @date 2022-07-14 10:07:24
39
+ * @export
40
+ * @class IBizContext
41
+ */
42
+ export class IBizContext implements IContext {
43
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
+ [key: string | symbol]: any;
45
+
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;
55
+
56
+ /**
57
+ * Creates an instance of IBizContext.
58
+ *
59
+ * @author chitanda
60
+ * @date 2022-07-14 10:07:15
61
+ * @param {IContext} [context={}]
62
+ * @param {IBizContext} [parent]
63
+ */
64
+ constructor(public context: IContext = {}, parent?: IBizContext) {
65
+ if (parent) {
66
+ this._parent = parent;
67
+ }
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;
92
+ }
93
+ }
@@ -0,0 +1,8 @@
1
+ import { IEnvironment } from '../interface';
2
+
3
+ /**
4
+ * 环境变量
5
+ */
6
+ export const Environment: IEnvironment = {
7
+ baseUrl: '/trainsys__web',
8
+ };
package/src/ibizsys.ts ADDED
@@ -0,0 +1,57 @@
1
+ import { commands } from '@ibiz-template/command';
2
+ import { Environment } from './environment/environment';
3
+ import { OrgData } from './interface';
4
+ import { Net } from './utils';
5
+
6
+ /**
7
+ * 全局对象
8
+ *
9
+ * @author chitanda
10
+ * @date 2022-07-19 16:07:50
11
+ * @export
12
+ * @class IBizSys
13
+ */
14
+ export class IBizSys {
15
+ /**
16
+ * 环境变量
17
+ *
18
+ * @author chitanda
19
+ * @date 2022-07-19 18:07:04
20
+ */
21
+ env = Environment;
22
+
23
+ /**
24
+ * 指令控制器
25
+ *
26
+ * @author chitanda
27
+ * @date 2022-07-21 17:07:45
28
+ */
29
+ commands = commands;
30
+
31
+ /**
32
+ * 网络请求工具类
33
+ *
34
+ * @author chitanda
35
+ * @date 2022-07-19 17:07:56
36
+ * @type {Net}
37
+ */
38
+ net: Net = new Net(this.env.baseUrl);
39
+
40
+ /**
41
+ * sass 模式下的中心系统标识
42
+ *
43
+ * @author chitanda
44
+ * @date 2022-07-19 18:07:23
45
+ * @type {string}
46
+ */
47
+ orgData?: OrgData;
48
+
49
+ /**
50
+ * 应用数据
51
+ *
52
+ * @author chitanda
53
+ * @date 2022-07-20 19:07:22
54
+ * @type {IData}
55
+ */
56
+ appData?: IData;
57
+ }
package/src/index.ts ADDED
@@ -0,0 +1,11 @@
1
+ import './types';
2
+
3
+ export { commands } from '@ibiz-template/command';
4
+
5
+ export * from './constant';
6
+ export { IBizContext, IBizContextProxyHandle } from './context';
7
+ export { Environment } from './environment/environment';
8
+ export * from './interface';
9
+ export * from './utils';
10
+ export { IBizSys } from './ibizsys';
11
+ export { install } from './install';
package/src/install.ts ADDED
@@ -0,0 +1,16 @@
1
+ import { IBizSys } from './ibizsys';
2
+ import { Interceptor } from './utils';
3
+
4
+ /**
5
+ * 初始化全局对象
6
+ *
7
+ * @author chitanda
8
+ * @date 2022-07-19 17:07:37
9
+ * @export
10
+ */
11
+ export function install(): void {
12
+ if (!window.ibiz) {
13
+ window.ibiz = new IBizSys();
14
+ }
15
+ new Interceptor();
16
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * 配置参数
3
+ *
4
+ * @author chitanda
5
+ * @date 2022-07-19 18:07:29
6
+ * @export
7
+ * @interface IEnvironment
8
+ */
9
+ export interface IEnvironment {
10
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
+ [key: string | symbol]: any;
12
+ /**
13
+ * 请求根路径
14
+ *
15
+ * @author chitanda
16
+ * @date 2022-07-19 18:07:58
17
+ * @type {string}
18
+ */
19
+ baseUrl: string;
20
+ }
@@ -0,0 +1,2 @@
1
+ export { IEnvironment } from './i-environment/i-environment';
2
+ export { OrgData } from './org-data/org-data';
@@ -0,0 +1,42 @@
1
+ /**
2
+ * 组织数据
3
+ *
4
+ * @author chitanda
5
+ * @date 2022-07-20 18:07:59
6
+ * @export
7
+ * @interface OrgData
8
+ */
9
+ export interface OrgData {
10
+ /**
11
+ * 组织标识
12
+ *
13
+ * @author chitanda
14
+ * @date 2022-07-20 18:07:17
15
+ * @type {string}
16
+ */
17
+ orgid: string;
18
+ /**
19
+ * 组织名称
20
+ *
21
+ * @author chitanda
22
+ * @date 2022-07-20 18:07:31
23
+ * @type {string}
24
+ */
25
+ orgname: string;
26
+ /**
27
+ * 中心系统标识
28
+ *
29
+ * @author chitanda
30
+ * @date 2022-07-20 18:07:56
31
+ * @type {string}
32
+ */
33
+ dcsystemid: string;
34
+ /**
35
+ * 系统标识
36
+ *
37
+ * @author chitanda
38
+ * @date 2022-07-20 18:07:47
39
+ * @type {string}
40
+ */
41
+ systemid: string;
42
+ }