@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,148 @@
|
|
|
1
|
+
export declare const defaultNamespace = "ibiz";
|
|
2
|
+
/**
|
|
3
|
+
* 全局样式处理命名空间
|
|
4
|
+
*
|
|
5
|
+
* @author chitanda
|
|
6
|
+
* @date 2022-09-06 11:09:50
|
|
7
|
+
* @export
|
|
8
|
+
* @class Namespace
|
|
9
|
+
*/
|
|
10
|
+
export declare class Namespace {
|
|
11
|
+
protected block: string;
|
|
12
|
+
/**
|
|
13
|
+
* 命名空间
|
|
14
|
+
*
|
|
15
|
+
* @author chitanda
|
|
16
|
+
* @date 2022-09-06 12:09:01
|
|
17
|
+
* @type {string}
|
|
18
|
+
*/
|
|
19
|
+
namespace: string;
|
|
20
|
+
/**
|
|
21
|
+
* Creates an instance of Namespace.
|
|
22
|
+
*
|
|
23
|
+
* @author chitanda
|
|
24
|
+
* @date 2022-09-06 12:09:12
|
|
25
|
+
* @param {string} block 当前命名空间的根模块,例如组件的名称
|
|
26
|
+
* @param {string} [namespace] 指定命名空间,未指定使用默认值 ibiz
|
|
27
|
+
*/
|
|
28
|
+
constructor(block: string, namespace?: string);
|
|
29
|
+
/**
|
|
30
|
+
* namespace-block
|
|
31
|
+
* namespace-block-blockSuffix
|
|
32
|
+
*
|
|
33
|
+
* @author chitanda
|
|
34
|
+
* @date 2022-09-06 12:09:08
|
|
35
|
+
* @param {string} [blockSuffix='']
|
|
36
|
+
* @return {*} {string}
|
|
37
|
+
*/
|
|
38
|
+
b(blockSuffix?: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* namespace-block__element
|
|
41
|
+
*
|
|
42
|
+
* @author chitanda
|
|
43
|
+
* @date 2022-09-06 12:09:48
|
|
44
|
+
* @param {string} [element]
|
|
45
|
+
* @return {*} {string}
|
|
46
|
+
*/
|
|
47
|
+
e(element?: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* namespace-block--modifier
|
|
50
|
+
*
|
|
51
|
+
* @author chitanda
|
|
52
|
+
* @date 2022-09-06 12:09:37
|
|
53
|
+
* @param {string} [modifier]
|
|
54
|
+
* @return {*} {string}
|
|
55
|
+
*/
|
|
56
|
+
m(modifier?: string): string;
|
|
57
|
+
/**
|
|
58
|
+
* namespace-block-blockSuffix__element
|
|
59
|
+
*
|
|
60
|
+
* @author chitanda
|
|
61
|
+
* @date 2022-09-06 12:09:52
|
|
62
|
+
* @param {string} [blockSuffix]
|
|
63
|
+
* @param {string} [element]
|
|
64
|
+
* @return {*} {string}
|
|
65
|
+
*/
|
|
66
|
+
be(blockSuffix?: string, element?: string): string;
|
|
67
|
+
/**
|
|
68
|
+
* namespace-block__element--modifier
|
|
69
|
+
*
|
|
70
|
+
* @author chitanda
|
|
71
|
+
* @date 2022-09-06 12:09:19
|
|
72
|
+
* @param {string} [element]
|
|
73
|
+
* @param {string} [modifier]
|
|
74
|
+
* @return {*} {string}
|
|
75
|
+
*/
|
|
76
|
+
em(element?: string, modifier?: string): string;
|
|
77
|
+
/**
|
|
78
|
+
* namespace-block-blockSuffix--modifier
|
|
79
|
+
*
|
|
80
|
+
* @author chitanda
|
|
81
|
+
* @date 2022-09-06 12:09:59
|
|
82
|
+
* @param {string} [blockSuffix]
|
|
83
|
+
* @param {string} [modifier]
|
|
84
|
+
* @return {*} {string}
|
|
85
|
+
*/
|
|
86
|
+
bm(blockSuffix?: string, modifier?: string): string;
|
|
87
|
+
/**
|
|
88
|
+
* namespace-block-blockSuffix__element--modifier
|
|
89
|
+
*
|
|
90
|
+
* @author chitanda
|
|
91
|
+
* @date 2022-09-06 12:09:37
|
|
92
|
+
* @param {string} [blockSuffix]
|
|
93
|
+
* @param {string} [element]
|
|
94
|
+
* @param {string} [modifier]
|
|
95
|
+
* @return {*} {string}
|
|
96
|
+
*/
|
|
97
|
+
bem(blockSuffix?: string, element?: string, modifier?: string): string;
|
|
98
|
+
/**
|
|
99
|
+
* 返回状态 class
|
|
100
|
+
*
|
|
101
|
+
* is('loading', false) => '';
|
|
102
|
+
* is('loading', true) => 'is-loading';
|
|
103
|
+
*
|
|
104
|
+
* @author chitanda
|
|
105
|
+
* @date 2022-09-06 12:09:57
|
|
106
|
+
* @param {string} name
|
|
107
|
+
* @param {boolean} [state]
|
|
108
|
+
* @return {*} {string}
|
|
109
|
+
*/
|
|
110
|
+
is(name: string, state?: boolean): string;
|
|
111
|
+
/**
|
|
112
|
+
* 生成使用到的 css 变量 style 对象
|
|
113
|
+
*
|
|
114
|
+
* @author chitanda
|
|
115
|
+
* @date 2022-09-06 15:09:41
|
|
116
|
+
* @param {Record<string, string>} object
|
|
117
|
+
* @return {*} {Record<string, string>}
|
|
118
|
+
*/
|
|
119
|
+
cssVar(object: Record<string, string>): Record<string, string>;
|
|
120
|
+
/**
|
|
121
|
+
* 生成使用到的 css block 变量 style 对象
|
|
122
|
+
*
|
|
123
|
+
* @author chitanda
|
|
124
|
+
* @date 2022-09-06 15:09:03
|
|
125
|
+
* @param {Record<string, string>} object
|
|
126
|
+
* @return {*} {Record<string, string>}
|
|
127
|
+
*/
|
|
128
|
+
cssVarBlock(object: Record<string, string>): Record<string, string>;
|
|
129
|
+
/**
|
|
130
|
+
* 生成 css var 变量名称
|
|
131
|
+
*
|
|
132
|
+
* @author chitanda
|
|
133
|
+
* @date 2022-09-06 15:09:21
|
|
134
|
+
* @param {string} name
|
|
135
|
+
* @return {*} {string}
|
|
136
|
+
*/
|
|
137
|
+
cssVarName(name: string): string;
|
|
138
|
+
/**
|
|
139
|
+
* 生成块 css var 变量名称
|
|
140
|
+
*
|
|
141
|
+
* @author chitanda
|
|
142
|
+
* @date 2022-09-06 15:09:35
|
|
143
|
+
* @param {string} name
|
|
144
|
+
* @return {*} {string}
|
|
145
|
+
*/
|
|
146
|
+
cssVarBlockName(name: string): string;
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=namespace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../../../src/utils/namespace/namespace.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,SAAS,CAAC;AAwCvC;;;;;;;GAOG;AACH,qBAAa,SAAS;IAkBR,SAAS,CAAC,KAAK,EAAE,MAAM;IAjBnC;;;;;;OAMG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;;;;;OAOG;gBACmB,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;IAIvD;;;;;;;;OAQG;IACH,CAAC,CAAC,WAAW,GAAE,MAAW,GAAG,MAAM;IAInC;;;;;;;OAOG;IACH,CAAC,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM;IAI3B;;;;;;;OAOG;IACH,CAAC,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM;IAI5B;;;;;;;;OAQG;IACH,EAAE,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM;IAMlD;;;;;;;;OAQG;IACH,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM;IAM/C;;;;;;;;OAQG;IACH,EAAE,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM;IAMnD;;;;;;;;;OASG;IACH,GAAG,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM;IAMtE;;;;;;;;;;;OAWG;IACH,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM;IAIzC;;;;;;;OAOG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAU9D;;;;;;;OAOG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAUnE;;;;;;;OAOG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAIhC;;;;;;;OAOG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAGtC"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
export const defaultNamespace = 'ibiz';
|
|
2
|
+
const statePrefix = 'is-';
|
|
3
|
+
/**
|
|
4
|
+
* css bem 命名规则拼接
|
|
5
|
+
* _bem('ibiz', 'layout') => ibiz-layout
|
|
6
|
+
* _bem('ibiz', 'layout', '', 'title') => ibiz-layout__title
|
|
7
|
+
* _bem('ibiz', 'layout', '', '', 'right') => ibiz-layout--right
|
|
8
|
+
* _bem('ibiz', 'layout', '', 'title', 'right') => ibiz-layout__title--right
|
|
9
|
+
* _bem('ibiz', 'layout', 'header', 'title', 'right') => ibiz-layout-header__title--right
|
|
10
|
+
*
|
|
11
|
+
* @author chitanda
|
|
12
|
+
* @date 2022-09-06 11:09:42
|
|
13
|
+
* @param {string} namespace 命名空间
|
|
14
|
+
* @param {string} block 块
|
|
15
|
+
* @param {string} blockSuffix 块后缀
|
|
16
|
+
* @param {string} element 元素
|
|
17
|
+
* @param {string} modifier 修饰符
|
|
18
|
+
* @return {*} {string}
|
|
19
|
+
*/
|
|
20
|
+
function _bem(namespace, block, blockSuffix, element, modifier) {
|
|
21
|
+
let cls = `${namespace}-${block}`;
|
|
22
|
+
if (blockSuffix) {
|
|
23
|
+
cls += `-${blockSuffix}`;
|
|
24
|
+
}
|
|
25
|
+
if (element) {
|
|
26
|
+
cls += `__${element}`;
|
|
27
|
+
}
|
|
28
|
+
if (modifier) {
|
|
29
|
+
cls += `--${modifier}`;
|
|
30
|
+
}
|
|
31
|
+
return cls;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 全局样式处理命名空间
|
|
35
|
+
*
|
|
36
|
+
* @author chitanda
|
|
37
|
+
* @date 2022-09-06 11:09:50
|
|
38
|
+
* @export
|
|
39
|
+
* @class Namespace
|
|
40
|
+
*/
|
|
41
|
+
export class Namespace {
|
|
42
|
+
/**
|
|
43
|
+
* Creates an instance of Namespace.
|
|
44
|
+
*
|
|
45
|
+
* @author chitanda
|
|
46
|
+
* @date 2022-09-06 12:09:12
|
|
47
|
+
* @param {string} block 当前命名空间的根模块,例如组件的名称
|
|
48
|
+
* @param {string} [namespace] 指定命名空间,未指定使用默认值 ibiz
|
|
49
|
+
*/
|
|
50
|
+
constructor(block, namespace) {
|
|
51
|
+
this.block = block;
|
|
52
|
+
this.namespace = namespace || defaultNamespace;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* namespace-block
|
|
56
|
+
* namespace-block-blockSuffix
|
|
57
|
+
*
|
|
58
|
+
* @author chitanda
|
|
59
|
+
* @date 2022-09-06 12:09:08
|
|
60
|
+
* @param {string} [blockSuffix='']
|
|
61
|
+
* @return {*} {string}
|
|
62
|
+
*/
|
|
63
|
+
b(blockSuffix = '') {
|
|
64
|
+
return _bem(this.namespace, this.block, blockSuffix, '', '');
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* namespace-block__element
|
|
68
|
+
*
|
|
69
|
+
* @author chitanda
|
|
70
|
+
* @date 2022-09-06 12:09:48
|
|
71
|
+
* @param {string} [element]
|
|
72
|
+
* @return {*} {string}
|
|
73
|
+
*/
|
|
74
|
+
e(element) {
|
|
75
|
+
return element ? _bem(this.namespace, this.block, '', element, '') : '';
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* namespace-block--modifier
|
|
79
|
+
*
|
|
80
|
+
* @author chitanda
|
|
81
|
+
* @date 2022-09-06 12:09:37
|
|
82
|
+
* @param {string} [modifier]
|
|
83
|
+
* @return {*} {string}
|
|
84
|
+
*/
|
|
85
|
+
m(modifier) {
|
|
86
|
+
return modifier ? _bem(this.namespace, this.block, '', '', modifier) : '';
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* namespace-block-blockSuffix__element
|
|
90
|
+
*
|
|
91
|
+
* @author chitanda
|
|
92
|
+
* @date 2022-09-06 12:09:52
|
|
93
|
+
* @param {string} [blockSuffix]
|
|
94
|
+
* @param {string} [element]
|
|
95
|
+
* @return {*} {string}
|
|
96
|
+
*/
|
|
97
|
+
be(blockSuffix, element) {
|
|
98
|
+
return blockSuffix && element
|
|
99
|
+
? _bem(this.namespace, this.block, blockSuffix, element, '')
|
|
100
|
+
: '';
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* namespace-block__element--modifier
|
|
104
|
+
*
|
|
105
|
+
* @author chitanda
|
|
106
|
+
* @date 2022-09-06 12:09:19
|
|
107
|
+
* @param {string} [element]
|
|
108
|
+
* @param {string} [modifier]
|
|
109
|
+
* @return {*} {string}
|
|
110
|
+
*/
|
|
111
|
+
em(element, modifier) {
|
|
112
|
+
return element && modifier
|
|
113
|
+
? _bem(this.namespace, this.block, '', element, modifier)
|
|
114
|
+
: '';
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* namespace-block-blockSuffix--modifier
|
|
118
|
+
*
|
|
119
|
+
* @author chitanda
|
|
120
|
+
* @date 2022-09-06 12:09:59
|
|
121
|
+
* @param {string} [blockSuffix]
|
|
122
|
+
* @param {string} [modifier]
|
|
123
|
+
* @return {*} {string}
|
|
124
|
+
*/
|
|
125
|
+
bm(blockSuffix, modifier) {
|
|
126
|
+
return blockSuffix && modifier
|
|
127
|
+
? _bem(this.namespace, this.block, blockSuffix, '', modifier)
|
|
128
|
+
: '';
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* namespace-block-blockSuffix__element--modifier
|
|
132
|
+
*
|
|
133
|
+
* @author chitanda
|
|
134
|
+
* @date 2022-09-06 12:09:37
|
|
135
|
+
* @param {string} [blockSuffix]
|
|
136
|
+
* @param {string} [element]
|
|
137
|
+
* @param {string} [modifier]
|
|
138
|
+
* @return {*} {string}
|
|
139
|
+
*/
|
|
140
|
+
bem(blockSuffix, element, modifier) {
|
|
141
|
+
return blockSuffix && element && modifier
|
|
142
|
+
? _bem(this.namespace, this.block, blockSuffix, element, modifier)
|
|
143
|
+
: '';
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* 返回状态 class
|
|
147
|
+
*
|
|
148
|
+
* is('loading', false) => '';
|
|
149
|
+
* is('loading', true) => 'is-loading';
|
|
150
|
+
*
|
|
151
|
+
* @author chitanda
|
|
152
|
+
* @date 2022-09-06 12:09:57
|
|
153
|
+
* @param {string} name
|
|
154
|
+
* @param {boolean} [state]
|
|
155
|
+
* @return {*} {string}
|
|
156
|
+
*/
|
|
157
|
+
is(name, state) {
|
|
158
|
+
return name && state ? `${statePrefix}${name}` : '';
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* 生成使用到的 css 变量 style 对象
|
|
162
|
+
*
|
|
163
|
+
* @author chitanda
|
|
164
|
+
* @date 2022-09-06 15:09:41
|
|
165
|
+
* @param {Record<string, string>} object
|
|
166
|
+
* @return {*} {Record<string, string>}
|
|
167
|
+
*/
|
|
168
|
+
cssVar(object) {
|
|
169
|
+
const styles = {};
|
|
170
|
+
for (const key in object) {
|
|
171
|
+
if (object[key]) {
|
|
172
|
+
styles[this.cssVarName(key)] = object[key];
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return styles;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* 生成使用到的 css block 变量 style 对象
|
|
179
|
+
*
|
|
180
|
+
* @author chitanda
|
|
181
|
+
* @date 2022-09-06 15:09:03
|
|
182
|
+
* @param {Record<string, string>} object
|
|
183
|
+
* @return {*} {Record<string, string>}
|
|
184
|
+
*/
|
|
185
|
+
cssVarBlock(object) {
|
|
186
|
+
const styles = {};
|
|
187
|
+
for (const key in object) {
|
|
188
|
+
if (object[key]) {
|
|
189
|
+
styles[this.cssVarBlockName(key)] = object[key];
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return styles;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* 生成 css var 变量名称
|
|
196
|
+
*
|
|
197
|
+
* @author chitanda
|
|
198
|
+
* @date 2022-09-06 15:09:21
|
|
199
|
+
* @param {string} name
|
|
200
|
+
* @return {*} {string}
|
|
201
|
+
*/
|
|
202
|
+
cssVarName(name) {
|
|
203
|
+
return `--${this.namespace}-${name}`;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* 生成块 css var 变量名称
|
|
207
|
+
*
|
|
208
|
+
* @author chitanda
|
|
209
|
+
* @date 2022-09-06 15:09:35
|
|
210
|
+
* @param {string} name
|
|
211
|
+
* @return {*} {string}
|
|
212
|
+
*/
|
|
213
|
+
cssVarBlockName(name) {
|
|
214
|
+
return `--${this.namespace}-${this.block}-${name}`;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { AxiosRequestConfig, AxiosResponse, AxiosResponseHeaders } from 'axios';
|
|
2
|
+
/**
|
|
3
|
+
* Http请求返回接口
|
|
4
|
+
*
|
|
5
|
+
* @author chitanda
|
|
6
|
+
* @date 2022-08-21 17:08:06
|
|
7
|
+
* @export
|
|
8
|
+
* @interface IHttpResponse
|
|
9
|
+
* @extends {AxiosResponse}
|
|
10
|
+
* @template T
|
|
11
|
+
*/
|
|
12
|
+
export interface IHttpResponse<T = IData> extends AxiosResponse {
|
|
13
|
+
/**
|
|
14
|
+
* 是否请求成功
|
|
15
|
+
*
|
|
16
|
+
* @description 当状态码为 200-299 时认为成功
|
|
17
|
+
* @author chitanda
|
|
18
|
+
* @date 2022-07-14 16:07:59
|
|
19
|
+
* @type {boolean}
|
|
20
|
+
*/
|
|
21
|
+
ok: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* 是否为本地仿造响应
|
|
24
|
+
*
|
|
25
|
+
* @description 只有当值为 true 时, 才认为是本地仿造响应
|
|
26
|
+
* @author chitanda
|
|
27
|
+
* @date 2022-08-18 15:08:44
|
|
28
|
+
* @type {boolean}
|
|
29
|
+
*/
|
|
30
|
+
local?: boolean;
|
|
31
|
+
data: T;
|
|
32
|
+
/**
|
|
33
|
+
* 当前页
|
|
34
|
+
*/
|
|
35
|
+
page?: number;
|
|
36
|
+
/**
|
|
37
|
+
* 分页条数
|
|
38
|
+
*/
|
|
39
|
+
size?: number;
|
|
40
|
+
/**
|
|
41
|
+
* 总条数
|
|
42
|
+
*/
|
|
43
|
+
total?: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 本地请求仿造响应
|
|
47
|
+
*
|
|
48
|
+
* @author chitanda
|
|
49
|
+
* @date 2022-08-21 17:08:00
|
|
50
|
+
* @export
|
|
51
|
+
* @class HttpResponse
|
|
52
|
+
* @implements {IHttpResponse<T>}
|
|
53
|
+
* @template T
|
|
54
|
+
*/
|
|
55
|
+
export declare class HttpResponse<T = IData> implements IHttpResponse<T> {
|
|
56
|
+
/**
|
|
57
|
+
* 本地仿造响应
|
|
58
|
+
*
|
|
59
|
+
* @author chitanda
|
|
60
|
+
* @date 2022-08-18 15:08:06
|
|
61
|
+
*/
|
|
62
|
+
local: boolean;
|
|
63
|
+
ok: boolean;
|
|
64
|
+
data: T;
|
|
65
|
+
status: number;
|
|
66
|
+
statusText: string;
|
|
67
|
+
/**
|
|
68
|
+
* header 本地仿造时值为空
|
|
69
|
+
*
|
|
70
|
+
* @author chitanda
|
|
71
|
+
* @date 2022-08-18 15:08:46
|
|
72
|
+
* @type {AxiosResponseHeaders}
|
|
73
|
+
*/
|
|
74
|
+
headers: AxiosResponseHeaders;
|
|
75
|
+
/**
|
|
76
|
+
* AxiosResponse 本地仿造时值为空
|
|
77
|
+
*
|
|
78
|
+
* @author chitanda
|
|
79
|
+
* @date 2022-08-18 15:08:22
|
|
80
|
+
* @type {AxiosRequestConfig<IData>}
|
|
81
|
+
*/
|
|
82
|
+
config: AxiosRequestConfig<IData>;
|
|
83
|
+
/**
|
|
84
|
+
* Creates an instance of HttpResponse.
|
|
85
|
+
*
|
|
86
|
+
* @author chitanda
|
|
87
|
+
* @date 2022-08-18 15:08:11
|
|
88
|
+
* @param {unknown} [data] 返回的数据
|
|
89
|
+
* @param {number} [status] 状态码 (默认为 200)
|
|
90
|
+
* @param {string} [statusText] 状态描述 (默认为空字符)
|
|
91
|
+
*/
|
|
92
|
+
constructor(data?: unknown, status?: number, statusText?: string);
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=http-response.d.ts.map
|
|
@@ -0,0 +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,CAAC,EAAE,OAAO,CAAC;IAEhB,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;;;;;;OAMG;IACH,OAAO,EAAE,oBAAoB,CAAM;IAEnC;;;;;;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"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 本地请求仿造响应
|
|
3
|
+
*
|
|
4
|
+
* @author chitanda
|
|
5
|
+
* @date 2022-08-21 17:08:00
|
|
6
|
+
* @export
|
|
7
|
+
* @class HttpResponse
|
|
8
|
+
* @implements {IHttpResponse<T>}
|
|
9
|
+
* @template T
|
|
10
|
+
*/
|
|
11
|
+
export class HttpResponse {
|
|
12
|
+
/**
|
|
13
|
+
* Creates an instance of HttpResponse.
|
|
14
|
+
*
|
|
15
|
+
* @author chitanda
|
|
16
|
+
* @date 2022-08-18 15:08:11
|
|
17
|
+
* @param {unknown} [data] 返回的数据
|
|
18
|
+
* @param {number} [status] 状态码 (默认为 200)
|
|
19
|
+
* @param {string} [statusText] 状态描述 (默认为空字符)
|
|
20
|
+
*/
|
|
21
|
+
constructor(data, status, statusText) {
|
|
22
|
+
/**
|
|
23
|
+
* 本地仿造响应
|
|
24
|
+
*
|
|
25
|
+
* @author chitanda
|
|
26
|
+
* @date 2022-08-18 15:08:06
|
|
27
|
+
*/
|
|
28
|
+
this.local = true;
|
|
29
|
+
this.ok = false;
|
|
30
|
+
/**
|
|
31
|
+
* header 本地仿造时值为空
|
|
32
|
+
*
|
|
33
|
+
* @author chitanda
|
|
34
|
+
* @date 2022-08-18 15:08:46
|
|
35
|
+
* @type {AxiosResponseHeaders}
|
|
36
|
+
*/
|
|
37
|
+
this.headers = {};
|
|
38
|
+
/**
|
|
39
|
+
* AxiosResponse 本地仿造时值为空
|
|
40
|
+
*
|
|
41
|
+
* @author chitanda
|
|
42
|
+
* @date 2022-08-18 15:08:22
|
|
43
|
+
* @type {AxiosRequestConfig<IData>}
|
|
44
|
+
*/
|
|
45
|
+
this.config = {};
|
|
46
|
+
this.data = data;
|
|
47
|
+
this.status = status || 200;
|
|
48
|
+
this.statusText = statusText || '';
|
|
49
|
+
if (this.status >= 200 && this.status < 300) {
|
|
50
|
+
this.ok = true;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { AxiosRequestHeaders } from 'axios';
|
|
2
|
+
import { IHttpResponse } from './http-response';
|
|
3
|
+
/**
|
|
4
|
+
* 全局请求工具类
|
|
5
|
+
*
|
|
6
|
+
* @author chitanda
|
|
7
|
+
* @date 2022-07-14 15:07:42
|
|
8
|
+
* @export
|
|
9
|
+
* @class Net
|
|
10
|
+
*/
|
|
11
|
+
export declare class Net {
|
|
12
|
+
/**
|
|
13
|
+
* 标准请求前缀
|
|
14
|
+
*
|
|
15
|
+
* @author chitanda
|
|
16
|
+
* @date 2022-07-21 10:07:48
|
|
17
|
+
* @protected
|
|
18
|
+
* @type {string}
|
|
19
|
+
*/
|
|
20
|
+
protected _prefix: string;
|
|
21
|
+
get prefix(): string;
|
|
22
|
+
/**
|
|
23
|
+
* Creates an instance of Net.
|
|
24
|
+
*
|
|
25
|
+
* @author chitanda
|
|
26
|
+
* @date 2022-07-21 10:07:27
|
|
27
|
+
* @param {string} [prefix] 请求前缀
|
|
28
|
+
*/
|
|
29
|
+
constructor(prefix?: string);
|
|
30
|
+
/**
|
|
31
|
+
* Post 请求
|
|
32
|
+
*
|
|
33
|
+
* @author chitanda
|
|
34
|
+
* @date 2022-07-14 15:07:01
|
|
35
|
+
* @param {string} url
|
|
36
|
+
* @param {IParams} [params={}]
|
|
37
|
+
* @return {*} {Promise<IHttpResponse>}
|
|
38
|
+
*/
|
|
39
|
+
post(url: string, data: IData, params?: IParams, headers?: AxiosRequestHeaders): Promise<IHttpResponse>;
|
|
40
|
+
/**
|
|
41
|
+
* Get 请求
|
|
42
|
+
*
|
|
43
|
+
* @author chitanda
|
|
44
|
+
* @date 2022-07-14 15:07:08
|
|
45
|
+
* @param {string} url
|
|
46
|
+
* @param {IParams} [params={}]
|
|
47
|
+
* @return {*} {Promise<IHttpResponse>}
|
|
48
|
+
*/
|
|
49
|
+
get(url: string, params?: IParams, headers?: AxiosRequestHeaders, option?: IParams): Promise<IHttpResponse>;
|
|
50
|
+
/**
|
|
51
|
+
* Delete 请求
|
|
52
|
+
*
|
|
53
|
+
* @author chitanda
|
|
54
|
+
* @date 2022-07-14 15:07:43
|
|
55
|
+
* @param {string} url
|
|
56
|
+
* @param {IParams} [params]
|
|
57
|
+
* @return {*} {Promise<IHttpResponse>}
|
|
58
|
+
*/
|
|
59
|
+
delete(url: string, params?: IParams, headers?: AxiosRequestHeaders): Promise<IHttpResponse>;
|
|
60
|
+
/**
|
|
61
|
+
* Put 请求
|
|
62
|
+
*
|
|
63
|
+
* @author chitanda
|
|
64
|
+
* @date 2022-07-14 15:07:49
|
|
65
|
+
* @param {string} url
|
|
66
|
+
* @param {IData} data
|
|
67
|
+
* @return {*} {Promise<IHttpResponse>}
|
|
68
|
+
*/
|
|
69
|
+
put(url: string, data: IData, headers?: AxiosRequestHeaders): Promise<IHttpResponse>;
|
|
70
|
+
/**
|
|
71
|
+
* 获取模型数据
|
|
72
|
+
*
|
|
73
|
+
* @author chitanda
|
|
74
|
+
* @date 2022-07-14 15:07:15
|
|
75
|
+
* @param {string} url
|
|
76
|
+
* @param {AxiosRequestHeaders} [headers={}]
|
|
77
|
+
* @return {*} {Promise<IHttpResponse>}
|
|
78
|
+
*/
|
|
79
|
+
getModel(url: string, headers?: AxiosRequestHeaders): Promise<IHttpResponse>;
|
|
80
|
+
/**
|
|
81
|
+
* 统一处理请求返回
|
|
82
|
+
*
|
|
83
|
+
* @author chitanda
|
|
84
|
+
* @date 2022-07-14 16:07:23
|
|
85
|
+
* @private
|
|
86
|
+
* @param {AxiosResponse} response
|
|
87
|
+
* @return {*} {IHttpResponse}
|
|
88
|
+
*/
|
|
89
|
+
private doResponseResult;
|
|
90
|
+
/**
|
|
91
|
+
* 处理平台预定义参数
|
|
92
|
+
*
|
|
93
|
+
* @author chitanda
|
|
94
|
+
* @date 2022-07-14 15:07:12
|
|
95
|
+
* @private
|
|
96
|
+
* @param {string} url
|
|
97
|
+
* @param {IParams} [params]
|
|
98
|
+
* @return {*} {string}
|
|
99
|
+
*/
|
|
100
|
+
private handleAppPresetParam;
|
|
101
|
+
/**
|
|
102
|
+
* url 附加请求参数
|
|
103
|
+
*
|
|
104
|
+
* @author chitanda
|
|
105
|
+
* @date 2022-07-14 15:07:34
|
|
106
|
+
* @private
|
|
107
|
+
* @param {string} url
|
|
108
|
+
* @param {IParams} params
|
|
109
|
+
* @return {*} {string}
|
|
110
|
+
*/
|
|
111
|
+
private attachUrlParam;
|
|
112
|
+
/**
|
|
113
|
+
* 处理 url 参数
|
|
114
|
+
*
|
|
115
|
+
* @author chitanda
|
|
116
|
+
* @date 2022-07-20 20:07:17
|
|
117
|
+
* @private
|
|
118
|
+
* @param {string} url
|
|
119
|
+
* @return {*} {string}
|
|
120
|
+
*/
|
|
121
|
+
private attachUrl;
|
|
122
|
+
}
|
|
123
|
+
//# 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,EAAiB,MAAM,OAAO,CAAC;AAGlE,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;IAezB;;;;;;;;OAQG;IACG,GAAG,CACP,GAAG,EAAE,MAAM,EACX,MAAM,GAAE,OAAY,EACpB,OAAO,GAAE,mBAAwB,EACjC,MAAM,GAAE,OAAY,GACnB,OAAO,CAAC,aAAa,CAAC;IAUzB;;;;;;;;OAQG;IACG,MAAM,CACV,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,OAAO,EAChB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,aAAa,CAAC;IAMzB;;;;;;;;OAQG;IACG,GAAG,CACP,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,KAAK,EACX,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,aAAa,CAAC;IAMzB;;;;;;;;OAQG;IACG,QAAQ,CACZ,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,aAAa,CAAC;IAOzB;;;;;;;;OAQG;IACH,OAAO,CAAC,gBAAgB;IAQxB;;;;;;;;;OASG;IACH,OAAO,CAAC,oBAAoB;IAc5B;;;;;;;;;OASG;IACH,OAAO,CAAC,cAAc;IAiBtB;;;;;;;;OAQG;IACH,OAAO,CAAC,SAAS;CAGlB"}
|