@ibiz-template/core 0.0.1-alpha.2 → 0.0.1-alpha.22
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/dist/system/index.system.js +1 -0
- package/out/constant/http-status-message/http-status-message.d.ts +5 -0
- package/out/constant/http-status-message/http-status-message.d.ts.map +1 -0
- package/out/constant/http-status-message/http-status-message.js +20 -0
- package/out/constant/index.d.ts +3 -0
- package/out/constant/index.d.ts.map +1 -1
- package/out/constant/index.js +3 -0
- package/out/constant/login-mode/login-mode.d.ts +23 -0
- package/out/constant/login-mode/login-mode.d.ts.map +1 -0
- package/out/constant/login-mode/login-mode.js +24 -0
- package/out/constant/menu-permission-mode/menu-permission-mode.d.ts +23 -0
- package/out/constant/menu-permission-mode/menu-permission-mode.d.ts.map +1 -0
- package/out/constant/menu-permission-mode/menu-permission-mode.js +24 -0
- package/out/context/index.d.ts +2 -39
- package/out/context/index.d.ts.map +1 -1
- package/out/context/index.js +34 -65
- package/out/environment/environment.d.ts.map +1 -1
- package/out/environment/environment.js +7 -1
- package/out/error/http-error/http-error.d.ts +18 -0
- package/out/error/http-error/http-error.d.ts.map +1 -0
- package/out/error/http-error/http-error.js +36 -0
- package/out/error/index.d.ts +3 -0
- package/out/error/index.d.ts.map +1 -0
- package/out/error/index.js +2 -0
- package/out/error/runtime-error/runtime-error.d.ts +15 -0
- package/out/error/runtime-error/runtime-error.d.ts.map +1 -0
- package/out/error/runtime-error/runtime-error.js +15 -0
- package/out/index.d.ts +2 -1
- package/out/index.d.ts.map +1 -1
- package/out/index.js +2 -1
- package/out/interface/i-environment/i-environment.d.ts +41 -0
- package/out/interface/i-environment/i-environment.d.ts.map +1 -1
- package/out/types.d.ts +10 -0
- package/out/types.d.ts.map +1 -1
- package/out/utils/index.d.ts +1 -0
- package/out/utils/index.d.ts.map +1 -1
- package/out/utils/index.js +1 -0
- package/out/utils/net/http-response.d.ts +1 -1
- package/out/utils/net/http-response.d.ts.map +1 -1
- package/out/utils/net/net.d.ts +1 -1
- package/out/utils/net/net.d.ts.map +1 -1
- package/out/utils/net/net.js +45 -19
- package/out/utils/plural/plural.js +1 -1
- package/out/utils/url-helper/url-helper.d.ts +51 -0
- package/out/utils/url-helper/url-helper.d.ts.map +1 -0
- package/out/utils/url-helper/url-helper.js +59 -0
- package/out/utils/util/util.d.ts +29 -0
- package/out/utils/util/util.d.ts.map +1 -1
- package/out/utils/util/util.js +50 -0
- package/package.json +15 -6
- package/src/constant/http-status-message/http-status-message.ts +20 -0
- package/src/constant/index.ts +3 -0
- package/src/constant/login-mode/login-mode.ts +23 -0
- package/src/constant/menu-permission-mode/menu-permission-mode.ts +23 -0
- package/src/context/index.ts +35 -69
- package/src/environment/environment.ts +7 -1
- package/src/error/http-error/http-error.ts +43 -0
- package/src/error/index.ts +2 -0
- package/src/error/runtime-error/runtime-error.ts +14 -0
- package/src/index.ts +2 -1
- package/src/interface/i-environment/i-environment.ts +47 -0
- package/src/types.ts +11 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/net/http-response.ts +1 -1
- package/src/utils/net/net.ts +45 -23
- package/src/utils/plural/plural.ts +1 -1
- package/src/utils/url-helper/url-helper.ts +62 -0
- package/src/utils/util/util.ts +64 -0
package/out/utils/net/net.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ export declare class Net {
|
|
|
66
66
|
* @param {IData} data
|
|
67
67
|
* @return {*} {Promise<IHttpResponse>}
|
|
68
68
|
*/
|
|
69
|
-
put(url: string, data: IData, headers?: AxiosRequestHeaders): Promise<IHttpResponse>;
|
|
69
|
+
put(url: string, data: IData, params?: IParams, headers?: AxiosRequestHeaders): Promise<IHttpResponse>;
|
|
70
70
|
/**
|
|
71
71
|
* 获取模型数据
|
|
72
72
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"net.d.ts","sourceRoot":"","sources":["../../../src/utils/net/net.ts"],"names":[],"mappings":"AAAA,OAAc,
|
|
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,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,aAAa,CAAC;IAWzB;;;;;;;;OAQG;IACH,OAAO,CAAC,gBAAgB;IAQxB;;;;;;;;;OASG;IACH,OAAO,CAAC,oBAAoB;IAc5B;;;;;;;;;OASG;IACH,OAAO,CAAC,cAAc;IAiBtB;;;;;;;;OAQG;IACH,OAAO,CAAC,SAAS;CAGlB"}
|
package/out/utils/net/net.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import { stringify } from 'qs';
|
|
3
3
|
import { notNilEmpty } from 'qx-util';
|
|
4
|
+
import { HttpError } from '../../error';
|
|
4
5
|
/**
|
|
5
6
|
* 全局请求工具类
|
|
6
7
|
*
|
|
@@ -45,13 +46,18 @@ export class Net {
|
|
|
45
46
|
*/
|
|
46
47
|
async post(url, data, params = {}, headers = {}) {
|
|
47
48
|
url = this.handleAppPresetParam(url, params);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
try {
|
|
50
|
+
const response = await axios({
|
|
51
|
+
method: 'post',
|
|
52
|
+
url,
|
|
53
|
+
data,
|
|
54
|
+
headers: Object.assign({ 'Content-Type': 'application/json;charset=UTF-8', Accept: 'application/json' }, headers),
|
|
55
|
+
});
|
|
56
|
+
return this.doResponseResult(response);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
throw new HttpError(error);
|
|
60
|
+
}
|
|
55
61
|
}
|
|
56
62
|
/**
|
|
57
63
|
* Get 请求
|
|
@@ -68,8 +74,13 @@ export class Net {
|
|
|
68
74
|
// delete params.srfparentdata;
|
|
69
75
|
// }
|
|
70
76
|
url = this.attachUrlParam(url, params);
|
|
71
|
-
|
|
72
|
-
|
|
77
|
+
try {
|
|
78
|
+
const response = await axios.get(url, Object.assign({ headers }, option));
|
|
79
|
+
return this.doResponseResult(response);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
throw new HttpError(error);
|
|
83
|
+
}
|
|
73
84
|
}
|
|
74
85
|
/**
|
|
75
86
|
* Delete 请求
|
|
@@ -82,8 +93,13 @@ export class Net {
|
|
|
82
93
|
*/
|
|
83
94
|
async delete(url, params, headers = {}) {
|
|
84
95
|
url = this.handleAppPresetParam(url, params);
|
|
85
|
-
|
|
86
|
-
|
|
96
|
+
try {
|
|
97
|
+
const response = await axios.delete(url, { headers });
|
|
98
|
+
return this.doResponseResult(response);
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
throw new HttpError(error);
|
|
102
|
+
}
|
|
87
103
|
}
|
|
88
104
|
/**
|
|
89
105
|
* Put 请求
|
|
@@ -94,10 +110,15 @@ export class Net {
|
|
|
94
110
|
* @param {IData} data
|
|
95
111
|
* @return {*} {Promise<IHttpResponse>}
|
|
96
112
|
*/
|
|
97
|
-
async put(url, data, headers = {}) {
|
|
98
|
-
url = this.handleAppPresetParam(url,
|
|
99
|
-
|
|
100
|
-
|
|
113
|
+
async put(url, data, params = {}, headers = {}) {
|
|
114
|
+
url = this.handleAppPresetParam(url, params);
|
|
115
|
+
try {
|
|
116
|
+
const response = await axios.put(url, data, { headers });
|
|
117
|
+
return this.doResponseResult(response);
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
throw new HttpError(error);
|
|
121
|
+
}
|
|
101
122
|
}
|
|
102
123
|
/**
|
|
103
124
|
* 获取模型数据
|
|
@@ -109,10 +130,15 @@ export class Net {
|
|
|
109
130
|
* @return {*} {Promise<IHttpResponse>}
|
|
110
131
|
*/
|
|
111
132
|
async getModel(url, headers = {}) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
133
|
+
try {
|
|
134
|
+
const response = await axios.get(url, {
|
|
135
|
+
headers,
|
|
136
|
+
});
|
|
137
|
+
return this.doResponseResult(response);
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
throw new HttpError(error);
|
|
141
|
+
}
|
|
116
142
|
}
|
|
117
143
|
/**
|
|
118
144
|
* 统一处理请求返回
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 路径解析助手
|
|
3
|
+
*
|
|
4
|
+
* @author lxm
|
|
5
|
+
* @date 2022-10-11 14:10:12
|
|
6
|
+
* @export
|
|
7
|
+
* @class UrlHelper
|
|
8
|
+
*/
|
|
9
|
+
export declare class UrlHelper {
|
|
10
|
+
/**
|
|
11
|
+
* 路由路径前面的基础路径
|
|
12
|
+
* 如:http://172.16.103.120:30061/portalwebapp/#/index/appportalview?params=123
|
|
13
|
+
* 返回:http://172.16.103.120:30061/portalwebapp/#
|
|
14
|
+
*
|
|
15
|
+
* @author lxm
|
|
16
|
+
* @date 2022-10-11 20:10:29
|
|
17
|
+
* @returns {*}
|
|
18
|
+
*/
|
|
19
|
+
static get routeBase(): string;
|
|
20
|
+
/**
|
|
21
|
+
* 应用的的基础路径
|
|
22
|
+
* 如:http://172.16.103.120:30061/portalwebapp/#/index/appportalview?params=123
|
|
23
|
+
* 返回:http://172.16.103.120:30061/portalwebapp
|
|
24
|
+
*
|
|
25
|
+
* @author lxm
|
|
26
|
+
* @date 2022-10-11 20:10:29
|
|
27
|
+
* @returns {*}
|
|
28
|
+
*/
|
|
29
|
+
static get appBase(): string;
|
|
30
|
+
/**
|
|
31
|
+
* #开始到末尾,即路由地址
|
|
32
|
+
* 如:http://172.16.103.120:30061/portalwebapp/#/index/appportalview?params=123
|
|
33
|
+
* 返回:/index/appportalview?params=123
|
|
34
|
+
*
|
|
35
|
+
* @author lxm
|
|
36
|
+
* @date 2022-10-11 16:10:40
|
|
37
|
+
* @returns {*}
|
|
38
|
+
*/
|
|
39
|
+
static get routePath(): string;
|
|
40
|
+
/**
|
|
41
|
+
* 当前地址的全路径,包含域名和参数
|
|
42
|
+
* 如:http://172.16.103.120:30061/portalwebapp/#/index/appportalview?params=123
|
|
43
|
+
*
|
|
44
|
+
* @author lxm
|
|
45
|
+
* @date 2022-10-11 21:10:39
|
|
46
|
+
* @readonly
|
|
47
|
+
* @static
|
|
48
|
+
*/
|
|
49
|
+
static get fullPath(): string;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=url-helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-helper.d.ts","sourceRoot":"","sources":["../../../src/utils/url-helper/url-helper.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,qBAAa,SAAS;IACpB;;;;;;;;OAQG;IACH,MAAM,KAAK,SAAS,WAEnB;IAED;;;;;;;;OAQG;IACH,MAAM,KAAK,OAAO,WAGjB;IAED;;;;;;;;OAQG;IACH,MAAM,KAAK,SAAS,WAEnB;IAED;;;;;;;;OAQG;IACH,MAAM,KAAK,QAAQ,WAElB;CACF"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 路径解析助手
|
|
3
|
+
*
|
|
4
|
+
* @author lxm
|
|
5
|
+
* @date 2022-10-11 14:10:12
|
|
6
|
+
* @export
|
|
7
|
+
* @class UrlHelper
|
|
8
|
+
*/
|
|
9
|
+
export class UrlHelper {
|
|
10
|
+
/**
|
|
11
|
+
* 路由路径前面的基础路径
|
|
12
|
+
* 如:http://172.16.103.120:30061/portalwebapp/#/index/appportalview?params=123
|
|
13
|
+
* 返回:http://172.16.103.120:30061/portalwebapp/#
|
|
14
|
+
*
|
|
15
|
+
* @author lxm
|
|
16
|
+
* @date 2022-10-11 20:10:29
|
|
17
|
+
* @returns {*}
|
|
18
|
+
*/
|
|
19
|
+
static get routeBase() {
|
|
20
|
+
return `${this.appBase}/#`;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 应用的的基础路径
|
|
24
|
+
* 如:http://172.16.103.120:30061/portalwebapp/#/index/appportalview?params=123
|
|
25
|
+
* 返回:http://172.16.103.120:30061/portalwebapp
|
|
26
|
+
*
|
|
27
|
+
* @author lxm
|
|
28
|
+
* @date 2022-10-11 20:10:29
|
|
29
|
+
* @returns {*}
|
|
30
|
+
*/
|
|
31
|
+
static get appBase() {
|
|
32
|
+
const { origin, pathname } = window.location;
|
|
33
|
+
return `${origin}${pathname}`.replace(/\/$/, '');
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* #开始到末尾,即路由地址
|
|
37
|
+
* 如:http://172.16.103.120:30061/portalwebapp/#/index/appportalview?params=123
|
|
38
|
+
* 返回:/index/appportalview?params=123
|
|
39
|
+
*
|
|
40
|
+
* @author lxm
|
|
41
|
+
* @date 2022-10-11 16:10:40
|
|
42
|
+
* @returns {*}
|
|
43
|
+
*/
|
|
44
|
+
static get routePath() {
|
|
45
|
+
return window.location.hash.replace('#', '');
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* 当前地址的全路径,包含域名和参数
|
|
49
|
+
* 如:http://172.16.103.120:30061/portalwebapp/#/index/appportalview?params=123
|
|
50
|
+
*
|
|
51
|
+
* @author lxm
|
|
52
|
+
* @date 2022-10-11 21:10:39
|
|
53
|
+
* @readonly
|
|
54
|
+
* @static
|
|
55
|
+
*/
|
|
56
|
+
static get fullPath() {
|
|
57
|
+
return window.location.href;
|
|
58
|
+
}
|
|
59
|
+
}
|
package/out/utils/util/util.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DebounceSettings } from 'lodash-es';
|
|
1
2
|
/**
|
|
2
3
|
* 获取认证令牌
|
|
3
4
|
*
|
|
@@ -7,4 +8,32 @@
|
|
|
7
8
|
* @return {*} {(string | null)}
|
|
8
9
|
*/
|
|
9
10
|
export declare function getToken(): string | null;
|
|
11
|
+
/**
|
|
12
|
+
* 判断两个数组是否有相同的元素
|
|
13
|
+
*
|
|
14
|
+
* @author lxm
|
|
15
|
+
* @date 2022-09-20 19:09:29
|
|
16
|
+
* @export
|
|
17
|
+
* @param {any[]} arr1
|
|
18
|
+
* @param {any[]} arr2
|
|
19
|
+
* @returns {*} {boolean}
|
|
20
|
+
*/
|
|
21
|
+
export declare function isOverlap(arr1: any[], arr2: any[]): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* 防抖并合并每次的参数
|
|
24
|
+
*
|
|
25
|
+
* @author lxm
|
|
26
|
+
* @date 2022-09-20 21:09:53
|
|
27
|
+
* @export
|
|
28
|
+
* @template T
|
|
29
|
+
* @param {T} func 要防抖的函数
|
|
30
|
+
* @param {(
|
|
31
|
+
* oldParams: Parameters<T>,
|
|
32
|
+
* newParams: Parameters<T>,
|
|
33
|
+
* ) => Parameters<T>} mergeFunc 合并的回调函数
|
|
34
|
+
* @param {number} [wait] 防抖的延迟毫秒数
|
|
35
|
+
* @param {DebounceSettings} [options] 防抖函数的额外参数
|
|
36
|
+
* @returns {*}
|
|
37
|
+
*/
|
|
38
|
+
export declare function debounceAndMerge<T extends (...args: any[]) => any>(func: T, mergeFunc: (oldParams: Parameters<T>, newParams: Parameters<T>) => Parameters<T>, wait?: number, options?: DebounceSettings): (...args: Parameters<T>) => any;
|
|
10
39
|
//# sourceMappingURL=util.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/utils/util/util.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/utils/util/util.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAIvD;;;;;;;GAOG;AACH,wBAAgB,QAAQ,IAAI,MAAM,GAAG,IAAI,CAExC;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAG3D;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAChE,IAAI,EAAE,CAAC,EACP,SAAS,EAAE,CACT,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,EACxB,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,KACrB,UAAU,CAAC,CAAC,CAAC,EAClB,IAAI,CAAC,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,gBAAgB,aAaT,WAAW,CAAC,CAAC,SAS/B"}
|
package/out/utils/util/util.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { debounce } from 'lodash-es';
|
|
1
3
|
import { getCookie } from 'qx-util';
|
|
2
4
|
import { CoreConst } from '../../constant';
|
|
3
5
|
/**
|
|
@@ -11,3 +13,51 @@ import { CoreConst } from '../../constant';
|
|
|
11
13
|
export function getToken() {
|
|
12
14
|
return getCookie(CoreConst.TOKEN);
|
|
13
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* 判断两个数组是否有相同的元素
|
|
18
|
+
*
|
|
19
|
+
* @author lxm
|
|
20
|
+
* @date 2022-09-20 19:09:29
|
|
21
|
+
* @export
|
|
22
|
+
* @param {any[]} arr1
|
|
23
|
+
* @param {any[]} arr2
|
|
24
|
+
* @returns {*} {boolean}
|
|
25
|
+
*/
|
|
26
|
+
export function isOverlap(arr1, arr2) {
|
|
27
|
+
const newArr = Array.from(new Set([...arr1, ...arr2]));
|
|
28
|
+
return newArr.length !== arr1.length + arr2.length;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 防抖并合并每次的参数
|
|
32
|
+
*
|
|
33
|
+
* @author lxm
|
|
34
|
+
* @date 2022-09-20 21:09:53
|
|
35
|
+
* @export
|
|
36
|
+
* @template T
|
|
37
|
+
* @param {T} func 要防抖的函数
|
|
38
|
+
* @param {(
|
|
39
|
+
* oldParams: Parameters<T>,
|
|
40
|
+
* newParams: Parameters<T>,
|
|
41
|
+
* ) => Parameters<T>} mergeFunc 合并的回调函数
|
|
42
|
+
* @param {number} [wait] 防抖的延迟毫秒数
|
|
43
|
+
* @param {DebounceSettings} [options] 防抖函数的额外参数
|
|
44
|
+
* @returns {*}
|
|
45
|
+
*/
|
|
46
|
+
export function debounceAndMerge(func, mergeFunc, wait, options) {
|
|
47
|
+
// 缓存上一次的函数参数
|
|
48
|
+
let oldParams;
|
|
49
|
+
const debounceFunc = debounce((...params) => {
|
|
50
|
+
// 防抖函数执行的时候清空缓存参数
|
|
51
|
+
oldParams = undefined;
|
|
52
|
+
return func(...params);
|
|
53
|
+
}, wait, options);
|
|
54
|
+
return (...args) => {
|
|
55
|
+
// 合并参数,并把参数缓存到oldParams里,用新参数调用防抖函数
|
|
56
|
+
let newParams = args;
|
|
57
|
+
if (oldParams) {
|
|
58
|
+
newParams = mergeFunc(oldParams, newParams);
|
|
59
|
+
}
|
|
60
|
+
oldParams = newParams;
|
|
61
|
+
return debounceFunc(...newParams);
|
|
62
|
+
};
|
|
63
|
+
}
|
package/package.json
CHANGED
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ibiz-template/core",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.22",
|
|
4
4
|
"description": "核心包",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "out/index.js",
|
|
6
7
|
"types": "out/index.d.ts",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://gitee.com/iBizModeling/ibiz-template.git"
|
|
11
|
+
},
|
|
7
12
|
"files": [
|
|
13
|
+
"dist",
|
|
8
14
|
"out",
|
|
9
15
|
"src"
|
|
10
16
|
],
|
|
11
17
|
"scripts": {
|
|
12
18
|
"dev": "tsc --watch",
|
|
13
|
-
"build": "npm run lint && npm run clean && tsc --build",
|
|
19
|
+
"build": "npm run lint && npm run clean && npm run build:rollup && tsc --build",
|
|
20
|
+
"build:rollup": "rollup -c",
|
|
14
21
|
"lint": "eslint 'src/**/*.ts'",
|
|
15
22
|
"lint:fix": "eslint --fix 'src/**/*.ts'",
|
|
16
|
-
"clean": "rimraf out",
|
|
23
|
+
"clean": "rimraf out dist",
|
|
17
24
|
"test": "jest",
|
|
18
25
|
"publish:next": "npm run build && npm publish --access public --tag next",
|
|
19
26
|
"publish:npm": "npm run build && npm publish --access public"
|
|
@@ -28,10 +35,12 @@
|
|
|
28
35
|
"devDependencies": {
|
|
29
36
|
"@types/pluralize": "^0.0.29",
|
|
30
37
|
"@types/qs": "^6.9.7",
|
|
31
|
-
"
|
|
38
|
+
"lodash-es": "^4.17.21",
|
|
39
|
+
"qx-util": "^0.4.1"
|
|
32
40
|
},
|
|
33
41
|
"peerDependencies": {
|
|
34
|
-
"
|
|
42
|
+
"lodash-es": "^4.17.21",
|
|
43
|
+
"qx-util": "^0.4.1"
|
|
35
44
|
},
|
|
36
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "ee99fd73db659de30803eaac0901b1f9b4b6147a"
|
|
37
46
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 请求状态码文本
|
|
3
|
+
*/
|
|
4
|
+
export const HttpStatusMessageConst: Record<number, string> = {
|
|
5
|
+
200: '服务器成功返回请求的数据。',
|
|
6
|
+
201: '新建或修改数据成功。',
|
|
7
|
+
202: '一个请求已经进入后台排队(异步任务)。',
|
|
8
|
+
204: '删除数据成功。',
|
|
9
|
+
400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。',
|
|
10
|
+
401: '用户没有权限(令牌、用户名、密码错误)。',
|
|
11
|
+
403: '用户得到授权,但是访问是被禁止的。',
|
|
12
|
+
404: '发出的请求针对的是不存在的记录,服务器没有进行操作。',
|
|
13
|
+
406: '请求的格式不可得。',
|
|
14
|
+
410: '请求的资源被永久删除,且不会再得到的。',
|
|
15
|
+
422: '当创建一个对象时,发生一个验证错误。',
|
|
16
|
+
500: '服务器发生错误,请检查服务器。',
|
|
17
|
+
502: '网关错误。',
|
|
18
|
+
503: '服务不可用,服务器暂时过载或维护。',
|
|
19
|
+
504: '网关超时。',
|
|
20
|
+
};
|
package/src/constant/index.ts
CHANGED
|
@@ -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
|
+
}
|
package/src/context/index.ts
CHANGED
|
@@ -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
|
-
|
|
23
|
+
// eslint-disable-next-line default-param-last
|
|
24
|
+
constructor(context: IContext = {}, parent?: IBizContext) {
|
|
65
25
|
if (parent) {
|
|
66
|
-
|
|
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
|
-
|
|
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,3 +1,4 @@
|
|
|
1
|
+
import { LoginMode, MenuPermissionMode } from '../constant';
|
|
1
2
|
import { IEnvironment } from '../interface';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -5,8 +6,13 @@ import { IEnvironment } from '../interface';
|
|
|
5
6
|
*/
|
|
6
7
|
export const Environment: IEnvironment = {
|
|
7
8
|
baseUrl: '',
|
|
8
|
-
|
|
9
|
+
remoteModelUrl: '/remotemodel',
|
|
10
|
+
assetsUrl: './assets',
|
|
9
11
|
dcSystem: '',
|
|
10
12
|
ExportFile: '/ibizutil/download',
|
|
11
13
|
UploadFile: '/ibizutil/upload',
|
|
14
|
+
casLoginUrl: '',
|
|
15
|
+
loginMode: LoginMode.DEFAULT,
|
|
16
|
+
menuPermissionMode: MenuPermissionMode.MIXIN,
|
|
17
|
+
enablePermission: true,
|
|
12
18
|
};
|
|
@@ -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,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
|
+
}
|