@jiangood/springboot-admin-starter 0.0.3 → 0.0.5

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 (272) hide show
  1. package/config/dist/config.js +32 -0
  2. package/config/dist/index.js +0 -1
  3. package/config/dist/plugins/form-plugin.js +2 -2
  4. package/package.json +12 -10
  5. package/src/forms/demoForm.jsx +5 -5
  6. package/src/framework/components/DownloadFileButton.jsx +2 -2
  7. package/src/framework/components/Ellipsis.jsx +2 -2
  8. package/src/framework/components/LinkButton.d.ts +4 -4
  9. package/src/framework/components/LinkButton.jsx +6 -9
  10. package/src/framework/components/Page/index.jsx +2 -2
  11. package/src/framework/components/PageLoading.tsx +27 -0
  12. package/src/framework/components/ProTable/components/ToolBar/index.jsx +6 -7
  13. package/src/framework/components/ProTable/index.d.ts +5 -1
  14. package/src/framework/components/ProTable/index.jsx +4 -6
  15. package/src/framework/components/ProTable/index.less +0 -1
  16. package/src/framework/components/ValueType/registry.jsx +9 -20
  17. package/src/framework/components/{index.js → index.ts} +2 -10
  18. package/src/framework/components/system/ButtonList.jsx +35 -0
  19. package/src/framework/components/system/HasPerm.tsx +14 -0
  20. package/src/framework/components/system/index.tsx +29 -0
  21. package/src/framework/components/view/ViewBooleanEnableDisable.tsx +20 -0
  22. package/src/framework/components/view/ViewEllipsis.jsx +2 -2
  23. package/src/framework/components/view/ViewFile.jsx +1 -2
  24. package/src/framework/components/view/ViewImage.jsx +2 -3
  25. package/src/framework/components/view/ViewText.tsx +16 -0
  26. package/src/framework/components/view/{index.js → index.ts} +0 -2
  27. package/src/framework/field-components/FieldBoolean.d.ts +13 -0
  28. package/src/framework/field-components/FieldBoolean.jsx +76 -0
  29. package/src/framework/field-components/FieldDate.d.ts +25 -0
  30. package/src/framework/field-components/FieldDate.jsx +109 -0
  31. package/src/framework/field-components/FieldDateRange.d.ts +6 -0
  32. package/src/framework/field-components/FieldDateRange.jsx +101 -0
  33. package/src/framework/field-components/FieldDictSelect.d.ts +13 -0
  34. package/src/framework/field-components/FieldDictSelect.jsx +16 -0
  35. package/src/framework/field-components/FieldEditor.d.ts +10 -0
  36. package/src/framework/field-components/FieldEditor.jsx +58 -0
  37. package/src/framework/field-components/FieldPercent.d.ts +12 -0
  38. package/src/framework/field-components/FieldPercent.jsx +27 -0
  39. package/src/framework/field-components/FieldRemoteSelect.d.ts +13 -0
  40. package/src/framework/field-components/FieldRemoteSelect.jsx +87 -0
  41. package/src/framework/field-components/FieldRemoteSelectMultiple.d.ts +13 -0
  42. package/src/framework/field-components/FieldRemoteSelectMultiple.jsx +86 -0
  43. package/src/framework/field-components/FieldRemoteSelectMultipleInline.d.ts +20 -0
  44. package/src/framework/field-components/FieldRemoteSelectMultipleInline.jsx +86 -0
  45. package/src/framework/field-components/FieldRemoteTree.d.ts +21 -0
  46. package/src/framework/field-components/FieldRemoteTree.jsx +45 -0
  47. package/src/framework/field-components/FieldRemoteTreeCascader.d.ts +23 -0
  48. package/src/framework/field-components/FieldRemoteTreeCascader.jsx +61 -0
  49. package/src/framework/field-components/FieldRemoteTreeSelect.d.ts +17 -0
  50. package/src/framework/field-components/FieldRemoteTreeSelect.jsx +67 -0
  51. package/src/framework/field-components/FieldRemoteTreeSelectMultiple.d.ts +17 -0
  52. package/src/framework/field-components/FieldRemoteTreeSelectMultiple.jsx +68 -0
  53. package/src/framework/field-components/FieldSysOrgTree.d.ts +12 -0
  54. package/src/framework/field-components/FieldSysOrgTree.jsx +23 -0
  55. package/src/framework/field-components/FieldSysOrgTreeSelect.d.ts +12 -0
  56. package/src/framework/field-components/FieldSysOrgTreeSelect.jsx +23 -0
  57. package/src/framework/field-components/FieldTable.d.ts +17 -0
  58. package/src/framework/field-components/FieldTable.jsx +108 -0
  59. package/src/framework/{components/field/select/FieldTableSelect/index.d.ts → field-components/FieldTableSelect.d.ts} +4 -14
  60. package/src/framework/field-components/FieldTableSelect.jsx +59 -0
  61. package/src/framework/{components/field/upload → field-components}/FieldUploadFile.d.ts +0 -1
  62. package/src/framework/{components/field/upload → field-components}/FieldUploadFile.jsx +5 -9
  63. package/src/framework/field-components/index.ts +20 -0
  64. package/src/framework/{components/OrgTree.jsx → field-components/system/OrgTree.tsx} +8 -7
  65. package/src/framework/{components/RoleTree.jsx → field-components/system/RoleTree.tsx} +3 -3
  66. package/src/framework/field-components/system/index.ts +2 -0
  67. package/src/framework/index.ts +5 -0
  68. package/src/framework/pages/LoginPage.d.ts +11 -0
  69. package/src/framework/pages/LoginPage.jsx +136 -0
  70. package/src/{pages/login.less → framework/pages/LoginPage.less} +1 -1
  71. package/src/framework/pages/index.ts +1 -0
  72. package/src/framework/utils/ArrUtils.ts +229 -0
  73. package/src/framework/utils/ColorsUtils.ts +378 -0
  74. package/src/framework/utils/{date.js → DateUtils.ts} +69 -69
  75. package/src/framework/utils/DeviceUtils.ts +46 -0
  76. package/src/framework/utils/DomUtils.ts +50 -0
  77. package/src/framework/utils/EventBusUtils.ts +143 -0
  78. package/src/framework/utils/MessageUtils.tsx +182 -0
  79. package/src/framework/utils/ObjectUtils.ts +113 -0
  80. package/src/framework/utils/StorageUtils.ts +67 -0
  81. package/src/framework/utils/StringUtils.ts +410 -0
  82. package/src/framework/utils/TreeUtils.ts +248 -0
  83. package/src/framework/utils/UrlUtils.ts +152 -0
  84. package/src/framework/utils/UuidUtils.ts +88 -0
  85. package/src/framework/utils/ValidateUtils.ts +28 -0
  86. package/src/framework/utils/index.ts +16 -0
  87. package/src/framework/utils/system/DictUtils.ts +97 -0
  88. package/src/framework/utils/system/FormRegistryUtils.ts +77 -0
  89. package/src/framework/utils/system/HttpUtils.ts +246 -0
  90. package/src/framework/utils/system/PageUtils.ts +153 -0
  91. package/src/framework/utils/system/PermUtils.ts +79 -0
  92. package/src/framework/utils/system/SysUtils.ts +97 -0
  93. package/src/framework/utils/system/ThemeUtils.ts +27 -0
  94. package/src/framework/utils/system/index.ts +7 -0
  95. package/src/framework/view-components/ViewBoolean.jsx +4 -0
  96. package/src/framework/view-components/index.js +3 -0
  97. package/src/layouts/PageRender.jsx +2 -2
  98. package/src/layouts/admin/HeaderRight.jsx +9 -9
  99. package/src/layouts/admin/TabPageRender.jsx +2 -2
  100. package/src/layouts/admin/index.jsx +27 -40
  101. package/src/layouts/admin/index.less +2 -1
  102. package/src/layouts/index.jsx +30 -38
  103. package/src/layouts/index.less +0 -21
  104. package/src/loading.jsx +2 -2
  105. package/src/{components → pages/flowable}/InstanceInfo.jsx +5 -4
  106. package/src/pages/flowable/design/customTranslate/customTranslate.js +16 -0
  107. package/src/pages/flowable/design/customTranslate/translations-properties-panel.js +10 -0
  108. package/src/pages/flowable/design/customTranslate/translations.js +144 -0
  109. package/src/pages/flowable/design/descriptors/flowable.json +1109 -0
  110. package/src/pages/flowable/design/index.jsx +61 -234
  111. package/src/pages/flowable/design/provider/FlowablePropertiesProvider.js +75 -0
  112. package/src/pages/flowable/design/provider/index.js +6 -0
  113. package/src/pages/flowable/design/provider/properties/ConditionDesign.jsx +175 -0
  114. package/src/pages/flowable/design/provider/properties/ConditionProps.jsx +76 -0
  115. package/src/pages/flowable/design/provider/properties/DelegateExpressionProps.js +54 -0
  116. package/src/pages/flowable/design/provider/properties/FormProps.js +55 -0
  117. package/src/pages/flowable/design/provider/properties/MultiInstanceProps.js +100 -0
  118. package/src/pages/flowable/design/provider/properties/UserTaskForm.jsx +48 -0
  119. package/src/pages/flowable/design/provider/properties/utils.jsx +35 -0
  120. package/src/pages/flowable/index.jsx +28 -69
  121. package/src/pages/flowable/monitor/definition.jsx +87 -0
  122. package/src/pages/flowable/monitor/instance/index.jsx +177 -0
  123. package/src/pages/flowable/monitor/instance/view.jsx +102 -0
  124. package/src/pages/flowable/monitor/task.jsx +93 -0
  125. package/src/pages/flowable/task/form.jsx +5 -5
  126. package/src/pages/flowable/task/index.jsx +5 -5
  127. package/src/pages/flowable/test/index.jsx +13 -10
  128. package/src/pages/index.jsx +8 -13
  129. package/src/pages/login.jsx +4 -129
  130. package/src/pages/{api/doc.jsx → system/api/ApiDoc.jsx} +56 -47
  131. package/src/pages/system/api/index.jsx +268 -0
  132. package/src/pages/system/api/perm.jsx +69 -0
  133. package/src/pages/system/config/index.jsx +3 -3
  134. package/src/pages/system/dict/Dict.jsx +2 -3
  135. package/src/pages/system/dict/DictItem.jsx +5 -5
  136. package/src/pages/system/file/index.jsx +13 -5
  137. package/src/pages/{job → system/job}/index.jsx +124 -39
  138. package/src/pages/system/log/index.jsx +3 -3
  139. package/src/pages/system/org/index.jsx +11 -12
  140. package/src/pages/system/role/index.jsx +11 -11
  141. package/src/pages/system/role/perm.jsx +8 -8
  142. package/src/pages/system/sysManual/index.jsx +6 -6
  143. package/src/pages/system/user/UserPerm.jsx +7 -42
  144. package/src/pages/system/user/index.jsx +13 -17
  145. package/src/pages/test.jsx +188 -3
  146. package/src/pages/ureport/index.jsx +4 -4
  147. package/src/pages/userCenter/ChangePassword.jsx +3 -4
  148. package/src/pages/userCenter/index.jsx +2 -2
  149. package/src/pages/userCenter/manual.jsx +3 -7
  150. package/src/pages/userCenter/message.jsx +5 -5
  151. package/config/dist/config.local.js +0 -23
  152. package/src/components/InstanceStatusInfo.jsx +0 -79
  153. package/src/components/StreamLog.jsx +0 -27
  154. package/src/components/flow/BpmnUtils.js +0 -85
  155. package/src/components/flow/customTranslate/customTranslate.js +0 -19
  156. package/src/components/flow/customTranslate/translations.js +0 -79
  157. package/src/components/flow/design/form/ConditionForm.jsx +0 -316
  158. package/src/components/flow/design/form/ServiceTaskForm.jsx +0 -55
  159. package/src/components/flow/design/form/TimerEventDefinitionForm.jsx +0 -62
  160. package/src/components/flow/design/form/UserTaskForm.jsx +0 -211
  161. package/src/components/flow/design/palette.js +0 -39
  162. package/src/components/monitor/AllDefinition.jsx +0 -46
  163. package/src/components/monitor/AllInstance.jsx +0 -76
  164. package/src/forms/driverForm.jsx +0 -18
  165. package/src/framework/components/ButtonList.jsx +0 -91
  166. package/src/framework/components/Echarts/index.d.ts +0 -10
  167. package/src/framework/components/Echarts/index.jsx +0 -49
  168. package/src/framework/components/EditTable/index.d.ts +0 -11
  169. package/src/framework/components/EditTable/index.jsx +0 -85
  170. package/src/framework/components/FieldRemoteTree.jsx +0 -20
  171. package/src/framework/components/HasPerm.jsx +0 -18
  172. package/src/framework/components/ImageView.d.ts +0 -12
  173. package/src/framework/components/ImageView.jsx +0 -64
  174. package/src/framework/components/MsgBox.jsx +0 -180
  175. package/src/framework/components/PageLoading.jsx +0 -31
  176. package/src/framework/components/Panel/index.d.ts +0 -11
  177. package/src/framework/components/Panel/index.jsx +0 -24
  178. package/src/framework/components/Panel/index.less +0 -0
  179. package/src/framework/components/field/FieldAutoTime/index.tsx +0 -46
  180. package/src/framework/components/field/FieldBoolean/index.tsx +0 -92
  181. package/src/framework/components/field/FieldEditTable/index.d.ts +0 -13
  182. package/src/framework/components/field/FieldEditTable/index.jsx +0 -103
  183. package/src/framework/components/field/FieldEditTable/index.less +0 -29
  184. package/src/framework/components/field/FieldEditor.jsx +0 -48
  185. package/src/framework/components/field/FieldFileBase64/index.d.ts +0 -15
  186. package/src/framework/components/field/FieldFileBase64/index.jsx +0 -23
  187. package/src/framework/components/field/FieldImageBase64/index.d.ts +0 -15
  188. package/src/framework/components/field/FieldImageBase64/index.jsx +0 -22
  189. package/src/framework/components/field/FieldInput.jsx +0 -13
  190. package/src/framework/components/field/FieldOrgTree/index.tsx +0 -45
  191. package/src/framework/components/field/FieldPassword.jsx +0 -11
  192. package/src/framework/components/field/FieldProps.ts +0 -19
  193. package/src/framework/components/field/FieldRemoteTreeCascader.jsx +0 -75
  194. package/src/framework/components/field/FieldRemoteTreeCheckable.jsx +0 -81
  195. package/src/framework/components/field/FieldRemoteTreeMultipleSelect.jsx +0 -100
  196. package/src/framework/components/field/FieldRemoteTreeSelect.jsx +0 -82
  197. package/src/framework/components/field/FieldSelectPosition/index.tsx +0 -85
  198. package/src/framework/components/field/FieldTree.jsx +0 -45
  199. package/src/framework/components/field/dict/index.tsx +0 -110
  200. package/src/framework/components/field/flat-multiple-select/index.d.ts +0 -4
  201. package/src/framework/components/field/flat-multiple-select/index.jsx +0 -116
  202. package/src/framework/components/field/flat-multiple-select/index.less +0 -12
  203. package/src/framework/components/field/flat-select/index.d.ts +0 -4
  204. package/src/framework/components/field/flat-select/index.jsx +0 -107
  205. package/src/framework/components/field/flat-select/index.less +0 -12
  206. package/src/framework/components/field/index.js +0 -33
  207. package/src/framework/components/field/input-number-percent/index.d.ts +0 -11
  208. package/src/framework/components/field/input-number-percent/index.jsx +0 -28
  209. package/src/framework/components/field/select/FieldSelect/index.d.ts +0 -39
  210. package/src/framework/components/field/select/FieldSelect/index.jsx +0 -156
  211. package/src/framework/components/field/select/FieldTableSelect/index.jsx +0 -155
  212. package/src/framework/components/field/select/index.jsx +0 -2
  213. package/src/framework/components/field/switch-y-n/index.d.ts +0 -11
  214. package/src/framework/components/field/switch-y-n/index.jsx +0 -31
  215. package/src/framework/components/field/text/index.tsx +0 -7
  216. package/src/framework/components/field/time/DatePickerString.tsx +0 -37
  217. package/src/framework/components/field/time/DateTimePickerString.tsx +0 -42
  218. package/src/framework/components/field/time/FieldDateRange.d.ts +0 -9
  219. package/src/framework/components/field/time/FieldDateRange.jsx +0 -49
  220. package/src/framework/components/field/time/HHmmPickerString.tsx +0 -42
  221. package/src/framework/components/field/time/MonthPickerString.tsx +0 -45
  222. package/src/framework/components/field/time/TimePickerTool.ts +0 -14
  223. package/src/framework/components/field/time/YearPickerString.tsx +0 -41
  224. package/src/framework/components/field/time/YearQuarterString.tsx +0 -38
  225. package/src/framework/components/field/time/index.tsx +0 -7
  226. package/src/framework/components/field/upload/FieldUploadCropImage/index.d.ts +0 -22
  227. package/src/framework/components/field/upload/FieldUploadCropImage/index.jsx +0 -11
  228. package/src/framework/components/field/upload/FieldUploadImage.d.ts +0 -7
  229. package/src/framework/components/field/upload/FieldUploadImage.jsx +0 -16
  230. package/src/framework/components/field/upload/index.jsx +0 -3
  231. package/src/framework/components/system.jsx +0 -29
  232. package/src/framework/components/view/ViewBoolean.jsx +0 -15
  233. package/src/framework/components/view/ViewBooleanEnableDisable.jsx +0 -16
  234. package/src/framework/components/view/ViewText.jsx +0 -9
  235. package/src/framework/index.js +0 -3
  236. package/src/framework/system/dict.js +0 -88
  237. package/src/framework/system/formRegistry.js +0 -58
  238. package/src/framework/system/http.jsx +0 -290
  239. package/src/framework/system/index.js +0 -13
  240. package/src/framework/system/page.js +0 -109
  241. package/src/framework/system/permission.js +0 -44
  242. package/src/framework/system/sys.js +0 -60
  243. package/src/framework/system/theme.js +0 -17
  244. package/src/framework/utils/arr.js +0 -118
  245. package/src/framework/utils/browser.js +0 -24
  246. package/src/framework/utils/color.js +0 -269
  247. package/src/framework/utils/debounce.js +0 -33
  248. package/src/framework/utils/dom.js +0 -16
  249. package/src/framework/utils/eventBus.js +0 -70
  250. package/src/framework/utils/html.js +0 -13
  251. package/src/framework/utils/index.js +0 -17
  252. package/src/framework/utils/obj.js +0 -72
  253. package/src/framework/utils/storage.js +0 -37
  254. package/src/framework/utils/str.js +0 -297
  255. package/src/framework/utils/tree.js +0 -175
  256. package/src/framework/utils/uid.js +0 -76
  257. package/src/framework/utils/url.js +0 -84
  258. package/src/framework/utils/validate.js +0 -9
  259. package/src/pages/api/accessLog/index.jsx +0 -108
  260. package/src/pages/api/accountResource/index.jsx +0 -149
  261. package/src/pages/api/index.jsx +0 -163
  262. package/src/pages/api/resource.jsx +0 -18
  263. package/src/pages/flowable/instance/view.jsx +0 -13
  264. package/src/pages/flowable/monitor.jsx +0 -106
  265. package/src/pages/flowable/test/form.jsx +0 -31
  266. package/src/pages/job/logList.jsx +0 -100
  267. package/src/pages/job/status.jsx +0 -84
  268. /package/src/framework/components/{ButtonList.d.ts → system/ButtonList.d.ts} +0 -0
  269. /package/src/framework/{components/EditTable/index.less → field-components/FieldTable.less} +0 -0
  270. /package/src/framework/{components/view → view-components}/ViewPassword.jsx +0 -0
  271. /package/src/{index.js → index.ts} +0 -0
  272. /package/src/{components/flow → pages/flowable}/design/contextPad.js +0 -0
@@ -0,0 +1,143 @@
1
+ /**
2
+ * 事件总线工具类 (Static Utility Class 模式) - 所有方法和状态均为静态
3
+ * forked form https://github.com/scottcorgan/tiny-emitter
4
+ */
5
+
6
+ // --- 内部类型定义 ---
7
+
8
+ /** 定义事件回调的结构 */
9
+ interface StaticEventEntry<T extends any[]> {
10
+ fn: (...args: T) => void;
11
+ ctx?: any;
12
+ }
13
+
14
+ /** 定义用于 once 的特殊回调,用于在 off 时查找原始回调 */
15
+ type StaticOnceCallback<T extends any[]> = ((...args: T) => void) & {
16
+ __callback?: ((...args: T) => void);
17
+ };
18
+
19
+ /** 定义事件映射的类型 */
20
+ interface StaticEventStack {
21
+ [key: string]: StaticEventEntry<any[]>[];
22
+ }
23
+
24
+ /**
25
+ * 静态事件总线工具类
26
+ * 所有方法和状态均通过静态属性直接访问。
27
+ */
28
+ export class EventBusUtils {
29
+ // 静态内部状态
30
+ private static __stack: StaticEventStack = {};
31
+
32
+ /**
33
+ * 静态工具类,无需实例化,因此构造函数私有化防止意外创建实例。
34
+ */
35
+ private constructor() {
36
+ // 静态工具类,无须实现
37
+ }
38
+
39
+ /**
40
+ * 注册事件监听器
41
+ * @param name 事件名称
42
+ * @param callback 事件回调函数
43
+ * @param ctx 回调函数的 this 上下文
44
+ */
45
+ public static on<T extends any[] = []>(
46
+ name: string,
47
+ callback: (...args: T) => void,
48
+ ctx?: any
49
+ ): void { // 静态方法通常不返回 this
50
+ if (!EventBusUtils.__stack[name]) {
51
+ EventBusUtils.__stack[name] = [];
52
+ }
53
+
54
+ (EventBusUtils.__stack[name] as StaticEventEntry<T>[]).push({
55
+ fn: callback as (...args: any[]) => void,
56
+ ctx
57
+ });
58
+ }
59
+
60
+ /**
61
+ * 注册只触发一次的事件监听器
62
+ * @param name 事件名称
63
+ * @param callback 事件回调函数
64
+ * @param ctx 回调函数的 this 上下文
65
+ */
66
+ public static once<T extends any[] = []>(
67
+ name: string,
68
+ callback: (...args: T) => void,
69
+ ctx?: any
70
+ ): void {
71
+ const listener: StaticOnceCallback<T> = (...args) => {
72
+ // 触发后立即移除
73
+ EventBusUtils.off(name, listener as unknown as ((...args: T) => void));
74
+ callback.apply(ctx, args);
75
+ };
76
+
77
+ // 存储原始回调,方便 off 时查找
78
+ listener.__callback = callback;
79
+
80
+ return EventBusUtils.on(name, listener, ctx);
81
+ }
82
+
83
+ /**
84
+ * 触发事件
85
+ * @param name 事件名称
86
+ * @param args 传递给回调函数的参数
87
+ */
88
+ public static emit<T extends any[] = []>(
89
+ name: string,
90
+ ...args: T
91
+ ): void {
92
+ const list = EventBusUtils.__stack[name] as StaticEventEntry<T>[];
93
+
94
+ if (list !== undefined) {
95
+ // 使用 slice(0) 确保在回调中 off 不会影响当前循环
96
+ list.slice(0).forEach(entry => {
97
+ entry.fn.apply(entry.ctx, args);
98
+ });
99
+ }
100
+ }
101
+
102
+ /**
103
+ * 移除事件监听器
104
+ * @param name 事件名称
105
+ * @param callback 可选:要移除的特定回调函数。如果省略,则移除该事件名的所有监听器。
106
+ */
107
+ public static off<T extends any[] = []>(
108
+ name: string,
109
+ callback?: ((...args: T) => void)
110
+ ): void {
111
+ const list = EventBusUtils.__stack[name];
112
+
113
+ if (list === undefined) {
114
+ return;
115
+ }
116
+
117
+ // 移除所有监听器
118
+ if (callback === undefined) {
119
+ delete EventBusUtils.__stack[name];
120
+ return;
121
+ }
122
+
123
+ // 移除特定监听器
124
+ const liveEvents = list.filter(
125
+ entry =>
126
+ // 排除当前回调
127
+ entry.fn !== callback &&
128
+ // 排除 once 包装的回调,通过 __callback 匹配原始回调
129
+ (entry.fn as StaticOnceCallback<T>).__callback !== callback
130
+ );
131
+
132
+ if (liveEvents.length !== 0) {
133
+ EventBusUtils.__stack[name] = liveEvents;
134
+ } else {
135
+ delete EventBusUtils.__stack[name];
136
+ }
137
+ }
138
+ }
139
+
140
+ /* 推荐的使用方式:直接通过类名调用静态方法 */
141
+ // import { EventBusUtils } from './EventBusUtils';
142
+ // EventBusUtils.on('myStaticEvent', (data) => console.log(data));
143
+ // EventBusUtils.emit('myStaticEvent', { status: 'ok' });
@@ -0,0 +1,182 @@
1
+ import {Input, message, Modal, notification} from 'antd';
2
+ import type {ModalFuncProps} from 'antd/es/modal/interface';
3
+ import type {ArgsProps, NotificationPlacement} from 'antd/es/notification/interface';
4
+ import React from 'react';
5
+ import {ThemeUtils} from './system/ThemeUtils';
6
+
7
+
8
+ let color = ThemeUtils.getColor('primary-color');
9
+ const buttonStyles = {
10
+ root: {
11
+ backgroundColor: color
12
+ }
13
+ }
14
+
15
+ /**
16
+ * 消息工具类 (MsgUtils)
17
+ * 封装了 Ant Design 的 Modal, message, 和 notification 静态方法
18
+ */
19
+ export class MessageUtils {
20
+ // --- Antd Modal 封装 (Alert/Confirm/Prompt) ---
21
+
22
+ /**
23
+ * 弹出 Alert 提示框
24
+ */
25
+ static alert(content: React.ReactNode, config?: Omit<ModalFuncProps, 'content' | 'icon' | 'onOk' | 'onCancel'>) {
26
+ Modal.info({
27
+ title: '提示',
28
+ content,
29
+ okText: '确定',
30
+ icon: null,
31
+ okButtonProps: {
32
+ styles: buttonStyles
33
+ },
34
+ ...config,
35
+ });
36
+ }
37
+
38
+ /**
39
+ * 弹出 Confirm 确认框
40
+ */
41
+ static confirm(content: React.ReactNode, config?: Omit<ModalFuncProps, 'content' | 'icon' | 'onOk' | 'onCancel'>) {
42
+ return new Promise((resolve) => {
43
+ Modal.confirm({
44
+ title: '确认操作',
45
+ content,
46
+ okText: '确定',
47
+ cancelText: '取消',
48
+ onOk: () => resolve(true),
49
+ onCancel: () => resolve(false),
50
+ okButtonProps: {
51
+ styles: buttonStyles
52
+ },
53
+ ...config,
54
+ });
55
+ })
56
+
57
+ }
58
+
59
+ /**
60
+ * 弹出 Prompt 输入框对话框
61
+ */
62
+ static prompt(message: React.ReactNode, initialValue?: string, placeholder?: string, config?: Omit<ModalFuncProps, 'content' | 'title' | 'icon' | 'onOk'>) {
63
+ return new Promise((resolve) => {
64
+ const ref = React.createRef()
65
+ Modal.confirm({
66
+ icon: null,
67
+ title: '提示',
68
+ content: <div>
69
+ <div style={{marginBottom: 4}}>{message}</div>
70
+ <Input ref={ref} placeholder={placeholder}/>
71
+ </div>,
72
+ okText: '确定',
73
+ cancelText: '取消',
74
+ onOk: () => {
75
+ const inputInstance = ref.current;
76
+ const inputElement = inputInstance.input;
77
+ const inputValue = inputElement.value;
78
+ resolve(inputValue)
79
+ },
80
+ onCancel: () => {
81
+ resolve()
82
+ },
83
+ okButtonProps: {
84
+ styles: buttonStyles
85
+ },
86
+ ...config,
87
+ });
88
+ })
89
+ }
90
+
91
+ // --- Antd message 封装 (全局通知/Loading) ---
92
+
93
+ /**
94
+ * 成功消息
95
+ */
96
+ static success(content: React.ReactNode, duration: number = 3) {
97
+ message.success(content, duration);
98
+ }
99
+
100
+ /**
101
+ * 错误消息
102
+ */
103
+ static error(content: React.ReactNode, duration: number = 3) {
104
+ message.error(content, duration);
105
+ }
106
+
107
+ /**
108
+ * 警告消息
109
+ */
110
+ static warning(content: React.ReactNode, duration: number = 3) {
111
+ message.warning(content, duration);
112
+ }
113
+
114
+ /**
115
+ * 通用消息
116
+ */
117
+ static info(content: React.ReactNode, duration: number = 3) {
118
+ message.info(content, duration);
119
+ }
120
+
121
+ /**
122
+ * 弹出 Loading 提示
123
+ */
124
+ static loading(content: React.ReactNode = '正在加载...', duration?: number) {
125
+ return message.loading({content, duration: duration === undefined ? 0 : duration});
126
+ }
127
+
128
+ /**
129
+ * 立即关闭所有 message 提示
130
+ */
131
+ static hideAll() {
132
+ message.destroy();
133
+ }
134
+
135
+ // --- Antd Notification 封装 (通知提醒框) ---
136
+
137
+ /**
138
+ * 弹出右上角通知提醒框
139
+ */
140
+ static notify(
141
+ message: React.ReactNode,
142
+ description: React.ReactNode,
143
+ type: 'success' | 'error' | 'info' | 'warning' | 'open' | 'config' = 'open',
144
+ placement: NotificationPlacement = 'topRight',
145
+ config?: Omit<ArgsProps, 'message' | 'description' | 'placement'>,
146
+ ) {
147
+ const notifyFunc = notification[type];
148
+ notifyFunc({
149
+ message,
150
+ description,
151
+ placement,
152
+ ...config,
153
+ });
154
+ }
155
+
156
+ /**
157
+ * 弹出成功通知
158
+ */
159
+ static notifySuccess(message: React.ReactNode, description: React.ReactNode, placement?: NotificationPlacement, config?: Omit<ArgsProps, 'message' | 'description' | 'placement'>) {
160
+ MessageUtils.notify(message, description, 'success', placement, config);
161
+ }
162
+
163
+ /**
164
+ * 弹出失败通知
165
+ */
166
+ static notifyError(message: React.ReactNode, description: React.ReactNode, placement?: NotificationPlacement, config?: Omit<ArgsProps, 'message' | 'description' | 'placement'>) {
167
+ MessageUtils.notify(message, description, 'error', placement, config);
168
+ }
169
+
170
+ /**
171
+ * 弹出警告通知
172
+ */
173
+ static notifyWarning(
174
+ message: React.ReactNode,
175
+ description: React.ReactNode,
176
+ placement?: NotificationPlacement,
177
+ config?: Omit<ArgsProps, 'message' | 'description' | 'placement'>,
178
+ ) {
179
+ MessageUtils.notify(message, description, 'warning', placement, config);
180
+ }
181
+ }
182
+
@@ -0,0 +1,113 @@
1
+ /**
2
+ * ObjectUtils 提供了对对象进行操作的静态方法,例如安全地获取嵌套属性和复制属性。
3
+ */
4
+ export class ObjectUtils {
5
+
6
+ /**
7
+ * 🎯 安全地获取深度嵌套的对象属性的值。
8
+ * 如果属性链中的任何一级为 undefined 或 null,getDefinition 函数会返回一个默认值,而不是抛出错误。
9
+ *
10
+ * @template TObj 目标对象的类型。
11
+ * @template TDefault 默认值的类型。
12
+ * @param obj 要查找属性的对象。
13
+ * @param path 属性路径,可以是点分隔的字符串(如 'a.b.c')或字符串数组(如 ['a', '0', 'b', 'c'])。
14
+ * @param defaultValue 如果属性不存在或路径中有 null/undefined 值时返回的默认值。
15
+ * @returns 属性的值,如果找不到则返回 defaultValue。
16
+ *
17
+ * @example
18
+ * const obj = { 'a': [{ 'b': { 'c': 3 } }] };
19
+ * const value = ObjectUtils.getDefinition(obj, 'a[0].b.c', 0); // 3
20
+ * const missing = ObjectUtils.getDefinition(obj, 'a[1].d', 'default'); // 'default'
21
+ */
22
+ static get<TObj extends object, TDefault = unknown>(
23
+ obj: TObj | null | undefined,
24
+ path: string | (keyof TObj)[],
25
+ defaultValue: TDefault | undefined = undefined
26
+ ): unknown | TDefault {
27
+
28
+ // 路径处理:将 'a[0].b.c' 转换为 ['a', '0', 'b', 'c'] 以支持数组索引
29
+ // 注意:这里简化处理,只处理点分隔符,如果需要完整的 lodash getDefinition 行为,需要更复杂的正则解析。
30
+ const pathArray: string[] = Array.isArray(path)
31
+ ? path.map(String) // 确保路径段都是字符串
32
+ : path.split('.');
33
+
34
+ let result: any = obj;
35
+
36
+ // 遍历路径
37
+ for (const segment of pathArray) {
38
+ // 如果当前结果是 null 或 undefined,则后续路径无法访问,返回默认值
39
+ if (result == null) {
40
+ return defaultValue;
41
+ }
42
+
43
+ // 尝试访问属性
44
+ // 使用 segment 作为索引,TypeScript 默认这里是合法的
45
+ result = result[segment];
46
+ }
47
+
48
+ // 如果最终结果是 null 或 undefined,则返回默认值;否则返回结果
49
+ return result !== null && result !== undefined ? result : defaultValue;
50
+ }
51
+
52
+
53
+ /**
54
+ * 📋 复制对象属性,仅复制源对象 (source) 中 **存在** 且目标对象 (target) 中 **也有** 对应属性的那些值。
55
+ * 主要用于根据目标对象的结构来过滤和填充数据。
56
+ *
57
+ * @param source 源对象。
58
+ * @param target 目标对象。
59
+ * @returns void
60
+ */
61
+ static copyPropertyIfPresent<TSource extends object, TTarget extends object>(
62
+ source: TSource | null | undefined,
63
+ target: TTarget | null | undefined
64
+ ): void {
65
+ if (!source || !target || typeof source !== 'object' || typeof target !== 'object') {
66
+ return;
67
+ }
68
+
69
+ // 遍历目标对象的键,确保我们只复制目标对象上已有的属性
70
+ const keys = Object.keys(target) as (keyof TTarget)[];
71
+
72
+ for (const key of keys) {
73
+ // 检查源对象是否有这个属性
74
+ if (Object.hasOwn(source, key)) {
75
+ // 因为目标对象和源对象都被约束为 object,所以这里的类型转换是相对安全的
76
+ const value = (source as any)[key];
77
+ (target as any)[key] = value;
78
+ }
79
+ }
80
+ }
81
+
82
+
83
+ /**
84
+ * 📝 复制对象属性,将源对象 (source) 中 **非 undefined** 的属性值复制到目标对象 (target) 对应的属性上。
85
+ * 仅复制目标对象 (target) 中 **已有** 的属性,如果源对象中的值是 undefined 则不复制。
86
+ *
87
+ * @param source 源对象。
88
+ * @param target 目标对象。
89
+ * @returns void
90
+ */
91
+ static copyProperty<TSource extends object, TTarget extends object>(
92
+ source: TSource | null | undefined,
93
+ target: TTarget | null | undefined
94
+ ): void {
95
+ if (!source || !target || typeof source !== 'object' || typeof target !== 'object') {
96
+ return;
97
+ }
98
+
99
+ // 遍历目标对象的键
100
+ const keys = Object.keys(target) as (keyof TTarget)[];
101
+
102
+ for (const key of keys) {
103
+ // 尝试从源对象获取值
104
+ const value = (source as any)[key];
105
+
106
+ // 只有当值明确不是 undefined 时才复制(即允许复制 null 或其他 falsy 值)
107
+ if (value !== undefined) {
108
+ (target as any)[key] = value;
109
+ }
110
+ }
111
+ }
112
+
113
+ }
@@ -0,0 +1,67 @@
1
+ import { DateUtils } from "./DateUtils";
2
+
3
+ /**
4
+ * 存储工具类
5
+ * 使用 localStorage 进行数据的存取,并包含时间戳和默认值处理。
6
+ */
7
+ export class StorageUtils {
8
+
9
+ /**
10
+ * 从 localStorage 获取数据。
11
+ * @param key 存储的键。
12
+ * @param defaultValue 如果找不到键或值,返回的默认值 (默认为 null)。
13
+ * @returns 存储的值或默认值。
14
+ */
15
+ static get<T>(key: string, defaultValue: T | null = null): T | null {
16
+ // 尝试从 localStorage 获取原始字符串
17
+ const vStr = localStorage.getItem(key);
18
+
19
+ // 如果没有存储项
20
+ if (vStr == null) {
21
+ return defaultValue;
22
+ }
23
+
24
+ try {
25
+ // 解析存储的项
26
+ const item: { createTime: number; data: T } = JSON.parse(vStr);
27
+
28
+ // 返回实际存储的数据
29
+ return item.data;
30
+
31
+ } catch (error) {
32
+ // 如果 JSON 解析失败 (例如,存储的值不是一个包含 createTime 和 data 的有效 JSON 结构)
33
+ console.error(`Error parsing storage item for key: ${key}`, error);
34
+ return defaultValue;
35
+ }
36
+ }
37
+
38
+ /**
39
+ * 将数据存储到 localStorage。
40
+ * 如果值为 null 或 undefined,则删除该键。
41
+ * @param key 存储的键。
42
+ * @param value 要存储的值。
43
+ */
44
+ static set<T>(key: string, value: T | null | undefined): void {
45
+ // 如果值为 null 或 undefined,则删除该键
46
+ if (value == null) {
47
+ localStorage.removeItem(key);
48
+ return;
49
+ }
50
+
51
+ // 构造包含时间戳的对象
52
+ const item = {
53
+ createTime: DateUtils.now(), // 假设 DateUtil.now() 返回 number 类型的时间戳
54
+ data: value
55
+ };
56
+
57
+ try {
58
+ // 序列化对象
59
+ const dataStr = JSON.stringify(item);
60
+ // 存储到 localStorage
61
+ localStorage.setItem(key, dataStr);
62
+ } catch (error) {
63
+ // 捕获 JSON.stringify 错误 (例如,如果 value 包含循环引用)
64
+ console.error(`Error stringifying storage value for key: ${key}`, error);
65
+ }
66
+ }
67
+ }