@ibiz-template/core 0.0.1-alpha.6 → 0.0.1-beta.17

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 (165) hide show
  1. package/dist/system/index.system.js +1 -0
  2. package/out/command/command-register.d.ts +66 -0
  3. package/out/command/command-register.d.ts.map +1 -0
  4. package/out/command/command-register.js +113 -0
  5. package/out/command/command.d.ts +54 -0
  6. package/out/command/command.d.ts.map +1 -0
  7. package/out/command/command.js +71 -0
  8. package/out/command/index.d.ts +10 -0
  9. package/out/command/index.d.ts.map +1 -0
  10. package/out/command/index.js +9 -0
  11. package/out/command/interface/command/command-option.d.ts +23 -0
  12. package/out/command/interface/command/command-option.d.ts.map +1 -0
  13. package/out/command/interface/command/command-option.js +1 -0
  14. package/out/command/interface/command/command.d.ts +74 -0
  15. package/out/command/interface/command/command.d.ts.map +1 -0
  16. package/out/command/interface/command/command.js +1 -0
  17. package/out/command/interface/disposable/disposable.d.ts +4 -0
  18. package/out/command/interface/disposable/disposable.d.ts.map +1 -0
  19. package/out/command/interface/disposable/disposable.js +1 -0
  20. package/out/command/interface/index.d.ts +4 -0
  21. package/out/command/interface/index.d.ts.map +1 -0
  22. package/out/command/interface/index.js +1 -0
  23. package/out/command/utils/index.d.ts +3 -0
  24. package/out/command/utils/index.d.ts.map +1 -0
  25. package/out/command/utils/index.js +2 -0
  26. package/out/command/utils/linked-list.d.ts +16 -0
  27. package/out/command/utils/linked-list.d.ts.map +1 -0
  28. package/out/command/utils/linked-list.js +120 -0
  29. package/out/command/utils/util.d.ts +27 -0
  30. package/out/command/utils/util.d.ts.map +1 -0
  31. package/out/command/utils/util.js +77 -0
  32. package/out/constant/index.d.ts +3 -0
  33. package/out/constant/index.d.ts.map +1 -1
  34. package/out/constant/index.js +3 -0
  35. package/out/constant/login-mode/login-mode.d.ts +23 -0
  36. package/out/constant/login-mode/login-mode.d.ts.map +1 -0
  37. package/out/constant/login-mode/login-mode.js +24 -0
  38. package/out/constant/menu-permission-mode/menu-permission-mode.d.ts +23 -0
  39. package/out/constant/menu-permission-mode/menu-permission-mode.d.ts.map +1 -0
  40. package/out/constant/menu-permission-mode/menu-permission-mode.js +24 -0
  41. package/out/constant/util/util.d.ts +5 -0
  42. package/out/constant/util/util.d.ts.map +1 -0
  43. package/out/constant/util/util.js +5 -0
  44. package/out/context/index.d.ts +19 -32
  45. package/out/context/index.d.ts.map +1 -1
  46. package/out/context/index.js +52 -60
  47. package/out/environment/environment.d.ts.map +1 -1
  48. package/out/environment/environment.js +11 -2
  49. package/out/error/http-error/http-error.d.ts.map +1 -1
  50. package/out/error/http-error/http-error.js +0 -4
  51. package/out/factory-center.d.ts +11 -0
  52. package/out/factory-center.d.ts.map +1 -0
  53. package/out/factory-center.js +10 -0
  54. package/out/ibizsys.d.ts +17 -1
  55. package/out/ibizsys.d.ts.map +1 -1
  56. package/out/ibizsys.js +17 -1
  57. package/out/index.d.ts +3 -1
  58. package/out/index.d.ts.map +1 -1
  59. package/out/index.js +3 -1
  60. package/out/install.d.ts.map +1 -1
  61. package/out/install.js +4 -2
  62. package/out/interface/click-outside/click-outside.d.ts +70 -0
  63. package/out/interface/click-outside/click-outside.d.ts.map +1 -0
  64. package/out/interface/click-outside/click-outside.js +1 -0
  65. package/out/interface/i-environment/i-environment.d.ts +72 -4
  66. package/out/interface/i-environment/i-environment.d.ts.map +1 -1
  67. package/out/interface/index.d.ts +1 -0
  68. package/out/interface/index.d.ts.map +1 -1
  69. package/out/interface/index.js +1 -1
  70. package/out/types.d.ts +10 -0
  71. package/out/types.d.ts.map +1 -1
  72. package/out/utils/click-outside/click-outside.d.ts +14 -0
  73. package/out/utils/click-outside/click-outside.d.ts.map +1 -0
  74. package/out/utils/click-outside/click-outside.js +85 -0
  75. package/out/utils/color/color.d.ts +13 -0
  76. package/out/utils/color/color.d.ts.map +1 -0
  77. package/out/utils/color/color.js +76 -0
  78. package/out/utils/download-file/download-file.d.ts +31 -0
  79. package/out/utils/download-file/download-file.d.ts.map +1 -0
  80. package/out/utils/download-file/download-file.js +107 -0
  81. package/out/utils/event/event.d.ts +34 -0
  82. package/out/utils/event/event.d.ts.map +1 -0
  83. package/out/utils/event/event.js +60 -0
  84. package/out/utils/index.d.ts +10 -1
  85. package/out/utils/index.d.ts.map +1 -1
  86. package/out/utils/index.js +10 -1
  87. package/out/utils/interceptor/core-interceptor.d.ts +15 -0
  88. package/out/utils/interceptor/core-interceptor.d.ts.map +1 -0
  89. package/out/utils/interceptor/core-interceptor.js +30 -0
  90. package/out/utils/interceptor/index.d.ts +3 -0
  91. package/out/utils/interceptor/index.d.ts.map +1 -0
  92. package/out/utils/interceptor/index.js +2 -0
  93. package/out/utils/interceptor/interceptor.d.ts +74 -3
  94. package/out/utils/interceptor/interceptor.d.ts.map +1 -1
  95. package/out/utils/interceptor/interceptor.js +73 -22
  96. package/out/utils/logger/logger.d.ts +3 -0
  97. package/out/utils/logger/logger.d.ts.map +1 -0
  98. package/out/utils/logger/logger.js +2 -0
  99. package/out/utils/net/http-response.d.ts +4 -9
  100. package/out/utils/net/http-response.d.ts.map +1 -1
  101. package/out/utils/net/http-response.js +0 -7
  102. package/out/utils/net/net.d.ts +82 -31
  103. package/out/utils/net/net.d.ts.map +1 -1
  104. package/out/utils/net/net.js +109 -40
  105. package/out/utils/sync/count-latch.d.ts +60 -0
  106. package/out/utils/sync/count-latch.d.ts.map +1 -0
  107. package/out/utils/sync/count-latch.js +93 -0
  108. package/out/utils/sync/index.d.ts +2 -0
  109. package/out/utils/sync/index.d.ts.map +1 -0
  110. package/out/utils/sync/index.js +1 -0
  111. package/out/utils/upload/select-file.d.ts +53 -0
  112. package/out/utils/upload/select-file.d.ts.map +1 -0
  113. package/out/utils/upload/select-file.js +47 -0
  114. package/out/utils/upload/upload-file.d.ts +46 -0
  115. package/out/utils/upload/upload-file.d.ts.map +1 -0
  116. package/out/utils/upload/upload-file.js +150 -0
  117. package/out/utils/url-helper/url-helper.d.ts +51 -0
  118. package/out/utils/url-helper/url-helper.d.ts.map +1 -0
  119. package/out/utils/url-helper/url-helper.js +59 -0
  120. package/out/utils/util/util.d.ts +20 -4
  121. package/out/utils/util/util.d.ts.map +1 -1
  122. package/out/utils/util/util.js +59 -5
  123. package/package.json +19 -9
  124. package/src/command/command-register.ts +135 -0
  125. package/src/command/command.ts +79 -0
  126. package/src/command/index.ts +11 -0
  127. package/src/command/interface/command/command-option.ts +22 -0
  128. package/src/command/interface/command/command.ts +86 -0
  129. package/src/command/interface/disposable/disposable.ts +3 -0
  130. package/src/command/interface/index.ts +9 -0
  131. package/src/command/utils/index.ts +2 -0
  132. package/src/command/utils/linked-list.ts +136 -0
  133. package/src/command/utils/util.ts +95 -0
  134. package/src/constant/index.ts +3 -0
  135. package/src/constant/login-mode/login-mode.ts +23 -0
  136. package/src/constant/menu-permission-mode/menu-permission-mode.ts +23 -0
  137. package/src/constant/util/util.ts +5 -0
  138. package/src/context/index.ts +69 -59
  139. package/src/environment/environment.ts +11 -2
  140. package/src/error/http-error/http-error.ts +0 -4
  141. package/src/factory-center.ts +9 -0
  142. package/src/ibizsys.ts +19 -1
  143. package/src/index.ts +3 -1
  144. package/src/install.ts +4 -2
  145. package/src/interface/click-outside/click-outside.ts +71 -0
  146. package/src/interface/i-environment/i-environment.ts +81 -4
  147. package/src/interface/index.ts +1 -0
  148. package/src/types.ts +10 -0
  149. package/src/utils/click-outside/click-outside.ts +110 -0
  150. package/src/utils/color/color.ts +84 -0
  151. package/src/utils/download-file/download-file.ts +109 -0
  152. package/src/utils/event/event.ts +77 -0
  153. package/src/utils/index.ts +10 -1
  154. package/src/utils/interceptor/core-interceptor.ts +35 -0
  155. package/src/utils/interceptor/index.ts +2 -0
  156. package/src/utils/interceptor/interceptor.ts +109 -22
  157. package/src/utils/logger/logger.ts +3 -0
  158. package/src/utils/net/http-response.ts +6 -9
  159. package/src/utils/net/net.ts +144 -51
  160. package/src/utils/sync/count-latch.ts +99 -0
  161. package/src/utils/sync/index.ts +1 -0
  162. package/src/utils/upload/select-file.ts +86 -0
  163. package/src/utils/upload/upload-file.ts +206 -0
  164. package/src/utils/url-helper/url-helper.ts +62 -0
  165. package/src/utils/util/util.ts +72 -14
@@ -0,0 +1,107 @@
1
+ /**
2
+ * 根据文件名称计算Mime类型
3
+ *
4
+ * @author lxm
5
+ * @date 2022-11-16 22:11:02
6
+ * @export
7
+ * @param {string} fileName
8
+ * @returns {*}
9
+ */
10
+ export function calcMimeByFileName(fileName) {
11
+ const ext = fileName.split('.').pop();
12
+ let mime = '';
13
+ switch (ext) {
14
+ case '.wps':
15
+ mime = 'application/kswps';
16
+ break;
17
+ case '.doc':
18
+ mime = 'application/msword';
19
+ break;
20
+ case '.docx':
21
+ mime =
22
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
23
+ break;
24
+ case '.txt':
25
+ mime = 'text/plain';
26
+ break;
27
+ case '.zip':
28
+ mime = 'application/zip';
29
+ break;
30
+ case '.png':
31
+ mime = 'image/png';
32
+ break;
33
+ case '.gif':
34
+ mime = 'image/gif';
35
+ break;
36
+ case '.jpeg':
37
+ mime = 'image/jpeg';
38
+ break;
39
+ case '.jpg':
40
+ mime = 'image/jpeg';
41
+ break;
42
+ case '.rtf':
43
+ mime = 'application/rtf';
44
+ break;
45
+ case '.avi':
46
+ mime = 'video/x-msvideo';
47
+ break;
48
+ case '.gz':
49
+ mime = 'application/x-gzip';
50
+ break;
51
+ case '.tar':
52
+ mime = 'application/x-tar';
53
+ break;
54
+ case '.xlsx':
55
+ mime = 'application/vnd.ms-excel';
56
+ break;
57
+ default:
58
+ mime = '';
59
+ }
60
+ return mime;
61
+ }
62
+ /**
63
+ * 判断是否是图片格式
64
+ *
65
+ * @author lxm
66
+ * @date 2022-11-21 13:11:23
67
+ * @export
68
+ * @param {string} fileName
69
+ * @returns {*} {boolean}
70
+ */
71
+ export function isImage(fileName) {
72
+ const ext = fileName.split('.').pop();
73
+ if (!ext) {
74
+ return false;
75
+ }
76
+ const imageTypes = ['.jpeg', 'jpg', 'gif', 'png', 'bmp', 'svg'];
77
+ return imageTypes.includes(ext);
78
+ }
79
+ /**
80
+ * 纯JS触发下载文件
81
+ *
82
+ * @author lxm
83
+ * @date 2022-11-16 22:11:24
84
+ * @export
85
+ * @param {Blob} file 文件流Blob
86
+ * @param {string} fileName 文件名称
87
+ */
88
+ export function downloadFileFromBlob(file, fileName) {
89
+ // 获取文件名
90
+ const filetype = calcMimeByFileName(fileName);
91
+ // 用blob对象获取文件流
92
+ const blob = new Blob([file], { type: filetype });
93
+ // 通过文件流创建下载链接
94
+ const href = URL.createObjectURL(blob);
95
+ // 创建一个a元素并设置相关属性
96
+ const a = document.createElement('a');
97
+ a.href = href;
98
+ a.download = fileName;
99
+ // 添加a元素到当前网页
100
+ document.body.appendChild(a);
101
+ // 触发a元素的点击事件,实现下载
102
+ a.click();
103
+ // 从当前网页移除a元素
104
+ document.body.removeChild(a);
105
+ // 释放blob对象
106
+ URL.revokeObjectURL(href);
107
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * 计算event的composedPath返回事件路径(兼容了IE)
3
+ *
4
+ * @author lxm
5
+ * @date 2022-10-28 17:10:14
6
+ * @param {MouseEvent} event
7
+ * @returns {*}
8
+ */
9
+ export declare function eventPath(event: MouseEvent): (EventTarget | null)[];
10
+ /**
11
+ * 监听JS原生事件,返回cleanup回调,调用后删除该监听
12
+ *
13
+ * @author lxm
14
+ * @date 2022-10-28 18:10:36
15
+ * @export
16
+ * @param {EventTarget} target 监听对象
17
+ * @param {string} eventName 监听事件名称
18
+ * @param {(..._args: any[]) => any} listener 监听回调
19
+ * @param {AddEventListenerOptions} options 额外参数
20
+ * @returns {*} {() => void}
21
+ */
22
+ export declare function listenJSEvent(target: EventTarget, eventName: string, listener: (..._args: any[]) => any, options?: AddEventListenerOptions): () => void;
23
+ /**
24
+ * event是否是在目标元素内部触发的
25
+ *
26
+ * @author lxm
27
+ * @date 2022-10-31 11:10:49
28
+ * @export
29
+ * @param {MouseEvent} event 原生事件
30
+ * @param {HTMLElement} el 目标元素
31
+ * @returns {*} {boolean}
32
+ */
33
+ export declare function isEventInside(event: MouseEvent, el: HTMLElement): boolean;
34
+ //# sourceMappingURL=event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../../src/utils/event/event.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,EAAE,CAmBnE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,CAAC,GAAG,KAAK,EAAE,GAAG,EAAE,KAAK,GAAG,EAClC,OAAO,GAAE,uBAA4B,GACpC,MAAM,IAAI,CAYZ;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,WAAW,GAAG,OAAO,CAEzE"}
@@ -0,0 +1,60 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { NOOP } from '../../constant';
3
+ /**
4
+ * 计算event的composedPath返回事件路径(兼容了IE)
5
+ *
6
+ * @author lxm
7
+ * @date 2022-10-28 17:10:14
8
+ * @param {MouseEvent} event
9
+ * @returns {*}
10
+ */
11
+ export function eventPath(event) {
12
+ const path = ((event.composedPath && event.composedPath()) ||
13
+ event.path);
14
+ if (path != null)
15
+ return path;
16
+ // 浏览器没有提供的,自己递归计算
17
+ function getParents(node, memo = []) {
18
+ const parentNode = node.parentNode;
19
+ return parentNode
20
+ ? getParents(parentNode, memo.concat([parentNode]))
21
+ : memo;
22
+ }
23
+ return [event.target].concat(getParents(event.target));
24
+ }
25
+ /**
26
+ * 监听JS原生事件,返回cleanup回调,调用后删除该监听
27
+ *
28
+ * @author lxm
29
+ * @date 2022-10-28 18:10:36
30
+ * @export
31
+ * @param {EventTarget} target 监听对象
32
+ * @param {string} eventName 监听事件名称
33
+ * @param {(..._args: any[]) => any} listener 监听回调
34
+ * @param {AddEventListenerOptions} options 额外参数
35
+ * @returns {*} {() => void}
36
+ */
37
+ export function listenJSEvent(target, eventName, listener, options = {}) {
38
+ target.addEventListener(eventName, listener, options);
39
+ let cleanup = () => {
40
+ target.removeEventListener(eventName, listener, options);
41
+ // cleanup方法只能调用一次
42
+ cleanup = NOOP;
43
+ };
44
+ return () => {
45
+ cleanup();
46
+ };
47
+ }
48
+ /**
49
+ * event是否是在目标元素内部触发的
50
+ *
51
+ * @author lxm
52
+ * @date 2022-10-31 11:10:49
53
+ * @export
54
+ * @param {MouseEvent} event 原生事件
55
+ * @param {HTMLElement} el 目标元素
56
+ * @returns {*} {boolean}
57
+ */
58
+ export function isEventInside(event, el) {
59
+ return el && (event.target === el || eventPath(event).includes(el));
60
+ }
@@ -1,7 +1,16 @@
1
- export { Interceptor } from './interceptor/interceptor';
1
+ export * from './interceptor';
2
+ export { Logger } from './logger/logger';
2
3
  export { Namespace } from './namespace/namespace';
3
4
  export { IHttpResponse, HttpResponse } from './net/http-response';
4
5
  export { Net } from './net/net';
5
6
  export { plural, pluralLower } from './plural/plural';
6
7
  export * from './util/util';
8
+ export * from './url-helper/url-helper';
9
+ export * from './event/event';
10
+ export * from './click-outside/click-outside';
11
+ export * from './color/color';
12
+ export * from './download-file/download-file';
13
+ export * from './upload/select-file';
14
+ export * from './upload/upload-file';
15
+ export * from './sync';
7
16
  //# sourceMappingURL=index.d.ts.map
@@ -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,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,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;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,eAAe,CAAC;AAC9B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,QAAQ,CAAC"}
@@ -1,6 +1,15 @@
1
- export { Interceptor } from './interceptor/interceptor';
1
+ export * from './interceptor';
2
+ export { Logger } from './logger/logger';
2
3
  export { Namespace } from './namespace/namespace';
3
4
  export { HttpResponse } from './net/http-response';
4
5
  export { Net } from './net/net';
5
6
  export { plural, pluralLower } from './plural/plural';
6
7
  export * from './util/util';
8
+ export * from './url-helper/url-helper';
9
+ export * from './event/event';
10
+ export * from './click-outside/click-outside';
11
+ export * from './color/color';
12
+ export * from './download-file/download-file';
13
+ export * from './upload/select-file';
14
+ export * from './upload/upload-file';
15
+ export * from './sync';
@@ -0,0 +1,15 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import { Interceptor } from './interceptor';
3
+ /**
4
+ * 核心包拦截器
5
+ *
6
+ * @author lxm
7
+ * @date 2022-10-27 17:10:48
8
+ * @export
9
+ * @class CoreInterceptor
10
+ * @extends {Interceptor}
11
+ */
12
+ export declare class CoreInterceptor extends Interceptor {
13
+ protected onBeforeRequest(config: AxiosRequestConfig): Promise<AxiosRequestConfig>;
14
+ }
15
+ //# sourceMappingURL=core-interceptor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-interceptor.d.ts","sourceRoot":"","sources":["../../../src/utils/interceptor/core-interceptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;;;;;;GAQG;AACH,qBAAa,eAAgB,SAAQ,WAAW;cAC9B,eAAe,CAC7B,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,kBAAkB,CAAC;CAkB/B"}
@@ -0,0 +1,30 @@
1
+ import { getToken } from '../util/util';
2
+ import { Interceptor } from './interceptor';
3
+ /**
4
+ * 核心包拦截器
5
+ *
6
+ * @author lxm
7
+ * @date 2022-10-27 17:10:48
8
+ * @export
9
+ * @class CoreInterceptor
10
+ * @extends {Interceptor}
11
+ */
12
+ export class CoreInterceptor extends Interceptor {
13
+ async onBeforeRequest(config) {
14
+ await super.onBeforeRequest(config);
15
+ if (!config.headers) {
16
+ config.headers = {};
17
+ }
18
+ config.headers.Authorization = `Bearer ${getToken()}`;
19
+ const { orgData } = ibiz;
20
+ if (orgData) {
21
+ if (orgData.systemid) {
22
+ config.headers.srfsystemid = orgData.systemid;
23
+ }
24
+ if (orgData.orgid) {
25
+ config.headers.srforgid = orgData.orgid;
26
+ }
27
+ }
28
+ return config;
29
+ }
30
+ }
@@ -0,0 +1,3 @@
1
+ export * from './core-interceptor';
2
+ export * from './interceptor';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/interceptor/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './core-interceptor';
2
+ export * from './interceptor';
@@ -1,5 +1,6 @@
1
+ import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
1
2
  /**
2
- * 默认请求拦截器
3
+ * 拦截器基类
3
4
  *
4
5
  * @author chitanda
5
6
  * @date 2022-07-20 18:07:11
@@ -7,7 +8,77 @@
7
8
  * @class Interceptor
8
9
  */
9
10
  export declare class Interceptor {
10
- constructor();
11
- protected init(): void;
11
+ /**
12
+ * 请求拦截器绑定标识
13
+ *
14
+ * @author lxm
15
+ * @date 2022-10-27 17:10:20
16
+ * @private
17
+ * @type {number}
18
+ */
19
+ private requestTag?;
20
+ /**
21
+ * 响应拦截器绑定标识
22
+ *
23
+ * @author lxm
24
+ * @date 2022-10-27 17:10:19
25
+ * @private
26
+ * @type {number}
27
+ */
28
+ private responseTag?;
29
+ /**
30
+ * 请求之前处理
31
+ *
32
+ * @author lxm
33
+ * @date 2022-10-27 17:10:41
34
+ * @protected
35
+ * @param {AxiosRequestConfig} config
36
+ * @returns {*} {Promise<AxiosRequestConfig>}
37
+ */
38
+ protected onBeforeRequest(config: AxiosRequestConfig): Promise<AxiosRequestConfig>;
39
+ /**
40
+ * 请求失败之后处理
41
+ *
42
+ * @author lxm
43
+ * @date 2022-10-27 17:10:40
44
+ * @protected
45
+ * @param {*} error
46
+ */
47
+ protected onRequestError(error: any): Promise<never>;
48
+ /**
49
+ * 响应成功之后处理
50
+ *
51
+ * @author lxm
52
+ * @date 2022-10-27 17:10:38
53
+ * @protected
54
+ * @param {AxiosResponse} config
55
+ * @returns {*} {Promise<AxiosRequestConfig>}
56
+ */
57
+ protected onResponseSuccess(config: AxiosResponse): Promise<AxiosResponse>;
58
+ /**
59
+ * 响应失败之后处理
60
+ *
61
+ * @author lxm
62
+ * @date 2022-10-27 17:10:37
63
+ * @protected
64
+ * @param {*} _error
65
+ */
66
+ protected onResponseError(error: any): Promise<never>;
67
+ /**
68
+ * 使用拦截器
69
+ *
70
+ * @author lxm
71
+ * @date 2022-10-27 17:10:28
72
+ * @param {AxiosInstance} instance
73
+ */
74
+ use(instance: AxiosInstance): void;
75
+ /**
76
+ * 移出拦截器
77
+ *
78
+ * @author lxm
79
+ * @date 2022-10-27 17:10:27
80
+ * @param {AxiosInstance} instance
81
+ */
82
+ eject(instance: AxiosInstance): void;
12
83
  }
13
84
  //# sourceMappingURL=interceptor.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"interceptor.d.ts","sourceRoot":"","sources":["../../../src/utils/interceptor/interceptor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEzE;;;;;;;GAOG;AACH,qBAAa,WAAW;IACtB;;;;;;;OAOG;IACH,OAAO,CAAC,UAAU,CAAC,CAAS;IAE5B;;;;;;;OAOG;IACH,OAAO,CAAC,WAAW,CAAC,CAAS;IAE7B;;;;;;;;OAQG;cACa,eAAe,CAC7B,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,kBAAkB,CAAC;IAI9B;;;;;;;OAOG;IACH,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,GAAG;IAKnC;;;;;;;;OAQG;cACa,iBAAiB,CAC/B,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,aAAa,CAAC;IAIzB;;;;;;;OAOG;IACH,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,GAAG;IAKpC;;;;;;OAMG;IACH,GAAG,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI;IAWlC;;;;;;OAMG;IACH,KAAK,CAAC,QAAQ,EAAE,aAAa;CAQ9B"}
@@ -1,7 +1,5 @@
1
- import axios from 'axios';
2
- import { getToken } from '../util/util';
3
1
  /**
4
- * 默认请求拦截器
2
+ * 拦截器基类
5
3
  *
6
4
  * @author chitanda
7
5
  * @date 2022-07-20 18:07:11
@@ -9,25 +7,78 @@ import { getToken } from '../util/util';
9
7
  * @class Interceptor
10
8
  */
11
9
  export class Interceptor {
12
- constructor() {
13
- this.init();
10
+ /**
11
+ * 请求之前处理
12
+ *
13
+ * @author lxm
14
+ * @date 2022-10-27 17:10:41
15
+ * @protected
16
+ * @param {AxiosRequestConfig} config
17
+ * @returns {*} {Promise<AxiosRequestConfig>}
18
+ */
19
+ async onBeforeRequest(config) {
20
+ return config;
14
21
  }
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
- });
22
+ /**
23
+ * 请求失败之后处理
24
+ *
25
+ * @author lxm
26
+ * @date 2022-10-27 17:10:40
27
+ * @protected
28
+ * @param {*} error
29
+ */
30
+ onRequestError(error) {
31
+ // 处理请求错误
32
+ return Promise.reject(error);
33
+ }
34
+ /**
35
+ * 响应成功之后处理
36
+ *
37
+ * @author lxm
38
+ * @date 2022-10-27 17:10:38
39
+ * @protected
40
+ * @param {AxiosResponse} config
41
+ * @returns {*} {Promise<AxiosRequestConfig>}
42
+ */
43
+ async onResponseSuccess(config) {
44
+ return config;
45
+ }
46
+ /**
47
+ * 响应失败之后处理
48
+ *
49
+ * @author lxm
50
+ * @date 2022-10-27 17:10:37
51
+ * @protected
52
+ * @param {*} _error
53
+ */
54
+ onResponseError(error) {
55
+ // 处理响应错误
56
+ return Promise.reject(error);
57
+ }
58
+ /**
59
+ * 使用拦截器
60
+ *
61
+ * @author lxm
62
+ * @date 2022-10-27 17:10:28
63
+ * @param {AxiosInstance} instance
64
+ */
65
+ use(instance) {
66
+ this.requestTag = instance.interceptors.request.use(this.onBeforeRequest, this.onRequestError);
67
+ this.responseTag = instance.interceptors.response.use(this.onResponseSuccess, this.onResponseError);
68
+ }
69
+ /**
70
+ * 移出拦截器
71
+ *
72
+ * @author lxm
73
+ * @date 2022-10-27 17:10:27
74
+ * @param {AxiosInstance} instance
75
+ */
76
+ eject(instance) {
77
+ if (this.requestTag) {
78
+ instance.interceptors.request.eject(this.requestTag);
79
+ }
80
+ if (this.responseTag) {
81
+ instance.interceptors.response.eject(this.responseTag);
82
+ }
32
83
  }
33
84
  }
@@ -0,0 +1,3 @@
1
+ import * as Logger from 'loglevel';
2
+ export { Logger };
3
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/utils/logger/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AAEnC,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ import * as Logger from 'loglevel';
2
+ export { Logger };
@@ -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?: boolean;
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
- * header 本地仿造时值为空
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,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"}
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 本地仿造时值为空