@ibiz-template/core 0.7.41-alpha.14 → 0.7.41-alpha.140

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 (201) hide show
  1. package/dist/index.esm.js +118 -39
  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/net/http-response.d.ts +2 -1
  53. package/out/utils/net/http-response.d.ts.map +1 -1
  54. package/out/utils/net/http-response.js +5 -1
  55. package/out/utils/net/net.d.ts +1 -1
  56. package/out/utils/net/net.d.ts.map +1 -1
  57. package/out/utils/net/net.js +16 -6
  58. package/out/utils/recursive/find-recursive-child.d.ts +20 -0
  59. package/out/utils/recursive/find-recursive-child.d.ts.map +1 -1
  60. package/out/utils/recursive/find-recursive-child.js +69 -7
  61. package/out/utils/string-util/string-util.d.ts.map +1 -1
  62. package/out/utils/string-util/string-util.js +2 -4
  63. package/out/utils/upload/select-file.d.ts.map +1 -1
  64. package/out/utils/upload/select-file.js +31 -15
  65. package/package.json +5 -4
  66. package/src/command/command-register.ts +121 -0
  67. package/src/command/command.ts +78 -0
  68. package/src/command/index.ts +8 -0
  69. package/src/command/utils/index.ts +2 -0
  70. package/src/command/utils/linked-list.ts +136 -0
  71. package/src/command/utils/util.ts +103 -0
  72. package/src/constant/core/core.ts +54 -0
  73. package/src/constant/emoji/emoji.ts +2929 -0
  74. package/src/constant/http-status-message/http-status-message.ts +18 -0
  75. package/src/constant/index.ts +4 -0
  76. package/src/constant/util/util.ts +3 -0
  77. package/src/context/index.ts +231 -0
  78. package/src/environment/environment.ts +67 -0
  79. package/src/error/http-error/entity-error.ts +29 -0
  80. package/src/error/http-error/http-error-factory.ts +33 -0
  81. package/src/error/http-error/http-error.ts +52 -0
  82. package/src/error/index.ts +7 -0
  83. package/src/error/model-error/model-error.ts +27 -0
  84. package/src/error/notice-error/notice-error.ts +16 -0
  85. package/src/error/runtime-error/runtime-error.ts +13 -0
  86. package/src/error/runtime-model-error/runtime-model-error.ts +27 -0
  87. package/src/ibizsys.ts +82 -0
  88. package/src/index.ts +14 -0
  89. package/src/install.ts +12 -0
  90. package/src/interface/api/chat-message/i-api-chat-message.ts +71 -0
  91. package/src/interface/api/chat-message/index.ts +1 -0
  92. package/src/interface/api/constant/index.ts +2 -0
  93. package/src/interface/api/constant/login-mode/login-mode.ts +25 -0
  94. package/src/interface/api/constant/menu-permission-mode/menu-permission-mode.ts +20 -0
  95. package/src/interface/api/environment/i-devtool-config.ts +76 -0
  96. package/src/interface/api/environment/i-environment.ts +532 -0
  97. package/src/interface/api/environment/index.ts +2 -0
  98. package/src/interface/api/global-param/i-api-context.ts +37 -0
  99. package/src/interface/api/global-param/i-global-param.ts +27 -0
  100. package/src/interface/api/global-param/index.ts +2 -0
  101. package/src/interface/api/ibizsys/i-api-ibizsys.ts +54 -0
  102. package/src/interface/api/ibizsys/i-app-data.ts +64 -0
  103. package/src/interface/api/ibizsys/i-org-data.ts +31 -0
  104. package/src/interface/api/ibizsys/index.ts +3 -0
  105. package/src/interface/api/index.ts +6 -0
  106. package/src/interface/api/utils/i-api-i18n.ts +56 -0
  107. package/src/interface/api/utils/index.ts +5 -0
  108. package/src/interface/api/utils/message-center/base/i-message-all.ts +8 -0
  109. package/src/interface/api/utils/message-center/base/i-message-base.ts +29 -0
  110. package/src/interface/api/utils/message-center/base/index.ts +2 -0
  111. package/src/interface/api/utils/message-center/command/add-in-changed/i-add-in-changed.ts +25 -0
  112. package/src/interface/api/utils/message-center/command/add-in-changed/i-command-add-in-changed.ts +16 -0
  113. package/src/interface/api/utils/message-center/command/async-action/i-command-async-action.ts +17 -0
  114. package/src/interface/api/utils/message-center/command/change/i-command-change.ts +8 -0
  115. package/src/interface/api/utils/message-center/command/create/i-command-create.ts +18 -0
  116. package/src/interface/api/utils/message-center/command/i-command-base.ts +23 -0
  117. package/src/interface/api/utils/message-center/command/i-message-command.ts +94 -0
  118. package/src/interface/api/utils/message-center/command/index.ts +20 -0
  119. package/src/interface/api/utils/message-center/command/internal-message/i-command-internal-message.ts +17 -0
  120. package/src/interface/api/utils/message-center/command/internal-message/i-internal-message.ts +132 -0
  121. package/src/interface/api/utils/message-center/command/mark-open-data/i-command-mark-open-data.ts +17 -0
  122. package/src/interface/api/utils/message-center/command/mark-open-data/i-mark-open-data.ts +47 -0
  123. package/src/interface/api/utils/message-center/command/remove/i-command-remove.ts +18 -0
  124. package/src/interface/api/utils/message-center/command/update/i-command-update.ts +18 -0
  125. package/src/interface/api/utils/message-center/common/i-app-data-entity.ts +16 -0
  126. package/src/interface/api/utils/message-center/common/i-message-center-event.ts +15 -0
  127. package/src/interface/api/utils/message-center/common/i-msg-meta-data.ts +13 -0
  128. package/src/interface/api/utils/message-center/common/i-portal-async-action.ts +144 -0
  129. package/src/interface/api/utils/message-center/common/i-portal-message.ts +84 -0
  130. package/src/interface/api/utils/message-center/common/index.ts +5 -0
  131. package/src/interface/api/utils/message-center/console/i-message-console.ts +17 -0
  132. package/src/interface/api/utils/message-center/error/i-message-error.ts +17 -0
  133. package/src/interface/api/utils/message-center/i-message-center.ts +53 -0
  134. package/src/interface/api/utils/message-center/index.ts +6 -0
  135. package/src/interface/api/utils/net/i-api-http-error.ts +43 -0
  136. package/src/interface/api/utils/net/i-api-net.ts +93 -0
  137. package/src/interface/api/utils/net/i-http-response.ts +67 -0
  138. package/src/interface/click-outside/click-outside.ts +51 -0
  139. package/src/interface/command/command/i-command-option.ts +47 -0
  140. package/src/interface/command/command/i-command.ts +68 -0
  141. package/src/interface/command/disposable/i-disposable.ts +12 -0
  142. package/src/interface/command/i-command-controller.ts +50 -0
  143. package/src/interface/command/index.ts +11 -0
  144. package/src/interface/context/index.ts +42 -0
  145. package/src/interface/error/index.ts +13 -0
  146. package/src/interface/i-chat-message/i-chat-message.ts +16 -0
  147. package/src/interface/ibizsys/i-ibizsys.ts +33 -0
  148. package/src/interface/ibizsys/index.ts +1 -0
  149. package/src/interface/index.ts +11 -0
  150. package/src/interface/utils/i-18n.ts +22 -0
  151. package/src/interface/utils/index.ts +1 -0
  152. package/src/locale/en/index.ts +30 -0
  153. package/src/locale/index.ts +2 -0
  154. package/src/locale/zh-CN/index.ts +28 -0
  155. package/src/params/params.ts +131 -0
  156. package/src/types.ts +26 -0
  157. package/src/utils/bit-mask/bit-mask.ts +87 -0
  158. package/src/utils/click-outside/click-outside.ts +108 -0
  159. package/src/utils/clone/clone.ts +38 -0
  160. package/src/utils/color/color.ts +84 -0
  161. package/src/utils/cookie-util/cookie-util.ts +192 -0
  162. package/src/utils/data-type/data-types.ts +93 -0
  163. package/src/utils/download-file/download-file.ts +110 -0
  164. package/src/utils/event/event.ts +69 -0
  165. package/src/utils/history-list/history-item.ts +41 -0
  166. package/src/utils/history-list/history-list.ts +137 -0
  167. package/src/utils/index.ts +24 -0
  168. package/src/utils/interceptor/core-interceptor.ts +127 -0
  169. package/src/utils/interceptor/index.ts +2 -0
  170. package/src/utils/interceptor/interceptor.ts +122 -0
  171. package/src/utils/logger/logger.ts +34 -0
  172. package/src/utils/message-center/base/message-all.ts +10 -0
  173. package/src/utils/message-center/base/message-base.ts +73 -0
  174. package/src/utils/message-center/command/add-in-changed/command-add-in-changed.ts +23 -0
  175. package/src/utils/message-center/command/async-action/command-async-action.ts +23 -0
  176. package/src/utils/message-center/command/change/command-change.ts +11 -0
  177. package/src/utils/message-center/command/command-base/command-base.ts +35 -0
  178. package/src/utils/message-center/command/create/command-create.ts +25 -0
  179. package/src/utils/message-center/command/internal-message/command-internal-message.ts +26 -0
  180. package/src/utils/message-center/command/mark-open-data/command-mark-open-data.ts +23 -0
  181. package/src/utils/message-center/command/message-command.ts +162 -0
  182. package/src/utils/message-center/command/remove/command-remove.ts +25 -0
  183. package/src/utils/message-center/command/update/command-update.ts +25 -0
  184. package/src/utils/message-center/console/message-console.ts +27 -0
  185. package/src/utils/message-center/error/message-error.ts +27 -0
  186. package/src/utils/message-center/index.ts +1 -0
  187. package/src/utils/message-center/message-center.ts +77 -0
  188. package/src/utils/namespace/namespace.ts +217 -0
  189. package/src/utils/net/http-response.ts +60 -0
  190. package/src/utils/net/net.ts +463 -0
  191. package/src/utils/recursive/find-recursive-child.ts +238 -0
  192. package/src/utils/string-util/string-util.ts +76 -0
  193. package/src/utils/style/remote-style.ts +17 -0
  194. package/src/utils/sync/await-timeout.ts +29 -0
  195. package/src/utils/sync/count-latch.ts +79 -0
  196. package/src/utils/sync/index.ts +2 -0
  197. package/src/utils/types/types.ts +24 -0
  198. package/src/utils/upload/select-file.ts +105 -0
  199. package/src/utils/upload/upload-file.ts +194 -0
  200. package/src/utils/url-helper/url-helper.ts +52 -0
  201. package/src/utils/util/util.ts +580 -0
@@ -0,0 +1,23 @@
1
+ import { ICommandMarkOpenData, IMarkOpenData } from '../../../../interface';
2
+ import { CommandBase } from '../command-base/command-base';
3
+
4
+ /**
5
+ * @description 协同指令消息控制器
6
+ * @export
7
+ * @class CommandMarkOpenData
8
+ * @extends {CommandBase}
9
+ * @implements {ICommandMarkOpenData}
10
+ */
11
+ export class CommandMarkOpenData
12
+ extends CommandBase
13
+ implements ICommandMarkOpenData
14
+ {
15
+ /**
16
+ * @description 发送消息
17
+ * @param {IMarkOpenData} data
18
+ * @memberof CommandMarkOpenData
19
+ */
20
+ send(data: IMarkOpenData): void {
21
+ this.sendCommand(data, 'MARKOPENDATA');
22
+ }
23
+ }
@@ -0,0 +1,162 @@
1
+ import { createUUID } from 'qx-util';
2
+ import { IMessageCommand, IPortalMessage } from '../../../interface';
3
+ import { MessageBase } from '../base/message-base';
4
+ import { CommandCreate } from './create/command-create';
5
+ import { CommandUpdate } from './update/command-update';
6
+ import { CommandRemove } from './remove/command-remove';
7
+ import { CommandChange } from './change/command-change';
8
+ import { CommandAsyncAction } from './async-action/command-async-action';
9
+ import { CommandInternalMessage } from './internal-message/command-internal-message';
10
+ import { CommandMarkOpenData } from './mark-open-data/command-mark-open-data';
11
+ import { CommandAddInChanged } from './add-in-changed/command-add-in-changed';
12
+
13
+ /**
14
+ * @description 指令消息控制器
15
+ * @export
16
+ * @class MessageCommand
17
+ * @extends {MessageBase}
18
+ * @implements {IMessageCommand}
19
+ */
20
+ export class MessageCommand extends MessageBase implements IMessageCommand {
21
+ /**
22
+ * @description 数据变更指令消息控制器
23
+ * @type {CommandChange}
24
+ * @memberof MessageCommand
25
+ */
26
+ readonly change: CommandChange = new CommandChange();
27
+
28
+ /**
29
+ * @description 新建数据指令消息控制器
30
+ * @type {CommandCreate}
31
+ * @memberof MessageCommand
32
+ */
33
+ readonly create: CommandCreate = new CommandCreate(this);
34
+
35
+ /**
36
+ * @description 更新数据指令消息控制器
37
+ * @type {CommandUpdate}
38
+ * @memberof MessageCommand
39
+ */
40
+ readonly update: CommandUpdate = new CommandUpdate(this);
41
+
42
+ /**
43
+ * @description 删除数据指令消息控制器
44
+ * @type {CommandRemove}
45
+ * @memberof MessageCommand
46
+ */
47
+ readonly remove: CommandRemove = new CommandRemove(this);
48
+
49
+ /**
50
+ * @description 异步指令消息控制器
51
+ * @type {CommandAsyncAction}
52
+ * @memberof MessageCommand
53
+ */
54
+ readonly asyncAction: CommandAsyncAction = new CommandAsyncAction(this);
55
+
56
+ /**
57
+ * @description 站内信消息指令消息控制器
58
+ * @type {CommandInternalMessage}
59
+ * @memberof MessageCommand
60
+ */
61
+ readonly internalMessage: CommandInternalMessage = new CommandInternalMessage(
62
+ this,
63
+ );
64
+
65
+ /**
66
+ * @description 协同指令消息控制器
67
+ * @type {CommandMarkOpenData}
68
+ * @memberof MessageCommand
69
+ */
70
+ readonly markOpenData: CommandMarkOpenData = new CommandMarkOpenData(this);
71
+
72
+ /**
73
+ * @description 添加变更指令消息控制器
74
+ * @type {CommandAddInChanged}
75
+ * @memberof MessageCommand
76
+ */
77
+ readonly addInChanged: CommandAddInChanged = new CommandAddInChanged(this);
78
+
79
+ /**
80
+ * @description 推送指令消息
81
+ * @param {IPortalMessage} msg
82
+ * @memberof MessageCommand
83
+ */
84
+ next(msg: IPortalMessage): void {
85
+ // 消息分子类型,子类型发完消息后,会让父发消息
86
+ // 所以子类型有父时,会一级一级的往上发消息。不需要在此处发全局消息
87
+ // change 特殊处理,不给父发消息
88
+ switch (msg.subtype) {
89
+ case 'OBJECTCREATED':
90
+ this.create.next(msg);
91
+ this.change.next(msg);
92
+ break;
93
+ case 'OBJECTUPDATED':
94
+ this.update.next(msg);
95
+ this.change.next(msg);
96
+ break;
97
+ case 'OBJECTREMOVED':
98
+ this.remove.next(msg);
99
+ this.change.next(msg);
100
+ break;
101
+ case 'ASYNCACTION':
102
+ this.asyncAction.next(msg);
103
+ break;
104
+ case 'INTERNALMESSAGE':
105
+ this.internalMessage.next(msg);
106
+ break;
107
+ case 'MARKOPENDATA':
108
+ this.markOpenData.next(msg);
109
+ break;
110
+ case 'ADDINCHANGED':
111
+ this.addInChanged.next(msg);
112
+ break;
113
+ default:
114
+ super.next(msg);
115
+ }
116
+ }
117
+
118
+ /**
119
+ * @description 发送消息给父级
120
+ * @protected
121
+ * @param {IPortalMessage} msg
122
+ * @memberof MessageCommand
123
+ */
124
+ protected nextParent(msg: IPortalMessage): void {
125
+ switch (msg.subtype) {
126
+ case 'OBJECTCREATED':
127
+ this.change.next(msg);
128
+ break;
129
+ case 'OBJECTUPDATED':
130
+ this.change.next(msg);
131
+ break;
132
+ case 'OBJECTREMOVED':
133
+ this.change.next(msg);
134
+ break;
135
+ default:
136
+ }
137
+ super.nextParent(msg);
138
+ }
139
+
140
+ /**
141
+ * @description 发送指令消息
142
+ * @param {IData} data
143
+ * @param {IPortalMessage['subtype']} subtype
144
+ * @param {string} [triggerKey]
145
+ * @memberof MessageCommand
146
+ */
147
+ send(
148
+ data: IData,
149
+ subtype: IPortalMessage['subtype'],
150
+ triggerKey?: string,
151
+ ): void {
152
+ const msg: IPortalMessage = {
153
+ messageid: createUUID(),
154
+ messagename: 'command',
155
+ type: 'COMMAND',
156
+ subtype,
157
+ triggerKey,
158
+ data,
159
+ };
160
+ this.next(msg);
161
+ }
162
+ }
@@ -0,0 +1,25 @@
1
+ import {
2
+ IAppDataEntity,
3
+ ICommandRemove,
4
+ IMsgMetaData,
5
+ } from '../../../../interface';
6
+ import { CommandBase } from '../command-base/command-base';
7
+
8
+ /**
9
+ * @description 删除指令消息控制器
10
+ * @export
11
+ * @class CommandRemove
12
+ * @extends {CommandBase}
13
+ * @implements {ICommandRemove}
14
+ */
15
+ export class CommandRemove extends CommandBase implements ICommandRemove {
16
+ /**
17
+ * @description 发送消息
18
+ * @param {IAppDataEntity} data 实体数据
19
+ * @param {IMsgMetaData} [meta] 元数据
20
+ * @memberof CommandRemove
21
+ */
22
+ send(data: IAppDataEntity, meta?: IMsgMetaData): void {
23
+ this.sendCommand(data, 'OBJECTREMOVED', meta?.triggerKey);
24
+ }
25
+ }
@@ -0,0 +1,25 @@
1
+ import {
2
+ IAppDataEntity,
3
+ ICommandUpdate,
4
+ IMsgMetaData,
5
+ } from '../../../../interface';
6
+ import { CommandBase } from '../command-base/command-base';
7
+
8
+ /**
9
+ * @description 更新指令消息控制器
10
+ * @export
11
+ * @class CommandUpdate
12
+ * @extends {CommandBase}
13
+ * @implements {ICommandUpdate}
14
+ */
15
+ export class CommandUpdate extends CommandBase implements ICommandUpdate {
16
+ /**
17
+ * @description 发送消息
18
+ * @param {IAppDataEntity} data 实体数据
19
+ * @param {IMsgMetaData} [meta] 元数据
20
+ * @memberof CommandUpdate
21
+ */
22
+ send(data: IAppDataEntity, meta?: IMsgMetaData): void {
23
+ this.sendCommand(data, 'OBJECTUPDATED', meta?.triggerKey);
24
+ }
25
+ }
@@ -0,0 +1,27 @@
1
+ import { createUUID } from 'qx-util';
2
+ import { IMessageConsole, IPortalMessage } from '../../../interface';
3
+ import { MessageBase } from '../base/message-base';
4
+
5
+ /**
6
+ * @description 日志消息控制器
7
+ * @export
8
+ * @class MessageConsole
9
+ * @extends {MessageBase}
10
+ * @implements {IMessageConsole}
11
+ */
12
+ export class MessageConsole extends MessageBase implements IMessageConsole {
13
+ /**
14
+ * @description 发送消息
15
+ * @param {(IData | string)} data
16
+ * @memberof MessageConsole
17
+ */
18
+ send(data: IData | string): void {
19
+ const msg: IPortalMessage = {
20
+ messageid: createUUID(),
21
+ messagename: 'console',
22
+ type: 'CONSOLE',
23
+ data,
24
+ };
25
+ this.next(msg);
26
+ }
27
+ }
@@ -0,0 +1,27 @@
1
+ import { createUUID } from 'qx-util';
2
+ import { IMessageError, IPortalMessage } from '../../../interface';
3
+ import { MessageBase } from '../base/message-base';
4
+
5
+ /**
6
+ * @description 错误消息控制器
7
+ * @export
8
+ * @class MessageError
9
+ * @extends {MessageBase}
10
+ * @implements {IMessageError}
11
+ */
12
+ export class MessageError extends MessageBase implements IMessageError {
13
+ /**
14
+ * @description 发送消息
15
+ * @param {(IData | string)} data
16
+ * @memberof MessageError
17
+ */
18
+ send(data: IData | string): void {
19
+ const msg: IPortalMessage = {
20
+ messageid: createUUID(),
21
+ messagename: 'error',
22
+ type: 'ERROR',
23
+ data,
24
+ };
25
+ this.next(msg);
26
+ }
27
+ }
@@ -0,0 +1 @@
1
+ export { MessageCenter } from './message-center';
@@ -0,0 +1,77 @@
1
+ import { IMessageCenter, IPortalMessage } from '../../interface';
2
+ import { MessageAll } from './base/message-all';
3
+ import { MessageCommand } from './command/message-command';
4
+ import { MessageConsole } from './console/message-console';
5
+ import { MessageError } from './error/message-error';
6
+
7
+ /**
8
+ * @description 界面消息中心
9
+ * @export
10
+ * @class MessageCenter
11
+ * @implements {IMessageCenter}
12
+ */
13
+ export class MessageCenter implements IMessageCenter {
14
+ /**
15
+ * @description 所有消息
16
+ * @protected
17
+ * @type {MessageAll}
18
+ * @memberof MessageCenter
19
+ */
20
+ protected all: MessageAll = new MessageAll();
21
+
22
+ /**
23
+ * @description 指令消息
24
+ * @type {MessageCommand}
25
+ * @memberof MessageCenter
26
+ */
27
+ readonly command: MessageCommand = new MessageCommand(this.all);
28
+
29
+ /**
30
+ * @description 日志消息
31
+ * @type {MessageConsole}
32
+ * @memberof MessageCenter
33
+ */
34
+ readonly console: MessageConsole = new MessageConsole(this.all);
35
+
36
+ /**
37
+ * @description 错误消息
38
+ * @type {MessageError}
39
+ * @memberof MessageCenter
40
+ */
41
+ readonly error: MessageError = new MessageError(this.all);
42
+
43
+ /**
44
+ * @description 发送消息
45
+ * @param {IPortalMessage} msg 消息
46
+ * @memberof MessageCenter
47
+ */
48
+ next(msg: IPortalMessage): void {
49
+ // 消息分子类型,子类型发完消息后,会让父发消息
50
+ // 所以子类型有父时,会一级一级的往上发消息。不需要在此处发全局消息
51
+ if (msg.type === 'COMMAND') {
52
+ this.command.next(msg);
53
+ } else if (msg.type === 'CONSOLE') {
54
+ this.console.next(msg);
55
+ } else {
56
+ this.all.next(msg);
57
+ }
58
+ }
59
+
60
+ /**
61
+ * @description 订阅消息
62
+ * @param {(msg: IPortalMessage) => void} callback
63
+ * @memberof MessageCenter
64
+ */
65
+ on(callback: (msg: IPortalMessage) => void): void {
66
+ this.all.on(callback);
67
+ }
68
+
69
+ /**
70
+ * @description 取消订阅
71
+ * @param {(msg: IPortalMessage) => void} callback
72
+ * @memberof MessageCenter
73
+ */
74
+ off(callback: (msg: IPortalMessage) => void): void {
75
+ this.all.off(callback);
76
+ }
77
+ }
@@ -0,0 +1,217 @@
1
+ export const defaultNamespace = 'ibiz';
2
+ const statePrefix = 'is-';
3
+
4
+ /**
5
+ * @description 拼接css bem命名
6
+ * @param {string} namespace 命名空间
7
+ * @param {string} block 块
8
+ * @param {string} [blockSuffix] 块后缀
9
+ * @param {string} [element] 元素
10
+ * @param {string} [modifier] 修饰符
11
+ * @example
12
+ * ```typescript
13
+ * _bem('ibiz', 'layout') => ibiz-layout
14
+ * _bem('ibiz', 'layout', '', 'title') => ibiz-layout__title
15
+ * _bem('ibiz', 'layout', '', '', 'right') => ibiz-layout--right
16
+ * _bem('ibiz', 'layout', '', 'title', 'right') => ibiz-layout__title--right
17
+ * _bem('ibiz', 'layout', 'header', 'title', 'right') => ibiz-layout-header__title--right
18
+ * ```
19
+ * @returns {*} {string}
20
+ */
21
+ function _bem(
22
+ namespace: string,
23
+ block: string,
24
+ blockSuffix?: string,
25
+ element?: string,
26
+ modifier?: string,
27
+ ): string {
28
+ let cls = `${namespace}-${block}`;
29
+ if (blockSuffix) {
30
+ cls += `-${blockSuffix}`;
31
+ }
32
+ if (element) {
33
+ cls += `__${element}`;
34
+ }
35
+ if (modifier) {
36
+ cls += `--${modifier}`;
37
+ }
38
+ return cls;
39
+ }
40
+
41
+ /**
42
+ * @description 全局样式处理命名空间
43
+ * @export
44
+ * @class Namespace
45
+ */
46
+ export class Namespace {
47
+ /**
48
+ * @description 命名空间
49
+ * @type {string}
50
+ * @memberof Namespace
51
+ */
52
+ namespace: string;
53
+
54
+ /**
55
+ * Creates an instance of Namespace.
56
+ * @param {string} block 当前命名空间的根模块,例如组件的名称
57
+ * @param {string} [namespace] 指定命名空间,未指定使用默认值 ibiz
58
+ * @memberof Namespace
59
+ */
60
+ constructor(
61
+ protected block: string,
62
+ namespace?: string,
63
+ ) {
64
+ this.namespace = namespace || defaultNamespace;
65
+ }
66
+
67
+ /**
68
+ * @description namespace-block、namespace-block-blockSuffix
69
+ * @param {string} [blockSuffix='']
70
+ * @returns {*} {string}
71
+ * @memberof Namespace
72
+ */
73
+ b(blockSuffix: string = ''): string {
74
+ return _bem(this.namespace, this.block, blockSuffix, '', '');
75
+ }
76
+
77
+ /**
78
+ * @description namespace-block__element
79
+ * @param {string} [element]
80
+ * @returns {*} {string}
81
+ * @memberof Namespace
82
+ */
83
+ e(element?: string): string {
84
+ return element ? _bem(this.namespace, this.block, '', element, '') : '';
85
+ }
86
+
87
+ /**
88
+ * @description namespace-block--modifier
89
+ * @param {string} [modifier]
90
+ * @returns {*} {string}
91
+ * @memberof Namespace
92
+ */
93
+ m(modifier?: string): string {
94
+ return modifier ? _bem(this.namespace, this.block, '', '', modifier) : '';
95
+ }
96
+
97
+ /**
98
+ * @description namespace-block-blockSuffix__element
99
+ * @param {string} [blockSuffix]
100
+ * @param {string} [element]
101
+ * @returns {*} {string}
102
+ * @memberof Namespace
103
+ */
104
+ be(blockSuffix?: string, element?: string): string {
105
+ return blockSuffix && element
106
+ ? _bem(this.namespace, this.block, blockSuffix, element, '')
107
+ : '';
108
+ }
109
+
110
+ /**
111
+ * @description namespace-block__element--modifier
112
+ * @param {string} [element]
113
+ * @param {string} [modifier]
114
+ * @returns {*} {string}
115
+ * @memberof Namespace
116
+ */
117
+ em(element?: string, modifier?: string): string {
118
+ return element && modifier
119
+ ? _bem(this.namespace, this.block, '', element, modifier)
120
+ : '';
121
+ }
122
+
123
+ /**
124
+ * @description namespace-block-blockSuffix--modifier
125
+ * @param {string} [blockSuffix]
126
+ * @param {string} [modifier]
127
+ * @returns {*} {string}
128
+ * @memberof Namespace
129
+ */
130
+ bm(blockSuffix?: string, modifier?: string): string {
131
+ return blockSuffix && modifier
132
+ ? _bem(this.namespace, this.block, blockSuffix, '', modifier)
133
+ : '';
134
+ }
135
+
136
+ /**
137
+ * @description namespace-block-blockSuffix__element--modifier
138
+ * @param {string} [blockSuffix]
139
+ * @param {string} [element]
140
+ * @param {string} [modifier]
141
+ * @returns {*} {string}
142
+ * @memberof Namespace
143
+ */
144
+ bem(blockSuffix?: string, element?: string, modifier?: string): string {
145
+ return blockSuffix && element && modifier
146
+ ? _bem(this.namespace, this.block, blockSuffix, element, modifier)
147
+ : '';
148
+ }
149
+
150
+ /**
151
+ * @description 返回状态类
152
+ * @param {string} name
153
+ * @param {boolean} [state]
154
+ * @example
155
+ * ```typescript
156
+ * is('loading', false) => '';
157
+ * is('loading', true) => 'is-loading';
158
+ * ```
159
+ * @returns {*} {string}
160
+ * @memberof Namespace
161
+ */
162
+ is(name: string, state?: boolean): string {
163
+ return name && state ? `${statePrefix}${name}` : '';
164
+ }
165
+
166
+ /**
167
+ * @description 生成使用到的 css 变量 style 对象
168
+ * @param {Record<string, string>} object
169
+ * @returns {*} {Record<string, string>}
170
+ * @memberof Namespace
171
+ */
172
+ cssVar(object: Record<string, string>): Record<string, string> {
173
+ const styles: Record<string, string> = {};
174
+ for (const key in object) {
175
+ if (object[key]) {
176
+ styles[this.cssVarName(key)] = object[key];
177
+ }
178
+ }
179
+ return styles;
180
+ }
181
+
182
+ /**
183
+ * @description 生成使用到的 css block 变量 style 对象
184
+ * @param {Record<string, string>} object
185
+ * @returns {*} {Record<string, string>}
186
+ * @memberof Namespace
187
+ */
188
+ cssVarBlock(object: Record<string, string>): Record<string, string> {
189
+ const styles: Record<string, string> = {};
190
+ for (const key in object) {
191
+ if (object[key]) {
192
+ styles[this.cssVarBlockName(key)] = object[key];
193
+ }
194
+ }
195
+ return styles;
196
+ }
197
+
198
+ /**
199
+ * @description 生成 css var 变量名称
200
+ * @param {string} name
201
+ * @returns {*} {string}
202
+ * @memberof Namespace
203
+ */
204
+ cssVarName(name: string): string {
205
+ return `--${this.namespace}-${name}`;
206
+ }
207
+
208
+ /**
209
+ * @description 生成块 css var 变量名称
210
+ * @param {string} name
211
+ * @returns {*} {string}
212
+ * @memberof Namespace
213
+ */
214
+ cssVarBlockName(name: string): string {
215
+ return `--${this.namespace}-${this.block}-${name}`;
216
+ }
217
+ }
@@ -0,0 +1,60 @@
1
+ import axios, {
2
+ AxiosResponseHeaders,
3
+ InternalAxiosRequestConfig,
4
+ RawAxiosResponseHeaders,
5
+ } from 'axios';
6
+ import { IHttpResponse } from '../../interface';
7
+
8
+ /**
9
+ * @description 本地请求仿造响应
10
+ * @export
11
+ * @class HttpResponse
12
+ * @implements {IHttpResponse<T>}
13
+ * @template T
14
+ */
15
+ export class HttpResponse<T = IData> implements IHttpResponse<T> {
16
+ /**
17
+ * @description 本地仿造响应
18
+ * @memberof HttpResponse
19
+ */
20
+ local = true;
21
+
22
+ ok = false;
23
+
24
+ data: T;
25
+
26
+ status: number;
27
+
28
+ statusText: string;
29
+
30
+ headers: RawAxiosResponseHeaders | AxiosResponseHeaders = {};
31
+
32
+ config: InternalAxiosRequestConfig<IData> = {
33
+ headers: new axios.AxiosHeaders(),
34
+ };
35
+
36
+ /**
37
+ * Creates an instance of HttpResponse.
38
+ * @param {unknown} [data] 返回的数据
39
+ * @param {number} [status] 状态码 (默认为 200)
40
+ * @param {string} [statusText] 状态描述 (默认为空字符)
41
+ * @param {RawAxiosResponseHeaders | AxiosResponseHeaders} [headers] 响应头
42
+ * @memberof HttpResponse
43
+ */
44
+ constructor(
45
+ data?: unknown,
46
+ status?: number,
47
+ statusText?: string,
48
+ headers?: RawAxiosResponseHeaders | AxiosResponseHeaders,
49
+ ) {
50
+ this.data = data as T;
51
+ this.status = status || 200;
52
+ this.statusText = statusText || '';
53
+ if (this.status >= 200 && this.status < 300) {
54
+ this.ok = true;
55
+ }
56
+ if (headers) {
57
+ this.headers = headers;
58
+ }
59
+ }
60
+ }