@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.
- 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 +9 -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/factory-center.d.ts +11 -0
- package/out/factory-center.d.ts.map +1 -0
- package/out/factory-center.js +10 -0
- package/out/index.d.ts +3 -1
- package/out/index.d.ts.map +1 -1
- package/out/index.js +3 -1
- package/out/install.d.ts.map +1 -1
- package/out/install.js +2 -0
- package/out/interface/i-environment/i-environment.d.ts +59 -0
- package/out/interface/i-environment/i-environment.d.ts.map +1 -1
- package/out/types.d.ts +20 -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 +4 -9
- package/out/utils/net/http-response.d.ts.map +1 -1
- package/out/utils/net/http-response.js +0 -7
- package/out/utils/net/net.d.ts +18 -11
- package/out/utils/net/net.d.ts.map +1 -1
- package/out/utils/net/net.js +57 -24
- 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 +19 -7
- 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 +9 -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/factory-center.ts +9 -0
- package/src/index.ts +3 -1
- package/src/install.ts +2 -0
- package/src/interface/i-environment/i-environment.ts +67 -0
- package/src/types.ts +21 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/net/http-response.ts +6 -9
- package/src/utils/net/net.ts +66 -33
- package/src/utils/url-helper/url-helper.ts +62 -0
- package/src/utils/util/util.ts +64 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i-environment.d.ts","sourceRoot":"","sources":["../../../src/interface/i-environment/i-environment.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;;;OAMG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;;;OAMG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;;;;OAMG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;;;;OAMG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;;OAMG;IACH,UAAU,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"i-environment.d.ts","sourceRoot":"","sources":["../../../src/interface/i-environment/i-environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAE/D;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;;;;OAOG;IACH,GAAG,EAAE,OAAO,CAAC;IAEb;;;;;;;OAOG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;;;OAMG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;;;OAMG;IACH,SAAS,EAAE,SAAS,CAAC;IAErB;;;;;;OAMG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;;;;OAMG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;;;;;OAMG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;;;;OAMG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;;;;OAMG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;;OAMG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;;OAMG;IACH,gBAAgB,EAAE,OAAO,CAAC;IAE1B;;;;;;OAMG;IACH,kBAAkB,EAAE,kBAAkB,CAAC;CACxC"}
|
package/out/types.d.ts
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
|
+
import { FactoryCenter } from './factory-center';
|
|
1
2
|
import { IBizSys } from './ibizsys';
|
|
2
3
|
declare global {
|
|
3
4
|
const ibiz: IBizSys;
|
|
5
|
+
const ___fc: FactoryCenter;
|
|
4
6
|
interface Window {
|
|
5
7
|
ibiz: IBizSys;
|
|
8
|
+
/**
|
|
9
|
+
* 全局工厂中心
|
|
10
|
+
*
|
|
11
|
+
* @author lxm
|
|
12
|
+
* @date 2022-10-17 15:10:43
|
|
13
|
+
* @type {FactoryCenter}
|
|
14
|
+
*/
|
|
15
|
+
___fc: FactoryCenter;
|
|
6
16
|
}
|
|
7
17
|
/**
|
|
8
18
|
* 上下文
|
|
@@ -34,5 +44,15 @@ declare global {
|
|
|
34
44
|
interface IData {
|
|
35
45
|
[key: string | symbol]: any;
|
|
36
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* 任意对象结构
|
|
49
|
+
*
|
|
50
|
+
* @author chitanda
|
|
51
|
+
* @date 2022-09-21 15:09:30
|
|
52
|
+
* @interface IObject
|
|
53
|
+
*/
|
|
54
|
+
interface IObject {
|
|
55
|
+
[key: string | symbol]: any;
|
|
56
|
+
}
|
|
37
57
|
}
|
|
38
58
|
//# sourceMappingURL=types.d.ts.map
|
package/out/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,CAAC,MAAM,CAAC;IACb,MAAM,IAAI,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,CAAC,MAAM,CAAC;IACb,MAAM,IAAI,EAAE,OAAO,CAAC;IACpB,MAAM,KAAK,EAAE,aAAa,CAAC;IAE3B,UAAU,MAAM;QACd,IAAI,EAAE,OAAO,CAAC;QACd;;;;;;WAMG;QACH,KAAK,EAAE,aAAa,CAAC;KACtB;IAED;;;;;;OAMG;IACH,UAAU,QAAQ;QAChB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;KAC7B;IAED;;;;;;OAMG;IACH,UAAU,OAAO;QACf,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;KAC7B;IAED;;;;;;OAMG;IACH,UAAU,KAAK;QACb,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;KAC7B;IAED;;;;;;OAMG;IACH,UAAU,OAAO;QACf,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;KAC7B;CACF"}
|
package/out/utils/index.d.ts
CHANGED
package/out/utils/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACtD,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACtD,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC"}
|
package/out/utils/index.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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,
|
|
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,EAAE,OAAO,CAAC;IAEf,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,OAAO,EACH,oBAAoB,GACpB,OAAO,CACL,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG;QAAE,YAAY,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAA;KAAE,CACjE,CAAM;IAEX;;;;;;OAMG;IACH,MAAM,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAM;IAEvC;;;;;;;;OAQG;gBACS,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;CAQjE"}
|
|
@@ -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 本地仿造时值为空
|
package/out/utils/net/net.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RawAxiosRequestHeaders } from 'axios';
|
|
2
2
|
import { IHttpResponse } from './http-response';
|
|
3
3
|
/**
|
|
4
4
|
* 全局请求工具类
|
|
@@ -31,52 +31,59 @@ export declare class Net {
|
|
|
31
31
|
* Post 请求
|
|
32
32
|
*
|
|
33
33
|
* @author chitanda
|
|
34
|
-
* @date 2022-
|
|
34
|
+
* @date 2022-10-19 11:10:30
|
|
35
35
|
* @param {string} url
|
|
36
|
+
* @param {IData} data
|
|
36
37
|
* @param {IParams} [params={}]
|
|
38
|
+
* @param {RawAxiosRequestHeaders} [headers={}]
|
|
37
39
|
* @return {*} {Promise<IHttpResponse>}
|
|
38
40
|
*/
|
|
39
|
-
post(url: string, data: IData, params?: IParams, headers?:
|
|
41
|
+
post(url: string, data: IData, params?: IParams, headers?: RawAxiosRequestHeaders): Promise<IHttpResponse>;
|
|
40
42
|
/**
|
|
41
43
|
* Get 请求
|
|
42
44
|
*
|
|
43
45
|
* @author chitanda
|
|
44
|
-
* @date 2022-
|
|
46
|
+
* @date 2022-10-19 11:10:24
|
|
45
47
|
* @param {string} url
|
|
46
48
|
* @param {IParams} [params={}]
|
|
49
|
+
* @param {RawAxiosRequestHeaders} [headers={}]
|
|
50
|
+
* @param {IParams} [option={}]
|
|
47
51
|
* @return {*} {Promise<IHttpResponse>}
|
|
48
52
|
*/
|
|
49
|
-
get(url: string, params?: IParams, headers?:
|
|
53
|
+
get(url: string, params?: IParams, headers?: RawAxiosRequestHeaders, option?: IParams): Promise<IHttpResponse>;
|
|
50
54
|
/**
|
|
51
55
|
* Delete 请求
|
|
52
56
|
*
|
|
53
57
|
* @author chitanda
|
|
54
|
-
* @date 2022-
|
|
58
|
+
* @date 2022-10-19 11:10:17
|
|
55
59
|
* @param {string} url
|
|
56
60
|
* @param {IParams} [params]
|
|
61
|
+
* @param {RawAxiosRequestHeaders} [headers={}]
|
|
57
62
|
* @return {*} {Promise<IHttpResponse>}
|
|
58
63
|
*/
|
|
59
|
-
delete(url: string, params?: IParams, headers?:
|
|
64
|
+
delete(url: string, params?: IParams, headers?: RawAxiosRequestHeaders): Promise<IHttpResponse>;
|
|
60
65
|
/**
|
|
61
66
|
* Put 请求
|
|
62
67
|
*
|
|
63
68
|
* @author chitanda
|
|
64
|
-
* @date 2022-
|
|
69
|
+
* @date 2022-10-19 11:10:11
|
|
65
70
|
* @param {string} url
|
|
66
71
|
* @param {IData} data
|
|
72
|
+
* @param {IParams} [params={}]
|
|
73
|
+
* @param {RawAxiosRequestHeaders} [headers={}]
|
|
67
74
|
* @return {*} {Promise<IHttpResponse>}
|
|
68
75
|
*/
|
|
69
|
-
put(url: string, data: IData, headers?:
|
|
76
|
+
put(url: string, data: IData, params?: IParams, headers?: RawAxiosRequestHeaders): Promise<IHttpResponse>;
|
|
70
77
|
/**
|
|
71
78
|
* 获取模型数据
|
|
72
79
|
*
|
|
73
80
|
* @author chitanda
|
|
74
81
|
* @date 2022-07-14 15:07:15
|
|
75
82
|
* @param {string} url
|
|
76
|
-
* @param {
|
|
83
|
+
* @param {RawAxiosRequestHeaders} [headers={}]
|
|
77
84
|
* @return {*} {Promise<IHttpResponse>}
|
|
78
85
|
*/
|
|
79
|
-
getModel(url: string, headers?:
|
|
86
|
+
getModel(url: string, headers?: RawAxiosRequestHeaders): Promise<IHttpResponse>;
|
|
80
87
|
/**
|
|
81
88
|
* 统一处理请求返回
|
|
82
89
|
*
|
|
@@ -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,EAEZ,sBAAsB,EAEvB,MAAM,OAAO,CAAC;AAIf,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;;;;;;;;;;OAUG;IACG,IAAI,CACR,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,KAAK,EACX,MAAM,GAAE,OAAY,EACpB,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,aAAa,CAAC;IAmBzB;;;;;;;;;;OAUG;IACG,GAAG,CACP,GAAG,EAAE,MAAM,EACX,MAAM,GAAE,OAAY,EACpB,OAAO,GAAE,sBAA2B,EACpC,MAAM,GAAE,OAAY,GACnB,OAAO,CAAC,aAAa,CAAC;IAczB;;;;;;;;;OASG;IACG,MAAM,CACV,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,OAAO,EAChB,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,aAAa,CAAC;IAUzB;;;;;;;;;;OAUG;IACG,GAAG,CACP,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,KAAK,EACX,MAAM,GAAE,OAAY,EACpB,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,aAAa,CAAC;IAUzB;;;;;;;;OAQG;IACG,QAAQ,CACZ,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,sBAA2B,GACnC,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
|
*
|
|
@@ -38,28 +39,37 @@ export class Net {
|
|
|
38
39
|
* Post 请求
|
|
39
40
|
*
|
|
40
41
|
* @author chitanda
|
|
41
|
-
* @date 2022-
|
|
42
|
+
* @date 2022-10-19 11:10:30
|
|
42
43
|
* @param {string} url
|
|
44
|
+
* @param {IData} data
|
|
43
45
|
* @param {IParams} [params={}]
|
|
46
|
+
* @param {RawAxiosRequestHeaders} [headers={}]
|
|
44
47
|
* @return {*} {Promise<IHttpResponse>}
|
|
45
48
|
*/
|
|
46
49
|
async post(url, data, params = {}, headers = {}) {
|
|
47
50
|
url = this.handleAppPresetParam(url, params);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
try {
|
|
52
|
+
const response = await axios({
|
|
53
|
+
method: 'post',
|
|
54
|
+
url,
|
|
55
|
+
data,
|
|
56
|
+
headers: Object.assign({ 'Content-Type': 'application/json;charset=UTF-8', Accept: 'application/json' }, headers),
|
|
57
|
+
});
|
|
58
|
+
return this.doResponseResult(response);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
throw new HttpError(error);
|
|
62
|
+
}
|
|
55
63
|
}
|
|
56
64
|
/**
|
|
57
65
|
* Get 请求
|
|
58
66
|
*
|
|
59
67
|
* @author chitanda
|
|
60
|
-
* @date 2022-
|
|
68
|
+
* @date 2022-10-19 11:10:24
|
|
61
69
|
* @param {string} url
|
|
62
70
|
* @param {IParams} [params={}]
|
|
71
|
+
* @param {RawAxiosRequestHeaders} [headers={}]
|
|
72
|
+
* @param {IParams} [option={}]
|
|
63
73
|
* @return {*} {Promise<IHttpResponse>}
|
|
64
74
|
*/
|
|
65
75
|
async get(url, params = {}, headers = {}, option = {}) {
|
|
@@ -68,36 +78,54 @@ export class Net {
|
|
|
68
78
|
// delete params.srfparentdata;
|
|
69
79
|
// }
|
|
70
80
|
url = this.attachUrlParam(url, params);
|
|
71
|
-
|
|
72
|
-
|
|
81
|
+
try {
|
|
82
|
+
const response = await axios.get(url, Object.assign({ headers }, option));
|
|
83
|
+
return this.doResponseResult(response);
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
throw new HttpError(error);
|
|
87
|
+
}
|
|
73
88
|
}
|
|
74
89
|
/**
|
|
75
90
|
* Delete 请求
|
|
76
91
|
*
|
|
77
92
|
* @author chitanda
|
|
78
|
-
* @date 2022-
|
|
93
|
+
* @date 2022-10-19 11:10:17
|
|
79
94
|
* @param {string} url
|
|
80
95
|
* @param {IParams} [params]
|
|
96
|
+
* @param {RawAxiosRequestHeaders} [headers={}]
|
|
81
97
|
* @return {*} {Promise<IHttpResponse>}
|
|
82
98
|
*/
|
|
83
99
|
async delete(url, params, headers = {}) {
|
|
84
100
|
url = this.handleAppPresetParam(url, params);
|
|
85
|
-
|
|
86
|
-
|
|
101
|
+
try {
|
|
102
|
+
const response = await axios.delete(url, { headers });
|
|
103
|
+
return this.doResponseResult(response);
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
throw new HttpError(error);
|
|
107
|
+
}
|
|
87
108
|
}
|
|
88
109
|
/**
|
|
89
110
|
* Put 请求
|
|
90
111
|
*
|
|
91
112
|
* @author chitanda
|
|
92
|
-
* @date 2022-
|
|
113
|
+
* @date 2022-10-19 11:10:11
|
|
93
114
|
* @param {string} url
|
|
94
115
|
* @param {IData} data
|
|
116
|
+
* @param {IParams} [params={}]
|
|
117
|
+
* @param {RawAxiosRequestHeaders} [headers={}]
|
|
95
118
|
* @return {*} {Promise<IHttpResponse>}
|
|
96
119
|
*/
|
|
97
|
-
async put(url, data, headers = {}) {
|
|
98
|
-
url = this.handleAppPresetParam(url,
|
|
99
|
-
|
|
100
|
-
|
|
120
|
+
async put(url, data, params = {}, headers = {}) {
|
|
121
|
+
url = this.handleAppPresetParam(url, params);
|
|
122
|
+
try {
|
|
123
|
+
const response = await axios.put(url, data, { headers });
|
|
124
|
+
return this.doResponseResult(response);
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
throw new HttpError(error);
|
|
128
|
+
}
|
|
101
129
|
}
|
|
102
130
|
/**
|
|
103
131
|
* 获取模型数据
|
|
@@ -105,14 +133,19 @@ export class Net {
|
|
|
105
133
|
* @author chitanda
|
|
106
134
|
* @date 2022-07-14 15:07:15
|
|
107
135
|
* @param {string} url
|
|
108
|
-
* @param {
|
|
136
|
+
* @param {RawAxiosRequestHeaders} [headers={}]
|
|
109
137
|
* @return {*} {Promise<IHttpResponse>}
|
|
110
138
|
*/
|
|
111
139
|
async getModel(url, headers = {}) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
140
|
+
try {
|
|
141
|
+
const response = await axios.get(url, {
|
|
142
|
+
headers,
|
|
143
|
+
});
|
|
144
|
+
return this.doResponseResult(response);
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
throw new HttpError(error);
|
|
148
|
+
}
|
|
116
149
|
}
|
|
117
150
|
/**
|
|
118
151
|
* 统一处理请求返回
|
|
@@ -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,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ibiz-template/core",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.32",
|
|
4
4
|
"description": "核心包",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "out/index.js",
|
|
6
7
|
"types": "out/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
"system": "./dist/system/index.system.js"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://gitee.com/iBizModeling/ibiz-template.git"
|
|
14
|
+
},
|
|
7
15
|
"files": [
|
|
16
|
+
"dist",
|
|
8
17
|
"out",
|
|
9
18
|
"src"
|
|
10
19
|
],
|
|
11
20
|
"scripts": {
|
|
12
21
|
"dev": "tsc --watch",
|
|
13
|
-
"build": "npm run lint && npm run clean && tsc --build",
|
|
22
|
+
"build": "npm run lint && npm run clean && npm run build:rollup && tsc --build",
|
|
23
|
+
"build:rollup": "rollup -c",
|
|
14
24
|
"lint": "eslint 'src/**/*.ts'",
|
|
15
25
|
"lint:fix": "eslint --fix 'src/**/*.ts'",
|
|
16
|
-
"clean": "rimraf out",
|
|
26
|
+
"clean": "rimraf out dist",
|
|
17
27
|
"test": "jest",
|
|
18
28
|
"publish:next": "npm run build && npm publish --access public --tag next",
|
|
19
29
|
"publish:npm": "npm run build && npm publish --access public"
|
|
@@ -21,17 +31,19 @@
|
|
|
21
31
|
"author": "chitanda",
|
|
22
32
|
"license": "MIT",
|
|
23
33
|
"dependencies": {
|
|
24
|
-
"axios": "^
|
|
34
|
+
"axios": "^1.1.3",
|
|
25
35
|
"pluralize": "^8.0.0",
|
|
26
36
|
"qs": "^6.11.0"
|
|
27
37
|
},
|
|
28
38
|
"devDependencies": {
|
|
29
39
|
"@types/pluralize": "^0.0.29",
|
|
30
40
|
"@types/qs": "^6.9.7",
|
|
31
|
-
"
|
|
41
|
+
"lodash-es": "^4.17.21",
|
|
42
|
+
"qx-util": "0.4.3"
|
|
32
43
|
},
|
|
33
44
|
"peerDependencies": {
|
|
34
|
-
"
|
|
45
|
+
"lodash-es": "^4.17.21",
|
|
46
|
+
"qx-util": "^0.4.1"
|
|
35
47
|
},
|
|
36
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "810108ae44074a1ff8fe4366ec2ca5f421737627"
|
|
37
49
|
}
|
|
@@ -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