@ibiz-template/core 0.0.1-alpha.0 → 0.0.1-alpha.3
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/LICENSE +21 -0
- package/out/constant/core/core.d.ts +23 -0
- package/out/constant/core/core.d.ts.map +1 -0
- package/out/constant/core/core.js +22 -0
- package/out/constant/index.d.ts +2 -0
- package/out/constant/index.d.ts.map +1 -0
- package/out/constant/index.js +1 -0
- package/out/context/index.d.ts +29 -2
- package/out/context/index.d.ts.map +1 -1
- package/out/context/index.js +36 -5
- package/out/environment/environment.d.ts +6 -0
- package/out/environment/environment.d.ts.map +1 -0
- package/out/environment/environment.js +10 -0
- package/out/ibizsys.d.ts +44 -0
- package/out/ibizsys.d.ts.map +1 -0
- package/out/ibizsys.js +29 -0
- package/out/index.d.ts +8 -1
- package/out/index.d.ts.map +1 -1
- package/out/index.js +8 -8
- package/out/install.d.ts +9 -0
- package/out/install.d.ts.map +1 -0
- package/out/install.js +16 -0
- package/out/interface/i-environment/i-environment.d.ts +59 -0
- package/out/interface/i-environment/i-environment.d.ts.map +1 -0
- package/out/interface/{i-context/i-context.js → i-environment/i-environment.js} +0 -0
- package/out/interface/index.d.ts +2 -1
- package/out/interface/index.d.ts.map +1 -1
- package/out/interface/org-data/org-data.d.ts +43 -0
- package/out/interface/org-data/org-data.d.ts.map +1 -0
- package/out/interface/org-data/org-data.js +1 -0
- package/out/types.d.ts +38 -0
- package/out/types.d.ts.map +1 -0
- package/out/types.js +1 -0
- package/out/utils/index.d.ts +7 -0
- package/out/utils/index.d.ts.map +1 -0
- package/out/utils/index.js +6 -0
- package/out/utils/interceptor/interceptor.d.ts +13 -0
- package/out/utils/interceptor/interceptor.d.ts.map +1 -0
- package/out/utils/interceptor/interceptor.js +33 -0
- package/out/utils/namespace/namespace.d.ts +148 -0
- package/out/utils/namespace/namespace.d.ts.map +1 -0
- package/out/utils/namespace/namespace.js +216 -0
- package/out/utils/net/http-response.d.ts +94 -0
- package/out/utils/net/http-response.d.ts.map +1 -0
- package/out/utils/net/http-response.js +53 -0
- package/out/utils/net/net.d.ts +123 -0
- package/out/utils/net/net.d.ts.map +1 -0
- package/out/utils/net/net.js +197 -0
- package/out/utils/plural/plural.d.ts +21 -0
- package/out/utils/plural/plural.d.ts.map +1 -0
- package/out/utils/plural/plural.js +25 -0
- package/out/utils/util/util.d.ts +10 -0
- package/out/utils/util/util.d.ts.map +1 -0
- package/out/utils/util/util.js +13 -0
- package/package.json +22 -6
- package/src/constant/core/core.ts +23 -0
- package/src/constant/index.ts +1 -0
- package/src/context/index.ts +93 -0
- package/src/environment/environment.ts +12 -0
- package/src/ibizsys.ts +48 -0
- package/src/index.ts +9 -0
- package/src/install.ts +17 -0
- package/src/interface/i-environment/i-environment.ts +63 -0
- package/src/interface/index.ts +2 -0
- package/src/interface/org-data/org-data.ts +42 -0
- package/src/types.ts +43 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/interceptor/interceptor.ts +35 -0
- package/src/utils/namespace/namespace.ts +244 -0
- package/src/utils/net/http-response.ts +113 -0
- package/src/utils/net/net.ts +232 -0
- package/src/utils/plural/plural.ts +27 -0
- package/src/utils/util/util.ts +14 -0
- package/out/interface/i-context/i-context.d.ts +0 -12
- package/out/interface/i-context/i-context.d.ts.map +0 -1
|
@@ -0,0 +1,197 @@
|
|
|
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
|
+
get prefix() {
|
|
35
|
+
return this._prefix || ibiz.env.baseUrl;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Post 请求
|
|
39
|
+
*
|
|
40
|
+
* @author chitanda
|
|
41
|
+
* @date 2022-07-14 15:07:01
|
|
42
|
+
* @param {string} url
|
|
43
|
+
* @param {IParams} [params={}]
|
|
44
|
+
* @return {*} {Promise<IHttpResponse>}
|
|
45
|
+
*/
|
|
46
|
+
async post(url, data, params = {}, headers = {}) {
|
|
47
|
+
url = this.handleAppPresetParam(url, params);
|
|
48
|
+
const response = await axios({
|
|
49
|
+
method: 'post',
|
|
50
|
+
url,
|
|
51
|
+
data,
|
|
52
|
+
headers: Object.assign({ 'Content-Type': 'application/json;charset=UTF-8', Accept: 'application/json' }, headers),
|
|
53
|
+
});
|
|
54
|
+
return this.doResponseResult(response);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Get 请求
|
|
58
|
+
*
|
|
59
|
+
* @author chitanda
|
|
60
|
+
* @date 2022-07-14 15:07:08
|
|
61
|
+
* @param {string} url
|
|
62
|
+
* @param {IParams} [params={}]
|
|
63
|
+
* @return {*} {Promise<IHttpResponse>}
|
|
64
|
+
*/
|
|
65
|
+
async get(url, params = {}, headers = {}, option = {}) {
|
|
66
|
+
// if (params.srfparentdata) {
|
|
67
|
+
// Object.assign(params, params.srfparentdata);
|
|
68
|
+
// delete params.srfparentdata;
|
|
69
|
+
// }
|
|
70
|
+
url = this.attachUrlParam(url, params);
|
|
71
|
+
const response = await axios.get(url, Object.assign({ headers }, option));
|
|
72
|
+
return this.doResponseResult(response);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Delete 请求
|
|
76
|
+
*
|
|
77
|
+
* @author chitanda
|
|
78
|
+
* @date 2022-07-14 15:07:43
|
|
79
|
+
* @param {string} url
|
|
80
|
+
* @param {IParams} [params]
|
|
81
|
+
* @return {*} {Promise<IHttpResponse>}
|
|
82
|
+
*/
|
|
83
|
+
async delete(url, params, headers = {}) {
|
|
84
|
+
url = this.handleAppPresetParam(url, params);
|
|
85
|
+
const response = await axios.delete(url, { headers });
|
|
86
|
+
return this.doResponseResult(response);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Put 请求
|
|
90
|
+
*
|
|
91
|
+
* @author chitanda
|
|
92
|
+
* @date 2022-07-14 15:07:49
|
|
93
|
+
* @param {string} url
|
|
94
|
+
* @param {IData} data
|
|
95
|
+
* @return {*} {Promise<IHttpResponse>}
|
|
96
|
+
*/
|
|
97
|
+
async put(url, data, headers = {}) {
|
|
98
|
+
url = this.handleAppPresetParam(url, data);
|
|
99
|
+
const response = await axios.put(url, data, { headers });
|
|
100
|
+
return this.doResponseResult(response);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* 获取模型数据
|
|
104
|
+
*
|
|
105
|
+
* @author chitanda
|
|
106
|
+
* @date 2022-07-14 15:07:15
|
|
107
|
+
* @param {string} url
|
|
108
|
+
* @param {AxiosRequestHeaders} [headers={}]
|
|
109
|
+
* @return {*} {Promise<IHttpResponse>}
|
|
110
|
+
*/
|
|
111
|
+
async getModel(url, headers = {}) {
|
|
112
|
+
const response = await axios.get(url, {
|
|
113
|
+
headers,
|
|
114
|
+
});
|
|
115
|
+
return this.doResponseResult(response);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* 统一处理请求返回
|
|
119
|
+
*
|
|
120
|
+
* @author chitanda
|
|
121
|
+
* @date 2022-07-14 16:07:23
|
|
122
|
+
* @private
|
|
123
|
+
* @param {AxiosResponse} response
|
|
124
|
+
* @return {*} {IHttpResponse}
|
|
125
|
+
*/
|
|
126
|
+
doResponseResult(response) {
|
|
127
|
+
const res = response;
|
|
128
|
+
if (res.status >= 200 && res.status <= 299) {
|
|
129
|
+
res.ok = true;
|
|
130
|
+
}
|
|
131
|
+
return res;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* 处理平台预定义参数
|
|
135
|
+
*
|
|
136
|
+
* @author chitanda
|
|
137
|
+
* @date 2022-07-14 15:07:12
|
|
138
|
+
* @private
|
|
139
|
+
* @param {string} url
|
|
140
|
+
* @param {IParams} [params]
|
|
141
|
+
* @return {*} {string}
|
|
142
|
+
*/
|
|
143
|
+
handleAppPresetParam(url, params) {
|
|
144
|
+
if (params) {
|
|
145
|
+
const keys = Object.keys(params);
|
|
146
|
+
const tempParam = {};
|
|
147
|
+
keys.forEach((item) => {
|
|
148
|
+
if (item.startsWith('srf') && notNilEmpty(params[item])) {
|
|
149
|
+
tempParam[item] = params[item];
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
return this.attachUrlParam(url, params);
|
|
153
|
+
}
|
|
154
|
+
return url;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* url 附加请求参数
|
|
158
|
+
*
|
|
159
|
+
* @author chitanda
|
|
160
|
+
* @date 2022-07-14 15:07:34
|
|
161
|
+
* @private
|
|
162
|
+
* @param {string} url
|
|
163
|
+
* @param {IParams} params
|
|
164
|
+
* @return {*} {string}
|
|
165
|
+
*/
|
|
166
|
+
attachUrlParam(url, params) {
|
|
167
|
+
url = this.attachUrl(url);
|
|
168
|
+
const strParams = stringify(params);
|
|
169
|
+
if (notNilEmpty(strParams)) {
|
|
170
|
+
if (url.endsWith('?')) {
|
|
171
|
+
url = `${url}${strParams}`;
|
|
172
|
+
}
|
|
173
|
+
else if (url.indexOf('?') !== -1 && url.endsWith('&')) {
|
|
174
|
+
url = `${url}${strParams}`;
|
|
175
|
+
}
|
|
176
|
+
else if (url.indexOf('?') !== -1 && !url.endsWith('&')) {
|
|
177
|
+
url = `${url}&${strParams}`;
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
url = `${url}?${strParams}`;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return url;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* 处理 url 参数
|
|
187
|
+
*
|
|
188
|
+
* @author chitanda
|
|
189
|
+
* @date 2022-07-20 20:07:17
|
|
190
|
+
* @private
|
|
191
|
+
* @param {string} url
|
|
192
|
+
* @return {*} {string}
|
|
193
|
+
*/
|
|
194
|
+
attachUrl(url) {
|
|
195
|
+
return `${this.prefix}${url}`;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 英文转复数写法
|
|
3
|
+
*
|
|
4
|
+
* @author chitanda
|
|
5
|
+
* @date 2022-08-25 18:08:41
|
|
6
|
+
* @export
|
|
7
|
+
* @param {string} key
|
|
8
|
+
* @return {*} {string}
|
|
9
|
+
*/
|
|
10
|
+
export declare function plural(key: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* 英文转复数写法并转全小写
|
|
13
|
+
*
|
|
14
|
+
* @author chitanda
|
|
15
|
+
* @date 2022-08-25 18:08:23
|
|
16
|
+
* @export
|
|
17
|
+
* @param {string} key
|
|
18
|
+
* @return {*} {string}
|
|
19
|
+
*/
|
|
20
|
+
export declare function pluralLower(key: string): string;
|
|
21
|
+
//# sourceMappingURL=plural.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plural.d.ts","sourceRoot":"","sources":["../../../src/utils/plural/plural.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE1C;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE/C"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import pluralize from 'pluralize';
|
|
2
|
+
/**
|
|
3
|
+
* 英文转复数写法
|
|
4
|
+
*
|
|
5
|
+
* @author chitanda
|
|
6
|
+
* @date 2022-08-25 18:08:41
|
|
7
|
+
* @export
|
|
8
|
+
* @param {string} key
|
|
9
|
+
* @return {*} {string}
|
|
10
|
+
*/
|
|
11
|
+
export function plural(key) {
|
|
12
|
+
return pluralize(key);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 英文转复数写法并转全小写
|
|
16
|
+
*
|
|
17
|
+
* @author chitanda
|
|
18
|
+
* @date 2022-08-25 18:08:23
|
|
19
|
+
* @export
|
|
20
|
+
* @param {string} key
|
|
21
|
+
* @return {*} {string}
|
|
22
|
+
*/
|
|
23
|
+
export function pluralLower(key) {
|
|
24
|
+
return plural(key).toLowerCase();
|
|
25
|
+
}
|
|
@@ -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,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ibiz-template/core",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.0.1-alpha.3",
|
|
4
|
+
"description": "核心包",
|
|
5
5
|
"main": "out/index.js",
|
|
6
|
-
"types": "out/
|
|
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
|
-
"lint": "eslint src/**/*.ts",
|
|
14
|
+
"lint": "eslint 'src/**/*.ts'",
|
|
15
|
+
"lint:fix": "eslint --fix 'src/**/*.ts'",
|
|
14
16
|
"clean": "rimraf out",
|
|
17
|
+
"test": "jest",
|
|
15
18
|
"publish:next": "npm run build && npm publish --access public --tag next",
|
|
16
19
|
"publish:npm": "npm run build && npm publish --access public"
|
|
17
20
|
},
|
|
18
21
|
"author": "chitanda",
|
|
19
22
|
"license": "MIT",
|
|
20
|
-
"dependencies": {
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"axios": "^0.27.2",
|
|
25
|
+
"pluralize": "^8.0.0",
|
|
26
|
+
"qs": "^6.11.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/pluralize": "^0.0.29",
|
|
30
|
+
"@types/qs": "^6.9.7",
|
|
31
|
+
"qx-util": "^0.4.0"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"qx-util": "^0.4.0"
|
|
35
|
+
},
|
|
36
|
+
"gitHead": "18f541775c71975fec7f07524e9b8c0135dedbf6"
|
|
21
37
|
}
|
|
@@ -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] !== 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
|
+
/**
|
|
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
|
+
}
|
package/src/ibizsys.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Environment } from './environment/environment';
|
|
2
|
+
import { OrgData } from './interface';
|
|
3
|
+
import { Net } from './utils';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 全局对象
|
|
7
|
+
*
|
|
8
|
+
* @author chitanda
|
|
9
|
+
* @date 2022-07-19 16:07:50
|
|
10
|
+
* @export
|
|
11
|
+
* @class IBizSys
|
|
12
|
+
*/
|
|
13
|
+
export class IBizSys {
|
|
14
|
+
/**
|
|
15
|
+
* 环境变量
|
|
16
|
+
*
|
|
17
|
+
* @author chitanda
|
|
18
|
+
* @date 2022-07-19 18:07:04
|
|
19
|
+
*/
|
|
20
|
+
env = Environment;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 网络请求工具类
|
|
24
|
+
*
|
|
25
|
+
* @author chitanda
|
|
26
|
+
* @date 2022-07-19 17:07:56
|
|
27
|
+
* @type {Net}
|
|
28
|
+
*/
|
|
29
|
+
net: Net = new Net();
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* sass 模式下的中心系统标识
|
|
33
|
+
*
|
|
34
|
+
* @author chitanda
|
|
35
|
+
* @date 2022-07-19 18:07:23
|
|
36
|
+
* @type {string}
|
|
37
|
+
*/
|
|
38
|
+
orgData?: OrgData;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 应用数据
|
|
42
|
+
*
|
|
43
|
+
* @author chitanda
|
|
44
|
+
* @date 2022-07-20 19:07:22
|
|
45
|
+
* @type {IData}
|
|
46
|
+
*/
|
|
47
|
+
appData?: IData;
|
|
48
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import './types';
|
|
2
|
+
|
|
3
|
+
export * from './constant';
|
|
4
|
+
export { IBizContext, IBizContextProxyHandle } from './context';
|
|
5
|
+
export { Environment } from './environment/environment';
|
|
6
|
+
export * from './interface';
|
|
7
|
+
export * from './utils';
|
|
8
|
+
export { IBizSys } from './ibizsys';
|
|
9
|
+
export { install } from './install';
|
package/src/install.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
throw new Error('ibiz 已经存在, 无需重复安装');
|
|
14
|
+
}
|
|
15
|
+
window.ibiz = new IBizSys();
|
|
16
|
+
new Interceptor();
|
|
17
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
/**
|
|
11
|
+
* 命名空间
|
|
12
|
+
*
|
|
13
|
+
* @author chitanda
|
|
14
|
+
* @date 2022-09-06 11:09:32
|
|
15
|
+
* @type {string}
|
|
16
|
+
*/
|
|
17
|
+
namespace?: string;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 请求根路径
|
|
21
|
+
*
|
|
22
|
+
* @author chitanda
|
|
23
|
+
* @date 2022-07-19 18:07:58
|
|
24
|
+
* @type {string}
|
|
25
|
+
*/
|
|
26
|
+
baseUrl: string;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 资源文件根路径
|
|
30
|
+
*
|
|
31
|
+
* @author lxm
|
|
32
|
+
* @date 2022-08-25 14:08:08
|
|
33
|
+
* @type {string}
|
|
34
|
+
*/
|
|
35
|
+
assetsUrl: string;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 中心系统标识
|
|
39
|
+
*
|
|
40
|
+
* @author chitanda
|
|
41
|
+
* @date 2022-08-22 23:08:46
|
|
42
|
+
* @type {string}
|
|
43
|
+
*/
|
|
44
|
+
dcSystem: string;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 文件导出
|
|
48
|
+
*
|
|
49
|
+
* @author chitanda
|
|
50
|
+
* @date 2022-08-22 23:08:46
|
|
51
|
+
* @type {string}
|
|
52
|
+
*/
|
|
53
|
+
ExportFile: string;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* 文件上传
|
|
57
|
+
*
|
|
58
|
+
* @author chitanda
|
|
59
|
+
* @date 2022-08-22 23:08:46
|
|
60
|
+
* @type {string}
|
|
61
|
+
*/
|
|
62
|
+
UploadFile: string;
|
|
63
|
+
}
|
|
@@ -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
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { IBizSys } from './ibizsys';
|
|
3
|
+
|
|
4
|
+
declare global {
|
|
5
|
+
const ibiz: IBizSys;
|
|
6
|
+
|
|
7
|
+
interface Window {
|
|
8
|
+
ibiz: IBizSys;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 上下文
|
|
13
|
+
*
|
|
14
|
+
* @author chitanda
|
|
15
|
+
* @date 2022-07-14 15:07:52
|
|
16
|
+
* @interface IContext
|
|
17
|
+
*/
|
|
18
|
+
interface IContext {
|
|
19
|
+
[key: string | symbol]: any;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 参数
|
|
24
|
+
*
|
|
25
|
+
* @author chitanda
|
|
26
|
+
* @date 2022-07-14 15:07:57
|
|
27
|
+
* @interface IParams
|
|
28
|
+
*/
|
|
29
|
+
interface IParams {
|
|
30
|
+
[key: string | symbol]: any;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 数据
|
|
35
|
+
*
|
|
36
|
+
* @author chitanda
|
|
37
|
+
* @date 2022-07-14 15:07:31
|
|
38
|
+
* @interface IData
|
|
39
|
+
*/
|
|
40
|
+
interface IData {
|
|
41
|
+
[key: string | symbol]: any;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { Interceptor } from './interceptor/interceptor';
|
|
2
|
+
export { Namespace } from './namespace/namespace';
|
|
3
|
+
export { IHttpResponse, HttpResponse } from './net/http-response';
|
|
4
|
+
export { Net } from './net/net';
|
|
5
|
+
export { plural, pluralLower } from './plural/plural';
|
|
6
|
+
export * from './util/util';
|