@ibiz-template/core 0.7.41-alpha.12 → 0.7.41-alpha.138

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 (200) hide show
  1. package/dist/index.esm.js +94 -23
  2. package/dist/index.system.min.js +1 -1
  3. package/out/environment/environment.d.ts.map +1 -1
  4. package/out/environment/environment.js +10 -0
  5. package/out/error/http-error/http-error-factory.d.ts +1 -1
  6. package/out/error/http-error/http-error-factory.d.ts.map +1 -1
  7. package/out/error/http-error/http-error-factory.js +11 -1
  8. package/out/error/http-error/http-error.d.ts +2 -2
  9. package/out/error/http-error/http-error.d.ts.map +1 -1
  10. package/out/interface/api/chat-message/i-api-chat-message.d.ts +63 -0
  11. package/out/interface/api/chat-message/i-api-chat-message.d.ts.map +1 -0
  12. package/out/interface/api/chat-message/i-api-chat-message.js +1 -0
  13. package/out/interface/api/chat-message/index.d.ts +2 -0
  14. package/out/interface/api/chat-message/index.d.ts.map +1 -0
  15. package/out/interface/api/chat-message/index.js +1 -0
  16. package/out/interface/api/environment/i-devtool-config.d.ts +29 -1
  17. package/out/interface/api/environment/i-devtool-config.d.ts.map +1 -1
  18. package/out/interface/api/environment/i-environment.d.ts +146 -1
  19. package/out/interface/api/environment/i-environment.d.ts.map +1 -1
  20. package/out/interface/api/ibizsys/i-app-data.d.ts +57 -0
  21. package/out/interface/api/ibizsys/i-app-data.d.ts.map +1 -0
  22. package/out/interface/api/ibizsys/i-app-data.js +1 -0
  23. package/out/interface/api/ibizsys/i-org-data.d.ts +1 -1
  24. package/out/interface/api/ibizsys/index.d.ts +1 -0
  25. package/out/interface/api/ibizsys/index.d.ts.map +1 -1
  26. package/out/interface/api/index.d.ts +1 -0
  27. package/out/interface/api/index.d.ts.map +1 -1
  28. package/out/interface/api/index.js +1 -0
  29. package/out/interface/api/utils/i-api-i18n.d.ts +9 -9
  30. package/out/interface/api/utils/index.d.ts +1 -0
  31. package/out/interface/api/utils/index.d.ts.map +1 -1
  32. package/out/interface/api/utils/message-center/base/i-message-base.d.ts +3 -3
  33. package/out/interface/api/utils/message-center/command/add-in-changed/i-command-add-in-changed.d.ts +1 -1
  34. package/out/interface/api/utils/message-center/command/async-action/i-command-async-action.d.ts +1 -1
  35. package/out/interface/api/utils/message-center/command/i-message-command.d.ts +1 -1
  36. package/out/interface/api/utils/message-center/command/internal-message/i-command-internal-message.d.ts +1 -1
  37. package/out/interface/api/utils/message-center/command/mark-open-data/i-command-mark-open-data.d.ts +1 -1
  38. package/out/interface/api/utils/message-center/common/i-message-center-event.d.ts +5 -0
  39. package/out/interface/api/utils/message-center/common/i-message-center-event.d.ts.map +1 -1
  40. package/out/interface/api/utils/message-center/common/i-portal-message.d.ts +3 -3
  41. package/out/interface/api/utils/message-center/console/i-message-console.d.ts +1 -1
  42. package/out/interface/api/utils/message-center/error/i-message-error.d.ts +1 -1
  43. package/out/interface/api/utils/message-center/i-message-center.d.ts +2 -2
  44. package/out/interface/api/utils/net/i-api-http-error.d.ts +39 -0
  45. package/out/interface/api/utils/net/i-api-http-error.d.ts.map +1 -0
  46. package/out/interface/api/utils/net/i-api-http-error.js +1 -0
  47. package/out/interface/api/utils/net/i-api-net.d.ts +1 -1
  48. package/out/interface/i-chat-message/i-chat-message.d.ts +2 -49
  49. package/out/interface/i-chat-message/i-chat-message.d.ts.map +1 -1
  50. package/out/utils/download-file/download-file.d.ts.map +1 -1
  51. package/out/utils/download-file/download-file.js +5 -1
  52. package/out/utils/interceptor/core-interceptor.js +2 -1
  53. package/out/utils/net/http-response.d.ts +2 -1
  54. package/out/utils/net/http-response.d.ts.map +1 -1
  55. package/out/utils/net/http-response.js +5 -1
  56. package/out/utils/net/net.d.ts +1 -1
  57. package/out/utils/net/net.d.ts.map +1 -1
  58. package/out/utils/net/net.js +16 -6
  59. package/out/utils/recursive/find-recursive-child.d.ts +20 -0
  60. package/out/utils/recursive/find-recursive-child.d.ts.map +1 -1
  61. package/out/utils/recursive/find-recursive-child.js +69 -7
  62. package/out/utils/string-util/string-util.d.ts.map +1 -1
  63. package/out/utils/string-util/string-util.js +2 -4
  64. package/package.json +5 -4
  65. package/src/command/command-register.ts +121 -0
  66. package/src/command/command.ts +78 -0
  67. package/src/command/index.ts +8 -0
  68. package/src/command/utils/index.ts +2 -0
  69. package/src/command/utils/linked-list.ts +136 -0
  70. package/src/command/utils/util.ts +103 -0
  71. package/src/constant/core/core.ts +54 -0
  72. package/src/constant/emoji/emoji.ts +2929 -0
  73. package/src/constant/http-status-message/http-status-message.ts +18 -0
  74. package/src/constant/index.ts +4 -0
  75. package/src/constant/util/util.ts +3 -0
  76. package/src/context/index.ts +231 -0
  77. package/src/environment/environment.ts +67 -0
  78. package/src/error/http-error/entity-error.ts +29 -0
  79. package/src/error/http-error/http-error-factory.ts +33 -0
  80. package/src/error/http-error/http-error.ts +52 -0
  81. package/src/error/index.ts +7 -0
  82. package/src/error/model-error/model-error.ts +27 -0
  83. package/src/error/notice-error/notice-error.ts +16 -0
  84. package/src/error/runtime-error/runtime-error.ts +13 -0
  85. package/src/error/runtime-model-error/runtime-model-error.ts +27 -0
  86. package/src/ibizsys.ts +82 -0
  87. package/src/index.ts +14 -0
  88. package/src/install.ts +12 -0
  89. package/src/interface/api/chat-message/i-api-chat-message.ts +71 -0
  90. package/src/interface/api/chat-message/index.ts +1 -0
  91. package/src/interface/api/constant/index.ts +2 -0
  92. package/src/interface/api/constant/login-mode/login-mode.ts +25 -0
  93. package/src/interface/api/constant/menu-permission-mode/menu-permission-mode.ts +20 -0
  94. package/src/interface/api/environment/i-devtool-config.ts +76 -0
  95. package/src/interface/api/environment/i-environment.ts +532 -0
  96. package/src/interface/api/environment/index.ts +2 -0
  97. package/src/interface/api/global-param/i-api-context.ts +37 -0
  98. package/src/interface/api/global-param/i-global-param.ts +27 -0
  99. package/src/interface/api/global-param/index.ts +2 -0
  100. package/src/interface/api/ibizsys/i-api-ibizsys.ts +54 -0
  101. package/src/interface/api/ibizsys/i-app-data.ts +64 -0
  102. package/src/interface/api/ibizsys/i-org-data.ts +31 -0
  103. package/src/interface/api/ibizsys/index.ts +3 -0
  104. package/src/interface/api/index.ts +6 -0
  105. package/src/interface/api/utils/i-api-i18n.ts +56 -0
  106. package/src/interface/api/utils/index.ts +5 -0
  107. package/src/interface/api/utils/message-center/base/i-message-all.ts +8 -0
  108. package/src/interface/api/utils/message-center/base/i-message-base.ts +29 -0
  109. package/src/interface/api/utils/message-center/base/index.ts +2 -0
  110. package/src/interface/api/utils/message-center/command/add-in-changed/i-add-in-changed.ts +25 -0
  111. package/src/interface/api/utils/message-center/command/add-in-changed/i-command-add-in-changed.ts +16 -0
  112. package/src/interface/api/utils/message-center/command/async-action/i-command-async-action.ts +17 -0
  113. package/src/interface/api/utils/message-center/command/change/i-command-change.ts +8 -0
  114. package/src/interface/api/utils/message-center/command/create/i-command-create.ts +18 -0
  115. package/src/interface/api/utils/message-center/command/i-command-base.ts +23 -0
  116. package/src/interface/api/utils/message-center/command/i-message-command.ts +94 -0
  117. package/src/interface/api/utils/message-center/command/index.ts +20 -0
  118. package/src/interface/api/utils/message-center/command/internal-message/i-command-internal-message.ts +17 -0
  119. package/src/interface/api/utils/message-center/command/internal-message/i-internal-message.ts +132 -0
  120. package/src/interface/api/utils/message-center/command/mark-open-data/i-command-mark-open-data.ts +17 -0
  121. package/src/interface/api/utils/message-center/command/mark-open-data/i-mark-open-data.ts +47 -0
  122. package/src/interface/api/utils/message-center/command/remove/i-command-remove.ts +18 -0
  123. package/src/interface/api/utils/message-center/command/update/i-command-update.ts +18 -0
  124. package/src/interface/api/utils/message-center/common/i-app-data-entity.ts +16 -0
  125. package/src/interface/api/utils/message-center/common/i-message-center-event.ts +15 -0
  126. package/src/interface/api/utils/message-center/common/i-msg-meta-data.ts +13 -0
  127. package/src/interface/api/utils/message-center/common/i-portal-async-action.ts +144 -0
  128. package/src/interface/api/utils/message-center/common/i-portal-message.ts +84 -0
  129. package/src/interface/api/utils/message-center/common/index.ts +5 -0
  130. package/src/interface/api/utils/message-center/console/i-message-console.ts +17 -0
  131. package/src/interface/api/utils/message-center/error/i-message-error.ts +17 -0
  132. package/src/interface/api/utils/message-center/i-message-center.ts +53 -0
  133. package/src/interface/api/utils/message-center/index.ts +6 -0
  134. package/src/interface/api/utils/net/i-api-http-error.ts +43 -0
  135. package/src/interface/api/utils/net/i-api-net.ts +93 -0
  136. package/src/interface/api/utils/net/i-http-response.ts +67 -0
  137. package/src/interface/click-outside/click-outside.ts +51 -0
  138. package/src/interface/command/command/i-command-option.ts +47 -0
  139. package/src/interface/command/command/i-command.ts +68 -0
  140. package/src/interface/command/disposable/i-disposable.ts +12 -0
  141. package/src/interface/command/i-command-controller.ts +50 -0
  142. package/src/interface/command/index.ts +11 -0
  143. package/src/interface/context/index.ts +42 -0
  144. package/src/interface/error/index.ts +13 -0
  145. package/src/interface/i-chat-message/i-chat-message.ts +16 -0
  146. package/src/interface/ibizsys/i-ibizsys.ts +33 -0
  147. package/src/interface/ibizsys/index.ts +1 -0
  148. package/src/interface/index.ts +11 -0
  149. package/src/interface/utils/i-18n.ts +22 -0
  150. package/src/interface/utils/index.ts +1 -0
  151. package/src/locale/en/index.ts +30 -0
  152. package/src/locale/index.ts +2 -0
  153. package/src/locale/zh-CN/index.ts +28 -0
  154. package/src/params/params.ts +131 -0
  155. package/src/types.ts +26 -0
  156. package/src/utils/bit-mask/bit-mask.ts +87 -0
  157. package/src/utils/click-outside/click-outside.ts +108 -0
  158. package/src/utils/clone/clone.ts +38 -0
  159. package/src/utils/color/color.ts +84 -0
  160. package/src/utils/cookie-util/cookie-util.ts +192 -0
  161. package/src/utils/data-type/data-types.ts +93 -0
  162. package/src/utils/download-file/download-file.ts +110 -0
  163. package/src/utils/event/event.ts +69 -0
  164. package/src/utils/history-list/history-item.ts +41 -0
  165. package/src/utils/history-list/history-list.ts +137 -0
  166. package/src/utils/index.ts +24 -0
  167. package/src/utils/interceptor/core-interceptor.ts +127 -0
  168. package/src/utils/interceptor/index.ts +2 -0
  169. package/src/utils/interceptor/interceptor.ts +122 -0
  170. package/src/utils/logger/logger.ts +34 -0
  171. package/src/utils/message-center/base/message-all.ts +10 -0
  172. package/src/utils/message-center/base/message-base.ts +73 -0
  173. package/src/utils/message-center/command/add-in-changed/command-add-in-changed.ts +23 -0
  174. package/src/utils/message-center/command/async-action/command-async-action.ts +23 -0
  175. package/src/utils/message-center/command/change/command-change.ts +11 -0
  176. package/src/utils/message-center/command/command-base/command-base.ts +35 -0
  177. package/src/utils/message-center/command/create/command-create.ts +25 -0
  178. package/src/utils/message-center/command/internal-message/command-internal-message.ts +26 -0
  179. package/src/utils/message-center/command/mark-open-data/command-mark-open-data.ts +23 -0
  180. package/src/utils/message-center/command/message-command.ts +162 -0
  181. package/src/utils/message-center/command/remove/command-remove.ts +25 -0
  182. package/src/utils/message-center/command/update/command-update.ts +25 -0
  183. package/src/utils/message-center/console/message-console.ts +27 -0
  184. package/src/utils/message-center/error/message-error.ts +27 -0
  185. package/src/utils/message-center/index.ts +1 -0
  186. package/src/utils/message-center/message-center.ts +77 -0
  187. package/src/utils/namespace/namespace.ts +217 -0
  188. package/src/utils/net/http-response.ts +60 -0
  189. package/src/utils/net/net.ts +463 -0
  190. package/src/utils/recursive/find-recursive-child.ts +238 -0
  191. package/src/utils/string-util/string-util.ts +76 -0
  192. package/src/utils/style/remote-style.ts +17 -0
  193. package/src/utils/sync/await-timeout.ts +29 -0
  194. package/src/utils/sync/count-latch.ts +79 -0
  195. package/src/utils/sync/index.ts +2 -0
  196. package/src/utils/types/types.ts +24 -0
  197. package/src/utils/upload/select-file.ts +93 -0
  198. package/src/utils/upload/upload-file.ts +194 -0
  199. package/src/utils/url-helper/url-helper.ts +52 -0
  200. package/src/utils/util/util.ts +580 -0
@@ -0,0 +1,84 @@
1
+ /* eslint-disable no-bitwise */
2
+ /* eslint-disable no-nested-ternary */
3
+ const r = Math.round;
4
+ /**
5
+ * @description 把颜色字符串转成RGBA数组
6
+ * @param {string} color 颜色字符串
7
+ * @returns {*} {number[]}
8
+ */
9
+ function toRGBA(color: string): number[] {
10
+ const l = color.length;
11
+ const rgba = [];
12
+ if (color.slice(0, 3).toLowerCase() === 'rgb') {
13
+ const d = color.match(/([\d|.%]{1,3})/g)!;
14
+ rgba[0] = parseInt(d[0], 10);
15
+ rgba[1] = parseInt(d[1], 10);
16
+ rgba[2] = parseInt(d[2], 10);
17
+ rgba[3] = d[3]
18
+ ? d[3].indexOf('%') !== -1
19
+ ? parseInt(d[3], 10) / 100
20
+ : parseFloat(d[3])
21
+ : 1;
22
+ } else {
23
+ let d: number;
24
+ if (l < 6)
25
+ d = parseInt(
26
+ String(color[1]) +
27
+ color[1] +
28
+ color[2] +
29
+ color[2] +
30
+ color[3] +
31
+ color[3] +
32
+ (l > 4 ? String(color[4]) + color[4] : ''),
33
+ 16,
34
+ );
35
+ else d = parseInt(color.slice(1), 16);
36
+ rgba[0] = (d >> 16) & 255;
37
+ rgba[1] = (d >> 8) & 255;
38
+ rgba[2] = d & 255;
39
+ rgba[3] =
40
+ l === 9 || l === 5 ? r((((d >> 24) & 255) / 255) * 10000) / 10000 : 1;
41
+ }
42
+ return rgba;
43
+ }
44
+
45
+ /**
46
+ * @description 混合两种颜色,颜色格式支持hex和rgb,如:#46b5d555,#fff,转化结果为rgb(245 245 245 / 80%)
47
+ * @export
48
+ * @param {string} color1 颜色1
49
+ * @param {string} color2 颜色2
50
+ * @param {number} [p=0.5] 颜色1占多少百分比,小数格式
51
+ * @param {('hex' | 'rgb')} [format='hex'] 输出的格式,hex或rgb
52
+ * @returns {*} {string}
53
+ */
54
+ export function colorBlend(
55
+ color1: string,
56
+ color2: string,
57
+ p = 0.5,
58
+ format: 'hex' | 'rgb' = 'hex',
59
+ ): string {
60
+ color1 = color1.trim();
61
+ color2 = color2.trim();
62
+ const c1 = toRGBA(color1);
63
+ const c2 = toRGBA(color2);
64
+ const result = [
65
+ r((1 - p) * c1[0] + p * c2[0]),
66
+ r((1 - p) * c1[1] + p * c2[1]),
67
+ r((1 - p) * c1[2] + p * c2[2]),
68
+ (1 - p) * c1[3] + p * c2[3],
69
+ ];
70
+ if (format === 'hex') {
71
+ const hex = [
72
+ result[0].toString(16).padStart(2, '0'),
73
+ result[1].toString(16).padStart(2, '0'),
74
+ result[2].toString(16).padStart(2, '0'),
75
+ result[3] === 0
76
+ ? '00'
77
+ : r(result[3] * 255)
78
+ .toString(16)
79
+ .padStart(2, '0'),
80
+ ];
81
+ return `#${hex[0]}${hex[1]}${hex[2]}${hex[3]}`;
82
+ }
83
+ return `rgb(${result[0]} ${result[1]} ${result[2]} / ${result[3]})`;
84
+ }
@@ -0,0 +1,192 @@
1
+ import { CoreConst } from '../../constant';
2
+
3
+ /**
4
+ * @description 获取所有的访问数据键名称
5
+ * @returns {string[]} 包含所有访问数据键名称的数组,如果出现错误则返回空数组
6
+ */
7
+ function getAccessStoreAreakeys(): string[] {
8
+ try {
9
+ const key = CoreConst.ACCESS_STORE_AREA_KEYS;
10
+ let cookieAlls;
11
+ switch (ibiz.env.accessStoreArea) {
12
+ case 'LOCALSTORAGE':
13
+ cookieAlls = localStorage.getItem(key);
14
+ break;
15
+ case 'SESSIONSTORAGE':
16
+ cookieAlls = sessionStorage.getItem(key);
17
+ break;
18
+ default:
19
+ break;
20
+ }
21
+ return JSON.parse(cookieAlls || '[]');
22
+ } catch (error) {
23
+ ibiz.log.error(error);
24
+ return [];
25
+ }
26
+ }
27
+
28
+ /**
29
+ * @description 将新的访问数据键名称添加到已有的名称列表中
30
+ * @param {string} name 要添加的访问数据键名称
31
+ */
32
+ function setAccessStoreAreakeys(name: string): void {
33
+ try {
34
+ const cookieAlls: string[] = [
35
+ ...new Set(getAccessStoreAreakeys().concat([name])),
36
+ ];
37
+ const key = CoreConst.ACCESS_STORE_AREA_KEYS;
38
+ switch (ibiz.env.accessStoreArea) {
39
+ case 'LOCALSTORAGE':
40
+ return localStorage.setItem(key, JSON.stringify(cookieAlls));
41
+ case 'SESSIONSTORAGE':
42
+ return sessionStorage.setItem(key, JSON.stringify(cookieAlls));
43
+ default:
44
+ break;
45
+ }
46
+ } catch (error) {
47
+ ibiz.log.error(error);
48
+ }
49
+ }
50
+
51
+ /**
52
+ * @description 设置cookie
53
+ * @export
54
+ * @param {string} name cookie名称
55
+ * @param {string} value cookie值
56
+ * @param {number} [day=0] 过期天数
57
+ * @param {boolean} [isDomain=false] 是否设置在主域下
58
+ * @param {string} [path='/'] 默认归属路径
59
+ * @param {string} [childDoMain=''] 子域,如果外部有传递,则需把cookie数据设置到传入子域上
60
+ */
61
+ export function setCookie(
62
+ name: string,
63
+ value: string,
64
+ day = 0,
65
+ isDomain = false,
66
+ path = '/',
67
+ childDoMain: string = '',
68
+ ): void {
69
+ let domain = '';
70
+ setAccessStoreAreakeys(name);
71
+ switch (ibiz.env.accessStoreArea) {
72
+ case 'LOCALSTORAGE':
73
+ return localStorage.setItem(name, value);
74
+ case 'SESSIONSTORAGE':
75
+ return sessionStorage.setItem(name, value);
76
+ default:
77
+ // 设置cookie到主域下
78
+ if (isDomain) {
79
+ // 是否为ip正则
80
+ const regExpr =
81
+ /^(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)$/;
82
+ // 为ip时忽略
83
+ if (!regExpr.test(window.location.hostname)) {
84
+ const host = window.location.hostname;
85
+ if (host.indexOf('.') !== host.lastIndexOf('.')) {
86
+ domain = `;domain=${host.substring(host.indexOf('.'), host.length)}`;
87
+ }
88
+ }
89
+ } else if (childDoMain) {
90
+ domain = `;domain=${childDoMain}`;
91
+ }
92
+ // 当设置的时间等于0时,不设置expires属性,cookie在浏览器关闭后删除
93
+ if (day !== 0) {
94
+ const expires = day * 24 * 60 * 60 * 1000;
95
+ const date = new Date(new Date().getTime() + expires);
96
+ document.cookie = `${name}=${escape(
97
+ value,
98
+ )};path=${path};expires=${date.toUTCString()}${domain}`;
99
+ } else {
100
+ document.cookie = `${name}=${escape(value)};path=${path}${domain}`;
101
+ }
102
+ break;
103
+ }
104
+ }
105
+
106
+ /**
107
+ * @description 设置应用cookie
108
+ * @export
109
+ * @param {string} name 名称
110
+ * @param {string} value 值
111
+ * @param {number} [day=0] 过期天数
112
+ */
113
+ export function setAppCookie(
114
+ name: string,
115
+ value: string,
116
+ day: number = 0,
117
+ ): void {
118
+ if (
119
+ ibiz.env.cookieDomain &&
120
+ window.location.href.indexOf(ibiz.env.cookieDomain) !== -1
121
+ ) {
122
+ setCookie(name, value, day, false, '/', ibiz.env.cookieDomain);
123
+ } else {
124
+ setCookie(name, value, day, true);
125
+ }
126
+ }
127
+
128
+ /**
129
+ * @description 清除应用cookie
130
+ * @export
131
+ * @param {string} cookieName
132
+ */
133
+ export function clearAppCookie(cookieName: string): void {
134
+ if (
135
+ ibiz.env.cookieDomain &&
136
+ window.location.href.indexOf(ibiz.env.cookieDomain) !== -1
137
+ ) {
138
+ setCookie(cookieName, '', -1, false, '/', ibiz.env.cookieDomain);
139
+ } else {
140
+ setCookie(cookieName, '', -1, true);
141
+ }
142
+ }
143
+ /**
144
+ * @description 获取cookie
145
+ * @export
146
+ * @param {string} name
147
+ * @returns {*} {(string | null)}
148
+ */
149
+ export function getAppCookie(name: string): string | null {
150
+ const reg = new RegExp(`(^| )${name}=([^;]*)(;|$)`);
151
+ const arr = document.cookie.match(reg);
152
+ switch (ibiz.env.accessStoreArea) {
153
+ case 'LOCALSTORAGE':
154
+ return localStorage.getItem(name);
155
+ case 'SESSIONSTORAGE':
156
+ return sessionStorage.getItem(name);
157
+ default:
158
+ if (arr && arr.length > 1) {
159
+ return unescape(arr[2]);
160
+ }
161
+ return null;
162
+ }
163
+ }
164
+
165
+ /**
166
+ * @description 重置应用cookie
167
+ * @export
168
+ */
169
+ export function resetAppCookie(): void {
170
+ const cookies = document.cookie.split(';');
171
+ const cookieAlls = getAccessStoreAreakeys().concat([
172
+ CoreConst.ACCESS_STORE_AREA_KEYS,
173
+ ]);
174
+ switch (ibiz.env.accessStoreArea) {
175
+ case 'LOCALSTORAGE':
176
+ for (const name of cookieAlls) {
177
+ localStorage.removeItem(name);
178
+ }
179
+ break;
180
+ case 'SESSIONSTORAGE':
181
+ for (const name of cookieAlls) {
182
+ sessionStorage.removeItem(name);
183
+ }
184
+ break;
185
+ default:
186
+ for (const cookie of cookies) {
187
+ const [cookieName, cookieValue] = cookie.split('=');
188
+ document.cookie = `${cookieName}=${cookieValue};expires=Thu, 01 Jan 1970 00:00:00 UTC;path=/;domain=${window.location.host}`;
189
+ }
190
+ break;
191
+ }
192
+ }
@@ -0,0 +1,93 @@
1
+ /**
2
+ * @description 数据类型转换识别工具类
3
+ * @export
4
+ * @class DataTypes
5
+ */
6
+ export class DataTypes {
7
+ /**
8
+ * @description 数字类型映射字符串类型
9
+ * @static
10
+ * @type {{ [p: number]: string }}
11
+ * @memberof DataTypes
12
+ */
13
+ static readonly typeMap: { [p: number]: string } = {
14
+ 0: 'UNKNOWN',
15
+ 1: 'BIGINT',
16
+ 2: 'BINARY',
17
+ 3: 'BIT',
18
+ 4: 'CHAR',
19
+ 5: 'DATETIME',
20
+ 6: 'DECIMAL',
21
+ 7: 'FLOAT',
22
+ 8: 'IMAGE',
23
+ 9: 'INT',
24
+ 10: 'MONEY',
25
+ 11: 'NCHAR',
26
+ 12: 'NTEXT',
27
+ 13: 'NVARCHAR',
28
+ 14: 'NUMERIC',
29
+ 15: 'REAL',
30
+ 16: 'SMALLDATETIME',
31
+ 17: 'SMALLINT',
32
+ 18: 'SMALLMONEY',
33
+ 19: 'SQL_VARIANT',
34
+ 20: 'SYSNAME',
35
+ 21: 'TEXT',
36
+ 22: 'TIMESTAMP',
37
+ 23: 'TINYINT',
38
+ 24: 'VARBINARY',
39
+ 25: 'VARCHAR',
40
+ 26: 'UNIQUEIDENTIFIER',
41
+ 27: 'DATE', // 纯日期型
42
+ 28: 'TIME', // 纯时间
43
+ 29: 'BIGDECIMAL', // 大数值
44
+ };
45
+
46
+ /**
47
+ * @description 是否是数值类型
48
+ * @static
49
+ * @param {number} dataType
50
+ * @returns {*} {boolean}
51
+ * @memberof DataTypes
52
+ */
53
+ public static isNumber(dataType: number): boolean {
54
+ const numberTypes = [
55
+ 'BIGINT',
56
+ 'BINARY',
57
+ 'DECIMAL',
58
+ 'FLOAT',
59
+ 'INT',
60
+ 'MONEY',
61
+ 'NUMERIC',
62
+ 'REAL',
63
+ 'SMALLINT',
64
+ 'SMALLMONEY',
65
+ 'TINYINT',
66
+ 'VARBINARY',
67
+ ];
68
+ return numberTypes.includes(this.toString(dataType));
69
+ }
70
+
71
+ /**
72
+ * @description 是否是日期类型数据
73
+ * @static
74
+ * @param {number} dataType
75
+ * @returns {*} {boolean}
76
+ * @memberof DataTypes
77
+ */
78
+ public static isDate(dataType: number): boolean {
79
+ const dateTypes = ['DATETIME', 'SMALLDATETIME', 'DATE', 'TIME'];
80
+ return dateTypes.includes(this.toString(dataType));
81
+ }
82
+
83
+ /**
84
+ * @description 获取字符串数据类型
85
+ * @static
86
+ * @param {number} dataType
87
+ * @returns {*} {string}
88
+ * @memberof DataTypes
89
+ */
90
+ public static toString(dataType: number): string {
91
+ return this.typeMap[dataType];
92
+ }
93
+ }
@@ -0,0 +1,110 @@
1
+ /**
2
+ * @description 根据文件名称计算Mime类型
3
+ * @export
4
+ * @param {string} fileName
5
+ * @returns {*} {string}
6
+ */
7
+ export function calcMimeByFileName(fileName: string): string {
8
+ const ext = fileName.includes('.') ? fileName.split('.').pop() : '';
9
+ let mime = '';
10
+ switch (ext) {
11
+ case 'wps':
12
+ mime = 'application/kswps';
13
+ break;
14
+ case 'doc':
15
+ mime = 'application/msword';
16
+ break;
17
+ case 'docx':
18
+ mime =
19
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
20
+ break;
21
+ case 'txt':
22
+ mime = 'text/plain';
23
+ break;
24
+ case 'zip':
25
+ mime = 'application/zip';
26
+ break;
27
+ case 'png':
28
+ mime = 'image/png';
29
+ break;
30
+ case 'gif':
31
+ mime = 'image/gif';
32
+ break;
33
+ case 'jpeg':
34
+ mime = 'image/jpeg';
35
+ break;
36
+ case 'jpg':
37
+ mime = 'image/jpeg';
38
+ break;
39
+ case 'rtf':
40
+ mime = 'application/rtf';
41
+ break;
42
+ case 'avi':
43
+ mime = 'video/x-msvideo';
44
+ break;
45
+ case 'gz':
46
+ mime = 'application/x-gzip';
47
+ break;
48
+ case 'tar':
49
+ mime = 'application/x-tar';
50
+ break;
51
+ case 'xls':
52
+ mime = 'application/vnd.ms-excel';
53
+ break;
54
+ case 'xlsx':
55
+ mime =
56
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
57
+ break;
58
+ case 'pdf':
59
+ mime = 'application/pdf';
60
+ break;
61
+ case 'html':
62
+ mime = 'text/html';
63
+ break;
64
+ default:
65
+ mime = '';
66
+ }
67
+ return mime;
68
+ }
69
+
70
+ /**
71
+ * @description 判断是否是图片格式
72
+ * @export
73
+ * @param {string} fileName
74
+ * @returns {*} {boolean}
75
+ */
76
+ export function isImage(fileName: string): boolean {
77
+ const ext = fileName.includes('.') ? fileName.split('.').pop() : '';
78
+ if (!ext) {
79
+ return false;
80
+ }
81
+ const imageTypes = ['jpeg', 'jpg', 'gif', 'png', 'bmp', 'svg'];
82
+ return imageTypes.includes(ext);
83
+ }
84
+
85
+ /**
86
+ * @description 纯JS触发下载文件
87
+ * @export
88
+ * @param {Blob} file
89
+ * @param {string} fileName
90
+ */
91
+ export function downloadFileFromBlob(file: Blob, fileName: string): void {
92
+ // 获取文件名
93
+ const filetype = calcMimeByFileName(fileName);
94
+ // 用blob对象获取文件流
95
+ const blob = new Blob([file], { type: filetype });
96
+ // 通过文件流创建下载链接
97
+ const href = URL.createObjectURL(blob);
98
+ // 创建一个a元素并设置相关属性
99
+ const a = document.createElement('a');
100
+ a.href = href;
101
+ a.download = fileName;
102
+ // 添加a元素到当前网页
103
+ document.body.appendChild(a);
104
+ // 触发a元素的点击事件,实现下载
105
+ a.click();
106
+ // 从当前网页移除a元素
107
+ document.body.removeChild(a);
108
+ // 释放blob对象
109
+ URL.revokeObjectURL(href);
110
+ }
@@ -0,0 +1,69 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+
3
+ import { NOOP } from '../../constant';
4
+
5
+ /**
6
+ * @description 计算event的composedPath返回事件路径(兼容了IE)
7
+ * @export
8
+ * @param {MouseEvent} event
9
+ * @returns {*} {((EventTarget | null)[])}
10
+ */
11
+ export function eventPath(event: MouseEvent): (EventTarget | null)[] {
12
+ const path = ((event.composedPath && event.composedPath()) ||
13
+ (event as any).path) as HTMLElement[] | undefined;
14
+
15
+ if (path != null) return path;
16
+
17
+ // 浏览器没有提供的,自己递归计算
18
+ function getParents(
19
+ node: HTMLElement,
20
+ memo: HTMLElement[] = [],
21
+ ): HTMLElement[] {
22
+ const parentNode = node.parentNode as HTMLElement | null;
23
+
24
+ return parentNode
25
+ ? getParents(parentNode, memo.concat([parentNode]))
26
+ : memo;
27
+ }
28
+
29
+ return [event.target].concat(getParents(event.target as HTMLElement));
30
+ }
31
+
32
+ /**
33
+ * @description 监听JS原生事件,返回cleanup回调,调用后删除该监听
34
+ * @export
35
+ * @param {EventTarget} target 监听对象
36
+ * @param {string} eventName 监听事件名称
37
+ * @param {(..._args: any[]) => any} listener 监听回调
38
+ * @param {AddEventListenerOptions} [options={}] 额外参数
39
+ * @returns {*} {() => void}
40
+ */
41
+ export function listenJSEvent(
42
+ target: EventTarget,
43
+ eventName: string,
44
+ listener: (..._args: any[]) => any,
45
+ options: AddEventListenerOptions = {},
46
+ ): () => void {
47
+ target.addEventListener(eventName, listener, options);
48
+
49
+ let cleanup = (): void => {
50
+ target.removeEventListener(eventName, listener, options);
51
+ // cleanup方法只能调用一次
52
+ cleanup = NOOP;
53
+ };
54
+
55
+ return () => {
56
+ cleanup();
57
+ };
58
+ }
59
+
60
+ /**
61
+ * @description event是否是在目标元素内部触发的
62
+ * @export
63
+ * @param {MouseEvent} event 原生事件
64
+ * @param {HTMLElement} el 目标元素
65
+ * @returns {*} {boolean}
66
+ */
67
+ export function isEventInside(event: MouseEvent, el: HTMLElement): boolean {
68
+ return el && (event.target === el || eventPath(event).includes(el));
69
+ }
@@ -0,0 +1,41 @@
1
+ import { RuntimeError } from '../../error';
2
+
3
+ /**
4
+ * @description 历史项
5
+ * @export
6
+ * @class HistoryItem
7
+ * @template E
8
+ */
9
+ export class HistoryItem<E> {
10
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
+ static readonly Undefined = new HistoryItem<any>(undefined);
12
+
13
+ _prev: HistoryItem<E>;
14
+
15
+ _next: HistoryItem<E>;
16
+
17
+ data: E;
18
+
19
+ constructor(data: unknown = {}) {
20
+ this.data = data as E;
21
+ this._prev = HistoryItem.Undefined;
22
+ this._next = HistoryItem.Undefined;
23
+ }
24
+
25
+ /**
26
+ * @description 克隆整个历史链
27
+ * @returns {*} {HistoryItem<E>}
28
+ * @memberof HistoryItem
29
+ */
30
+ clone(): HistoryItem<E> {
31
+ // const history = new HistoryItem<E>(clone(this.data));
32
+ // if (history._prev && history._prev !== HistoryItem.Undefined) {
33
+ // history._prev = clone(this._prev);
34
+ // }
35
+ // if (history._next && history._next !== HistoryItem.Undefined) {
36
+ // history._next = clone(this._next);
37
+ // }
38
+ // return history;
39
+ throw new RuntimeError(ibiz.i18n.t('core.utils.unrealized'));
40
+ }
41
+ }