@ibiz-template/core 0.0.1-alpha.4 → 0.0.1-alpha.40

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 (114) hide show
  1. package/dist/system/index.system.js +1 -0
  2. package/out/constant/http-status-message/http-status-message.d.ts +5 -0
  3. package/out/constant/http-status-message/http-status-message.d.ts.map +1 -0
  4. package/out/constant/http-status-message/http-status-message.js +20 -0
  5. package/out/constant/index.d.ts +4 -0
  6. package/out/constant/index.d.ts.map +1 -1
  7. package/out/constant/index.js +4 -0
  8. package/out/constant/login-mode/login-mode.d.ts +23 -0
  9. package/out/constant/login-mode/login-mode.d.ts.map +1 -0
  10. package/out/constant/login-mode/login-mode.js +24 -0
  11. package/out/constant/menu-permission-mode/menu-permission-mode.d.ts +23 -0
  12. package/out/constant/menu-permission-mode/menu-permission-mode.d.ts.map +1 -0
  13. package/out/constant/menu-permission-mode/menu-permission-mode.js +24 -0
  14. package/out/constant/util/util.d.ts +5 -0
  15. package/out/constant/util/util.d.ts.map +1 -0
  16. package/out/constant/util/util.js +5 -0
  17. package/out/context/index.d.ts +2 -39
  18. package/out/context/index.d.ts.map +1 -1
  19. package/out/context/index.js +34 -65
  20. package/out/environment/environment.d.ts.map +1 -1
  21. package/out/environment/environment.js +11 -1
  22. package/out/error/http-error/http-error.d.ts +18 -0
  23. package/out/error/http-error/http-error.d.ts.map +1 -0
  24. package/out/error/http-error/http-error.js +36 -0
  25. package/out/error/index.d.ts +3 -0
  26. package/out/error/index.d.ts.map +1 -0
  27. package/out/error/index.js +2 -0
  28. package/out/error/runtime-error/runtime-error.d.ts +15 -0
  29. package/out/error/runtime-error/runtime-error.d.ts.map +1 -0
  30. package/out/error/runtime-error/runtime-error.js +15 -0
  31. package/out/factory-center.d.ts +11 -0
  32. package/out/factory-center.d.ts.map +1 -0
  33. package/out/factory-center.js +10 -0
  34. package/out/ibizsys.d.ts +8 -1
  35. package/out/ibizsys.d.ts.map +1 -1
  36. package/out/ibizsys.js +8 -1
  37. package/out/index.d.ts +3 -1
  38. package/out/index.d.ts.map +1 -1
  39. package/out/index.js +3 -1
  40. package/out/install.d.ts.map +1 -1
  41. package/out/install.js +4 -2
  42. package/out/interface/click-outside/click-outside.d.ts +70 -0
  43. package/out/interface/click-outside/click-outside.d.ts.map +1 -0
  44. package/out/interface/click-outside/click-outside.js +1 -0
  45. package/out/interface/i-environment/i-environment.d.ts +76 -0
  46. package/out/interface/i-environment/i-environment.d.ts.map +1 -1
  47. package/out/interface/index.d.ts +1 -0
  48. package/out/interface/index.d.ts.map +1 -1
  49. package/out/interface/index.js +1 -1
  50. package/out/types.d.ts +20 -0
  51. package/out/types.d.ts.map +1 -1
  52. package/out/utils/click-outside/click-outside.d.ts +14 -0
  53. package/out/utils/click-outside/click-outside.d.ts.map +1 -0
  54. package/out/utils/click-outside/click-outside.js +85 -0
  55. package/out/utils/event/event.d.ts +34 -0
  56. package/out/utils/event/event.d.ts.map +1 -0
  57. package/out/utils/event/event.js +60 -0
  58. package/out/utils/index.d.ts +5 -1
  59. package/out/utils/index.d.ts.map +1 -1
  60. package/out/utils/index.js +5 -1
  61. package/out/utils/interceptor/core-interceptor.d.ts +15 -0
  62. package/out/utils/interceptor/core-interceptor.d.ts.map +1 -0
  63. package/out/utils/interceptor/core-interceptor.js +30 -0
  64. package/out/utils/interceptor/index.d.ts +3 -0
  65. package/out/utils/interceptor/index.d.ts.map +1 -0
  66. package/out/utils/interceptor/index.js +2 -0
  67. package/out/utils/interceptor/interceptor.d.ts +74 -3
  68. package/out/utils/interceptor/interceptor.d.ts.map +1 -1
  69. package/out/utils/interceptor/interceptor.js +73 -22
  70. package/out/utils/logger/logger.d.ts +3 -0
  71. package/out/utils/logger/logger.d.ts.map +1 -0
  72. package/out/utils/logger/logger.js +2 -0
  73. package/out/utils/net/http-response.d.ts +4 -9
  74. package/out/utils/net/http-response.d.ts.map +1 -1
  75. package/out/utils/net/http-response.js +0 -7
  76. package/out/utils/net/net.d.ts +82 -31
  77. package/out/utils/net/net.d.ts.map +1 -1
  78. package/out/utils/net/net.js +145 -50
  79. package/out/utils/url-helper/url-helper.d.ts +51 -0
  80. package/out/utils/url-helper/url-helper.d.ts.map +1 -0
  81. package/out/utils/url-helper/url-helper.js +59 -0
  82. package/out/utils/util/util.d.ts +45 -0
  83. package/out/utils/util/util.d.ts.map +1 -1
  84. package/out/utils/util/util.js +96 -0
  85. package/package.json +18 -7
  86. package/src/constant/http-status-message/http-status-message.ts +20 -0
  87. package/src/constant/index.ts +4 -0
  88. package/src/constant/login-mode/login-mode.ts +23 -0
  89. package/src/constant/menu-permission-mode/menu-permission-mode.ts +23 -0
  90. package/src/constant/util/util.ts +5 -0
  91. package/src/context/index.ts +35 -69
  92. package/src/environment/environment.ts +11 -1
  93. package/src/error/http-error/http-error.ts +43 -0
  94. package/src/error/index.ts +2 -0
  95. package/src/error/runtime-error/runtime-error.ts +14 -0
  96. package/src/factory-center.ts +9 -0
  97. package/src/ibizsys.ts +9 -1
  98. package/src/index.ts +3 -1
  99. package/src/install.ts +4 -2
  100. package/src/interface/click-outside/click-outside.ts +71 -0
  101. package/src/interface/i-environment/i-environment.ts +86 -0
  102. package/src/interface/index.ts +1 -0
  103. package/src/types.ts +21 -0
  104. package/src/utils/click-outside/click-outside.ts +110 -0
  105. package/src/utils/event/event.ts +77 -0
  106. package/src/utils/index.ts +5 -1
  107. package/src/utils/interceptor/core-interceptor.ts +35 -0
  108. package/src/utils/interceptor/index.ts +2 -0
  109. package/src/utils/interceptor/interceptor.ts +109 -22
  110. package/src/utils/logger/logger.ts +3 -0
  111. package/src/utils/net/http-response.ts +6 -9
  112. package/src/utils/net/net.ts +175 -61
  113. package/src/utils/url-helper/url-helper.ts +62 -0
  114. package/src/utils/util/util.ts +115 -0
@@ -1 +1 @@
1
- {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,wBAAgB,OAAO,IAAI,IAAI,CAM9B"}
1
+ {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,wBAAgB,OAAO,IAAI,IAAI,CAO9B"}
package/out/install.js CHANGED
@@ -1,5 +1,6 @@
1
+ import { FactoryCenter } from './factory-center';
1
2
  import { IBizSys } from './ibizsys';
2
- import { Interceptor } from './utils';
3
+ import { CoreInterceptor } from './utils';
3
4
  /**
4
5
  * 初始化全局对象
5
6
  *
@@ -12,5 +13,6 @@ export function install() {
12
13
  throw new Error('ibiz 已经存在, 无需重复安装');
13
14
  }
14
15
  window.ibiz = new IBizSys();
15
- new Interceptor();
16
+ window.___fc = new FactoryCenter();
17
+ ibiz.net.addInterceptor('CoreInterceptor', new CoreInterceptor());
16
18
  }
@@ -0,0 +1,70 @@
1
+ /**
2
+ * 可选配置参数
3
+ *
4
+ * @author lxm
5
+ * @date 2022-10-28 16:10:48
6
+ * @export
7
+ * @interface OnClickOutsideOptions
8
+ * @extends {ConfigurableWindow}
9
+ * @template E
10
+ */
11
+ export interface OnClickOutsideOptions {
12
+ /**
13
+ * 指定使用的window,不给就用默认的window
14
+ * 一般是在iframe或测试环境中使用。
15
+ *
16
+ * @author lxm
17
+ * @date 2022-10-28 17:10:49
18
+ * @type {Window}
19
+ */
20
+ window?: Window;
21
+ /**
22
+ * 指定需要忽略的元素,用于排除某些外部的元素
23
+ *
24
+ * @author lxm
25
+ * @date 2022-10-28 17:10:50
26
+ * @type {HTMLElement[]}
27
+ */
28
+ ignore?: HTMLElement[];
29
+ /**
30
+ * 是否捕获内部元素。默认为是,内部元素不会触发回调。
31
+ * @default true
32
+ */
33
+ capture?: boolean;
34
+ }
35
+ /**
36
+ * 回调处理函数类型
37
+ */
38
+ export declare type OnClickOutsideHandler = (_evt: PointerEvent | MouseEvent) => void;
39
+ /**
40
+ * OnClickOutside返回对象类型
41
+ *
42
+ * @author lxm
43
+ * @date 2022-10-31 11:10:59
44
+ * @export
45
+ * @interface OnClickOutsideResult
46
+ */
47
+ export interface OnClickOutsideResult {
48
+ /**
49
+ * 停止监听,并移除相关监听事件
50
+ *
51
+ * @author lxm
52
+ * @date 2022-10-31 11:10:28
53
+ */
54
+ stop: () => void;
55
+ /**
56
+ * 暂停监听
57
+ *
58
+ * @author lxm
59
+ * @date 2022-10-31 11:10:30
60
+ */
61
+ pause: () => void;
62
+ /**
63
+ * 继续监听
64
+ *
65
+ * @author lxm
66
+ * @date 2022-10-31 11:10:32
67
+ */
68
+ proceed: () => void;
69
+ }
70
+ //# sourceMappingURL=click-outside.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"click-outside.d.ts","sourceRoot":"","sources":["../../../src/interface/click-outside/click-outside.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;IACvB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,oBAAY,qBAAqB,GAAG,CAAC,IAAI,EAAE,YAAY,GAAG,UAAU,KAAK,IAAI,CAAC;AAE9E;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB;;;;;OAKG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB;;;;;OAKG;IACH,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,5 @@
1
+ import { LogLevelDesc } from 'loglevel';
2
+ import { LoginMode, MenuPermissionMode } from '../../constant';
1
3
  /**
2
4
  * 配置参数
3
5
  *
@@ -15,6 +17,32 @@ export interface IEnvironment {
15
17
  * @type {string}
16
18
  */
17
19
  namespace?: string;
20
+ /**
21
+ * 是否为开发模式
22
+ *
23
+ * @default false
24
+ * @author chitanda
25
+ * @date 2022-10-21 11:10:29
26
+ * @type {boolean}
27
+ */
28
+ dev: boolean;
29
+ /**
30
+ * 日志级别
31
+ *
32
+ * @author chitanda
33
+ * @date 2022-10-25 20:10:55
34
+ * @type {LogLevelDesc}
35
+ */
36
+ logLevel: LogLevelDesc;
37
+ /**
38
+ * js 静态文件 cdn 地址
39
+ *
40
+ * @default https://cdn.jsdelivr.net/
41
+ * @author chitanda
42
+ * @date 2022-10-24 11:10:14
43
+ * @type {string}
44
+ */
45
+ jsCdn: string;
18
46
  /**
19
47
  * 请求根路径
20
48
  *
@@ -23,6 +51,38 @@ export interface IEnvironment {
23
51
  * @type {string}
24
52
  */
25
53
  baseUrl: string;
54
+ /**
55
+ * 插件默认所在目录
56
+ *
57
+ * @author chitanda
58
+ * @date 2022-10-31 14:10:49
59
+ * @type {string}
60
+ */
61
+ pluginBaseUrl: string;
62
+ /**
63
+ * 登录模式
64
+ *
65
+ * @author lxm
66
+ * @date 2022-10-12 14:10:51
67
+ * @type {LoginMode}
68
+ */
69
+ loginMode: LoginMode;
70
+ /**
71
+ * 中央认证登录地址
72
+ *
73
+ * @author lxm
74
+ * @date 2022-10-11 12:10:21
75
+ * @type {string}
76
+ */
77
+ casLoginUrl: string;
78
+ /**
79
+ * 远程模型路径
80
+ *
81
+ * @author chitanda
82
+ * @date 2022-09-22 18:09:25
83
+ * @type {string}
84
+ */
85
+ remoteModelUrl: string;
26
86
  /**
27
87
  * 资源文件根路径
28
88
  *
@@ -55,5 +115,21 @@ export interface IEnvironment {
55
115
  * @type {string}
56
116
  */
57
117
  UploadFile: string;
118
+ /**
119
+ * 是否启用权限校验(默认true)
120
+ *
121
+ * @author lxm
122
+ * @date 2022-10-12 18:10:25
123
+ * @type {boolean}
124
+ */
125
+ enablePermission: boolean;
126
+ /**
127
+ * 菜单权限校验模式(默认MIXIN)
128
+ *
129
+ * @author lxm
130
+ * @date 2022-10-12 18:10:27
131
+ * @type {MenuPermissionMode}
132
+ */
133
+ menuPermissionMode: MenuPermissionMode;
58
134
  }
59
135
  //# sourceMappingURL=i-environment.d.ts.map
@@ -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;CACpB"}
1
+ {"version":3,"file":"i-environment.d.ts","sourceRoot":"","sources":["../../../src/interface/i-environment/i-environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,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;;;;;;OAMG;IACH,QAAQ,EAAE,YAAY,CAAC;IAEvB;;;;;;;OAOG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;;;OAMG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;;;OAMG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;;;;;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"}
@@ -1,3 +1,4 @@
1
1
  export { IEnvironment } from './i-environment/i-environment';
2
2
  export { OrgData } from './org-data/org-data';
3
+ export * from './click-outside/click-outside';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interface/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interface/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,cAAc,+BAA+B,CAAC"}
@@ -1 +1 @@
1
- export {};
1
+ export * from './click-outside/click-outside';
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
@@ -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;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;CACF"}
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"}
@@ -0,0 +1,14 @@
1
+ import { OnClickOutsideHandler, OnClickOutsideOptions, OnClickOutsideResult } from '../../interface';
2
+ /**
3
+ * 监听目标元素之外的点击事件回调
4
+ *
5
+ * @author lxm
6
+ * @date 2022-10-28 18:10:25
7
+ * @export
8
+ * @param {HTMLElement} target 目标元素
9
+ * @param {OnClickOutsideHandler} handler 触发的时间回调
10
+ * @param {OnClickOutsideOptions} [options={}] 额外配置参数
11
+ * @returns {*} {OnClickOutsideResult}
12
+ */
13
+ export declare function onClickOutside(target: HTMLElement, handler: OnClickOutsideHandler, options?: OnClickOutsideOptions): OnClickOutsideResult;
14
+ //# sourceMappingURL=click-outside.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"click-outside.d.ts","sourceRoot":"","sources":["../../../src/utils/click-outside/click-outside.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AAKzB;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,qBAAqB,EAC9B,OAAO,GAAE,qBAA0B,GAClC,oBAAoB,CAoFtB"}
@@ -0,0 +1,85 @@
1
+ import { RuntimeError } from '../../error';
2
+ import { eventPath, isEventInside, listenJSEvent } from '../event/event';
3
+ const defaultWindow = typeof window !== 'undefined' ? window : undefined;
4
+ /**
5
+ * 监听目标元素之外的点击事件回调
6
+ *
7
+ * @author lxm
8
+ * @date 2022-10-28 18:10:25
9
+ * @export
10
+ * @param {HTMLElement} target 目标元素
11
+ * @param {OnClickOutsideHandler} handler 触发的时间回调
12
+ * @param {OnClickOutsideOptions} [options={}] 额外配置参数
13
+ * @returns {*} {OnClickOutsideResult}
14
+ */
15
+ export function onClickOutside(target, handler, options = {}) {
16
+ const { window = defaultWindow, ignore = [], capture = true } = options;
17
+ if (!target)
18
+ throw new RuntimeError('target元素不存在');
19
+ if (!window)
20
+ throw new RuntimeError('找不到window');
21
+ /** 是否需要监听,为false时handler不会执行 */
22
+ let shouldListen = true;
23
+ /**
24
+ * 判断event的触发是否是在元素的外部(排除了ignore元素)
25
+ * @param event 事件对象
26
+ * @returns
27
+ */
28
+ const isOutside = (event) => {
29
+ // 有一个判断是在内部,则不算外部,返回false
30
+ return ![target, ...ignore].some(el => {
31
+ return isEventInside(event, el);
32
+ });
33
+ };
34
+ /** 暂停,所有监听的回调都不执行,用于增强某些ignore无法实现的场景 */
35
+ let isPaused = false;
36
+ const pause = () => {
37
+ isPaused = true;
38
+ };
39
+ const proceed = () => {
40
+ isPaused = false;
41
+ };
42
+ /** pointerup延时触发标识 */
43
+ let fallback;
44
+ /**
45
+ * 事件监听处理回调
46
+ * @param event 事件对象
47
+ * @returns
48
+ */
49
+ const listener = (event) => {
50
+ if (isPaused)
51
+ return;
52
+ window.clearTimeout(fallback);
53
+ // 当需要监听并且最终触发在外部时才需要执行回调
54
+ if (!(shouldListen && isOutside(event)))
55
+ return;
56
+ handler(event);
57
+ };
58
+ // 鼠标左键单击先后触发pointerdown,pointerup,click
59
+ // 鼠标右键单击先后触发pointerdown,pointerup
60
+ const cleanups = [
61
+ listenJSEvent(window, 'click', listener, { passive: true, capture }),
62
+ listenJSEvent(window, 'pointerdown', e => {
63
+ if (isPaused)
64
+ return;
65
+ // 当pointerdown是在内部触发则不需要后续监听
66
+ shouldListen = isOutside(e);
67
+ }, { passive: true }),
68
+ listenJSEvent(window, 'pointerup', e => {
69
+ if (isPaused)
70
+ return;
71
+ // 鼠标左键触发才执行
72
+ if (e.button === 0) {
73
+ // 锁死结果避免延时执行时变更
74
+ const path = eventPath(e);
75
+ e.composedPath = () => path;
76
+ fallback = window.setTimeout(() => listener(e), 50);
77
+ }
78
+ }, { passive: true }),
79
+ ].filter(Boolean);
80
+ /**
81
+ * 停止事件监听,移除监听
82
+ */
83
+ const stop = () => cleanups.forEach(fn => fn());
84
+ return { stop, pause, proceed };
85
+ }
@@ -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,11 @@
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';
7
11
  //# 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"}
@@ -1,6 +1,10 @@
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';
@@ -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"}