@ibiz-template/core 0.0.1-alpha.0 → 0.0.1-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/LICENSE +21 -0
  2. package/out/constant/core/core.d.ts +23 -0
  3. package/out/constant/core/core.d.ts.map +1 -0
  4. package/out/constant/core/core.js +22 -0
  5. package/out/constant/http-status-message/http-status-message.d.ts +5 -0
  6. package/out/constant/http-status-message/http-status-message.d.ts.map +1 -0
  7. package/out/constant/http-status-message/http-status-message.js +20 -0
  8. package/out/constant/index.d.ts +3 -0
  9. package/out/constant/index.d.ts.map +1 -0
  10. package/out/constant/index.js +2 -0
  11. package/out/context/index.d.ts +38 -3
  12. package/out/context/index.d.ts.map +1 -1
  13. package/out/context/index.js +53 -6
  14. package/out/environment/environment.d.ts +6 -0
  15. package/out/environment/environment.d.ts.map +1 -0
  16. package/out/environment/environment.js +11 -0
  17. package/out/error/http-error/http-error.d.ts +18 -0
  18. package/out/error/http-error/http-error.d.ts.map +1 -0
  19. package/out/error/http-error/http-error.js +36 -0
  20. package/out/error/index.d.ts +3 -0
  21. package/out/error/index.d.ts.map +1 -0
  22. package/out/error/index.js +2 -0
  23. package/out/error/runtime-error/runtime-error.d.ts +15 -0
  24. package/out/error/runtime-error/runtime-error.d.ts.map +1 -0
  25. package/out/error/runtime-error/runtime-error.js +15 -0
  26. package/out/ibizsys.d.ts +44 -0
  27. package/out/ibizsys.d.ts.map +1 -0
  28. package/out/ibizsys.js +29 -0
  29. package/out/index.d.ts +9 -1
  30. package/out/index.d.ts.map +1 -1
  31. package/out/index.js +9 -8
  32. package/out/install.d.ts +9 -0
  33. package/out/install.d.ts.map +1 -0
  34. package/out/install.js +16 -0
  35. package/out/interface/i-environment/i-environment.d.ts +67 -0
  36. package/out/interface/i-environment/i-environment.d.ts.map +1 -0
  37. package/out/interface/{i-context/i-context.js → i-environment/i-environment.js} +0 -0
  38. package/out/interface/index.d.ts +2 -1
  39. package/out/interface/index.d.ts.map +1 -1
  40. package/out/interface/org-data/org-data.d.ts +43 -0
  41. package/out/interface/org-data/org-data.d.ts.map +1 -0
  42. package/out/interface/org-data/org-data.js +1 -0
  43. package/out/types.d.ts +48 -0
  44. package/out/types.d.ts.map +1 -0
  45. package/out/types.js +1 -0
  46. package/out/utils/index.d.ts +7 -0
  47. package/out/utils/index.d.ts.map +1 -0
  48. package/out/utils/index.js +6 -0
  49. package/out/utils/interceptor/interceptor.d.ts +13 -0
  50. package/out/utils/interceptor/interceptor.d.ts.map +1 -0
  51. package/out/utils/interceptor/interceptor.js +33 -0
  52. package/out/utils/namespace/namespace.d.ts +148 -0
  53. package/out/utils/namespace/namespace.d.ts.map +1 -0
  54. package/out/utils/namespace/namespace.js +216 -0
  55. package/out/utils/net/http-response.d.ts +94 -0
  56. package/out/utils/net/http-response.d.ts.map +1 -0
  57. package/out/utils/net/http-response.js +53 -0
  58. package/out/utils/net/net.d.ts +123 -0
  59. package/out/utils/net/net.d.ts.map +1 -0
  60. package/out/utils/net/net.js +223 -0
  61. package/out/utils/plural/plural.d.ts +21 -0
  62. package/out/utils/plural/plural.d.ts.map +1 -0
  63. package/out/utils/plural/plural.js +25 -0
  64. package/out/utils/util/util.d.ts +39 -0
  65. package/out/utils/util/util.d.ts.map +1 -0
  66. package/out/utils/util/util.js +63 -0
  67. package/package.json +24 -6
  68. package/src/constant/core/core.ts +23 -0
  69. package/src/constant/http-status-message/http-status-message.ts +20 -0
  70. package/src/constant/index.ts +2 -0
  71. package/src/context/index.ts +112 -0
  72. package/src/environment/environment.ts +13 -0
  73. package/src/error/http-error/http-error.ts +43 -0
  74. package/src/error/index.ts +2 -0
  75. package/src/error/runtime-error/runtime-error.ts +14 -0
  76. package/src/ibizsys.ts +48 -0
  77. package/src/index.ts +10 -0
  78. package/src/install.ts +17 -0
  79. package/src/interface/i-environment/i-environment.ts +72 -0
  80. package/src/interface/index.ts +2 -0
  81. package/src/interface/org-data/org-data.ts +42 -0
  82. package/src/types.ts +54 -0
  83. package/src/utils/index.ts +6 -0
  84. package/src/utils/interceptor/interceptor.ts +35 -0
  85. package/src/utils/namespace/namespace.ts +244 -0
  86. package/src/utils/net/http-response.ts +113 -0
  87. package/src/utils/net/net.ts +254 -0
  88. package/src/utils/plural/plural.ts +27 -0
  89. package/src/utils/util/util.ts +78 -0
  90. package/out/interface/i-context/i-context.d.ts +0 -12
  91. package/out/interface/i-context/i-context.d.ts.map +0 -1
@@ -0,0 +1,43 @@
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
+ }
43
+ //# sourceMappingURL=org-data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"org-data.d.ts","sourceRoot":"","sources":["../../../src/interface/org-data/org-data.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,OAAO;IACtB;;;;;;OAMG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;;;;OAMG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;OAMG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;;;;OAMG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB"}
@@ -0,0 +1 @@
1
+ export {};
package/out/types.d.ts ADDED
@@ -0,0 +1,48 @@
1
+ import { IBizSys } from './ibizsys';
2
+ declare global {
3
+ const ibiz: IBizSys;
4
+ interface Window {
5
+ ibiz: IBizSys;
6
+ }
7
+ /**
8
+ * 上下文
9
+ *
10
+ * @author chitanda
11
+ * @date 2022-07-14 15:07:52
12
+ * @interface IContext
13
+ */
14
+ interface IContext {
15
+ [key: string | symbol]: any;
16
+ }
17
+ /**
18
+ * 参数
19
+ *
20
+ * @author chitanda
21
+ * @date 2022-07-14 15:07:57
22
+ * @interface IParams
23
+ */
24
+ interface IParams {
25
+ [key: string | symbol]: any;
26
+ }
27
+ /**
28
+ * 数据
29
+ *
30
+ * @author chitanda
31
+ * @date 2022-07-14 15:07:31
32
+ * @interface IData
33
+ */
34
+ interface IData {
35
+ [key: string | symbol]: any;
36
+ }
37
+ /**
38
+ * 任意对象结构
39
+ *
40
+ * @author chitanda
41
+ * @date 2022-09-21 15:09:30
42
+ * @interface IObject
43
+ */
44
+ interface IObject {
45
+ [key: string | symbol]: any;
46
+ }
47
+ }
48
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +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;IAEpB,UAAU,MAAM;QACd,IAAI,EAAE,OAAO,CAAC;KACf;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/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
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';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,6 @@
1
+ export { Interceptor } from './interceptor/interceptor';
2
+ export { Namespace } from './namespace/namespace';
3
+ export { HttpResponse } from './net/http-response';
4
+ export { Net } from './net/net';
5
+ export { plural, pluralLower } from './plural/plural';
6
+ export * from './util/util';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * 默认请求拦截器
3
+ *
4
+ * @author chitanda
5
+ * @date 2022-07-20 18:07:11
6
+ * @export
7
+ * @class Interceptor
8
+ */
9
+ export declare class Interceptor {
10
+ constructor();
11
+ protected init(): void;
12
+ }
13
+ //# sourceMappingURL=interceptor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interceptor.d.ts","sourceRoot":"","sources":["../../../src/utils/interceptor/interceptor.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,qBAAa,WAAW;;IAKtB,SAAS,CAAC,IAAI,IAAI,IAAI;CAkBvB"}
@@ -0,0 +1,33 @@
1
+ import axios from 'axios';
2
+ import { getToken } from '../util/util';
3
+ /**
4
+ * 默认请求拦截器
5
+ *
6
+ * @author chitanda
7
+ * @date 2022-07-20 18:07:11
8
+ * @export
9
+ * @class Interceptor
10
+ */
11
+ export class Interceptor {
12
+ constructor() {
13
+ this.init();
14
+ }
15
+ init() {
16
+ axios.interceptors.request.use(config => {
17
+ if (!config.headers) {
18
+ config.headers = {};
19
+ }
20
+ config.headers.Authorization = `Bearer ${getToken()}`;
21
+ const { orgData } = ibiz;
22
+ if (orgData) {
23
+ if (orgData.systemid) {
24
+ config.headers.srfsystemid = orgData.systemid;
25
+ }
26
+ if (orgData.orgid) {
27
+ config.headers.srforgid = orgData.orgid;
28
+ }
29
+ }
30
+ return config;
31
+ });
32
+ }
33
+ }
@@ -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
+ }