@jiangood/springboot-admin-starter 0.0.2 → 0.0.4

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 (266) 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/{components/field/FieldEditTable/index.d.ts → field-components/FieldTable.d.ts} +5 -2
  58. package/src/framework/{components/field/FieldEditTable/index.jsx → field-components/FieldTable.jsx} +29 -21
  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 +4 -0
  68. package/src/framework/utils/ArrUtils.ts +229 -0
  69. package/src/framework/utils/ColorsUtils.ts +378 -0
  70. package/src/framework/utils/{date.js → DateUtils.ts} +69 -69
  71. package/src/framework/utils/DeviceUtils.ts +46 -0
  72. package/src/framework/utils/DomUtils.ts +50 -0
  73. package/src/framework/utils/EventBusUtils.ts +143 -0
  74. package/src/framework/utils/MessageUtils.tsx +182 -0
  75. package/src/framework/utils/ObjectUtils.ts +113 -0
  76. package/src/framework/utils/StorageUtils.ts +67 -0
  77. package/src/framework/utils/StringUtils.ts +410 -0
  78. package/src/framework/utils/TreeUtils.ts +248 -0
  79. package/src/framework/utils/UrlUtils.ts +152 -0
  80. package/src/framework/utils/UuidUtils.ts +88 -0
  81. package/src/framework/utils/ValidateUtils.ts +28 -0
  82. package/src/framework/utils/index.ts +16 -0
  83. package/src/framework/utils/system/DictUtils.ts +97 -0
  84. package/src/framework/utils/system/FormRegistryUtils.ts +77 -0
  85. package/src/framework/utils/system/HttpUtils.ts +246 -0
  86. package/src/framework/utils/system/PageUtils.ts +153 -0
  87. package/src/framework/utils/system/PermUtils.ts +79 -0
  88. package/src/framework/utils/system/SysUtils.ts +97 -0
  89. package/src/framework/utils/system/ThemeUtils.ts +27 -0
  90. package/src/framework/utils/system/index.ts +7 -0
  91. package/src/framework/view-components/ViewBoolean.jsx +4 -0
  92. package/src/framework/view-components/index.js +3 -0
  93. package/src/layouts/PageRender.jsx +2 -2
  94. package/src/layouts/admin/HeaderRight.jsx +9 -9
  95. package/src/layouts/admin/TabPageRender.jsx +2 -2
  96. package/src/layouts/admin/index.jsx +27 -40
  97. package/src/layouts/admin/index.less +2 -1
  98. package/src/layouts/index.jsx +30 -38
  99. package/src/layouts/index.less +0 -21
  100. package/src/loading.jsx +2 -2
  101. package/src/{components → pages/flowable}/InstanceInfo.jsx +5 -4
  102. package/src/pages/flowable/design/customTranslate/customTranslate.js +16 -0
  103. package/src/pages/flowable/design/customTranslate/translations-properties-panel.js +10 -0
  104. package/src/pages/flowable/design/customTranslate/translations.js +144 -0
  105. package/src/pages/flowable/design/descriptors/flowable.json +1109 -0
  106. package/src/pages/flowable/design/index.jsx +61 -234
  107. package/src/pages/flowable/design/provider/FlowablePropertiesProvider.js +75 -0
  108. package/src/pages/flowable/design/provider/index.js +6 -0
  109. package/src/pages/flowable/design/provider/properties/ConditionDesign.jsx +175 -0
  110. package/src/pages/flowable/design/provider/properties/ConditionProps.jsx +76 -0
  111. package/src/pages/flowable/design/provider/properties/DelegateExpressionProps.js +54 -0
  112. package/src/pages/flowable/design/provider/properties/FormProps.js +55 -0
  113. package/src/pages/flowable/design/provider/properties/MultiInstanceProps.js +100 -0
  114. package/src/pages/flowable/design/provider/properties/UserTaskForm.jsx +48 -0
  115. package/src/pages/flowable/design/provider/properties/utils.jsx +35 -0
  116. package/src/pages/flowable/index.jsx +28 -69
  117. package/src/pages/flowable/monitor/definition.jsx +87 -0
  118. package/src/pages/flowable/monitor/instance/index.jsx +177 -0
  119. package/src/pages/flowable/monitor/instance/view.jsx +102 -0
  120. package/src/pages/flowable/monitor/task.jsx +93 -0
  121. package/src/pages/flowable/task/form.jsx +5 -5
  122. package/src/pages/flowable/task/index.jsx +5 -5
  123. package/src/pages/flowable/test/index.jsx +13 -10
  124. package/src/pages/index.jsx +8 -13
  125. package/src/pages/login.jsx +8 -8
  126. package/src/pages/{api/doc.jsx → system/api/ApiDoc.jsx} +56 -47
  127. package/src/pages/system/api/index.jsx +268 -0
  128. package/src/pages/system/api/perm.jsx +69 -0
  129. package/src/pages/system/config/index.jsx +3 -3
  130. package/src/pages/system/dict/Dict.jsx +2 -3
  131. package/src/pages/system/dict/DictItem.jsx +5 -5
  132. package/src/pages/system/file/index.jsx +13 -5
  133. package/src/pages/{job → system/job}/index.jsx +124 -39
  134. package/src/pages/system/log/index.jsx +3 -3
  135. package/src/pages/system/org/index.jsx +11 -12
  136. package/src/pages/system/role/index.jsx +11 -11
  137. package/src/pages/system/role/perm.jsx +8 -8
  138. package/src/pages/system/sysManual/index.jsx +6 -6
  139. package/src/pages/system/user/UserPerm.jsx +7 -42
  140. package/src/pages/system/user/index.jsx +13 -17
  141. package/src/pages/test.jsx +188 -3
  142. package/src/pages/ureport/index.jsx +4 -4
  143. package/src/pages/userCenter/ChangePassword.jsx +3 -4
  144. package/src/pages/userCenter/index.jsx +2 -2
  145. package/src/pages/userCenter/manual.jsx +3 -7
  146. package/src/pages/userCenter/message.jsx +5 -5
  147. package/config/dist/config.local.js +0 -23
  148. package/src/components/InstanceStatusInfo.jsx +0 -79
  149. package/src/components/StreamLog.jsx +0 -27
  150. package/src/components/flow/BpmnUtils.js +0 -85
  151. package/src/components/flow/customTranslate/customTranslate.js +0 -19
  152. package/src/components/flow/customTranslate/translations.js +0 -79
  153. package/src/components/flow/design/form/ConditionForm.jsx +0 -316
  154. package/src/components/flow/design/form/ServiceTaskForm.jsx +0 -55
  155. package/src/components/flow/design/form/TimerEventDefinitionForm.jsx +0 -62
  156. package/src/components/flow/design/form/UserTaskForm.jsx +0 -211
  157. package/src/components/flow/design/palette.js +0 -39
  158. package/src/components/monitor/AllDefinition.jsx +0 -46
  159. package/src/components/monitor/AllInstance.jsx +0 -76
  160. package/src/forms/driverForm.jsx +0 -18
  161. package/src/framework/components/ButtonList.jsx +0 -91
  162. package/src/framework/components/Echarts/index.d.ts +0 -10
  163. package/src/framework/components/Echarts/index.jsx +0 -49
  164. package/src/framework/components/EditTable/index.d.ts +0 -11
  165. package/src/framework/components/EditTable/index.jsx +0 -85
  166. package/src/framework/components/FieldRemoteTree.jsx +0 -20
  167. package/src/framework/components/HasPerm.jsx +0 -18
  168. package/src/framework/components/ImageView.d.ts +0 -12
  169. package/src/framework/components/ImageView.jsx +0 -64
  170. package/src/framework/components/MsgBox.jsx +0 -180
  171. package/src/framework/components/PageLoading.jsx +0 -31
  172. package/src/framework/components/Panel/index.d.ts +0 -11
  173. package/src/framework/components/Panel/index.jsx +0 -24
  174. package/src/framework/components/Panel/index.less +0 -0
  175. package/src/framework/components/field/FieldAutoTime/index.tsx +0 -46
  176. package/src/framework/components/field/FieldBoolean/index.tsx +0 -92
  177. package/src/framework/components/field/FieldEditTable/index.less +0 -29
  178. package/src/framework/components/field/FieldEditor.jsx +0 -48
  179. package/src/framework/components/field/FieldFileBase64/index.d.ts +0 -15
  180. package/src/framework/components/field/FieldFileBase64/index.jsx +0 -23
  181. package/src/framework/components/field/FieldImageBase64/index.d.ts +0 -15
  182. package/src/framework/components/field/FieldImageBase64/index.jsx +0 -22
  183. package/src/framework/components/field/FieldInput.jsx +0 -13
  184. package/src/framework/components/field/FieldOrgTree/index.tsx +0 -45
  185. package/src/framework/components/field/FieldPassword.jsx +0 -11
  186. package/src/framework/components/field/FieldProps.ts +0 -19
  187. package/src/framework/components/field/FieldRemoteTreeCascader.jsx +0 -75
  188. package/src/framework/components/field/FieldRemoteTreeCheckable.jsx +0 -81
  189. package/src/framework/components/field/FieldRemoteTreeMultipleSelect.jsx +0 -100
  190. package/src/framework/components/field/FieldRemoteTreeSelect.jsx +0 -82
  191. package/src/framework/components/field/FieldSelectPosition/index.tsx +0 -85
  192. package/src/framework/components/field/FieldTree.jsx +0 -45
  193. package/src/framework/components/field/dict/index.tsx +0 -110
  194. package/src/framework/components/field/flat-multiple-select/index.d.ts +0 -4
  195. package/src/framework/components/field/flat-multiple-select/index.jsx +0 -116
  196. package/src/framework/components/field/flat-multiple-select/index.less +0 -12
  197. package/src/framework/components/field/flat-select/index.d.ts +0 -4
  198. package/src/framework/components/field/flat-select/index.jsx +0 -107
  199. package/src/framework/components/field/flat-select/index.less +0 -12
  200. package/src/framework/components/field/index.js +0 -33
  201. package/src/framework/components/field/input-number-percent/index.d.ts +0 -11
  202. package/src/framework/components/field/input-number-percent/index.jsx +0 -28
  203. package/src/framework/components/field/select/FieldSelect/index.d.ts +0 -39
  204. package/src/framework/components/field/select/FieldSelect/index.jsx +0 -156
  205. package/src/framework/components/field/select/FieldTableSelect/index.jsx +0 -155
  206. package/src/framework/components/field/select/index.jsx +0 -2
  207. package/src/framework/components/field/switch-y-n/index.d.ts +0 -11
  208. package/src/framework/components/field/switch-y-n/index.jsx +0 -31
  209. package/src/framework/components/field/text/index.tsx +0 -7
  210. package/src/framework/components/field/time/DatePickerString.tsx +0 -37
  211. package/src/framework/components/field/time/DateTimePickerString.tsx +0 -42
  212. package/src/framework/components/field/time/FieldDateRange.d.ts +0 -9
  213. package/src/framework/components/field/time/FieldDateRange.jsx +0 -49
  214. package/src/framework/components/field/time/HHmmPickerString.tsx +0 -42
  215. package/src/framework/components/field/time/MonthPickerString.tsx +0 -45
  216. package/src/framework/components/field/time/TimePickerTool.ts +0 -14
  217. package/src/framework/components/field/time/YearPickerString.tsx +0 -41
  218. package/src/framework/components/field/time/YearQuarterString.tsx +0 -38
  219. package/src/framework/components/field/time/index.tsx +0 -7
  220. package/src/framework/components/field/upload/FieldUploadCropImage/index.d.ts +0 -22
  221. package/src/framework/components/field/upload/FieldUploadCropImage/index.jsx +0 -11
  222. package/src/framework/components/field/upload/FieldUploadImage.d.ts +0 -7
  223. package/src/framework/components/field/upload/FieldUploadImage.jsx +0 -16
  224. package/src/framework/components/field/upload/index.jsx +0 -3
  225. package/src/framework/components/system.jsx +0 -29
  226. package/src/framework/components/view/ViewBoolean.jsx +0 -15
  227. package/src/framework/components/view/ViewBooleanEnableDisable.jsx +0 -16
  228. package/src/framework/components/view/ViewText.jsx +0 -9
  229. package/src/framework/index.js +0 -3
  230. package/src/framework/system/dict.js +0 -88
  231. package/src/framework/system/formRegistry.js +0 -58
  232. package/src/framework/system/http.jsx +0 -290
  233. package/src/framework/system/index.js +0 -13
  234. package/src/framework/system/page.js +0 -109
  235. package/src/framework/system/permission.js +0 -44
  236. package/src/framework/system/sys.js +0 -60
  237. package/src/framework/system/theme.js +0 -17
  238. package/src/framework/utils/arr.js +0 -118
  239. package/src/framework/utils/browser.js +0 -24
  240. package/src/framework/utils/color.js +0 -269
  241. package/src/framework/utils/debounce.js +0 -33
  242. package/src/framework/utils/dom.js +0 -16
  243. package/src/framework/utils/eventBus.js +0 -70
  244. package/src/framework/utils/html.js +0 -13
  245. package/src/framework/utils/index.js +0 -17
  246. package/src/framework/utils/obj.js +0 -72
  247. package/src/framework/utils/storage.js +0 -37
  248. package/src/framework/utils/str.js +0 -297
  249. package/src/framework/utils/tree.js +0 -175
  250. package/src/framework/utils/uid.js +0 -76
  251. package/src/framework/utils/url.js +0 -84
  252. package/src/framework/utils/validate.js +0 -9
  253. package/src/pages/api/accessLog/index.jsx +0 -108
  254. package/src/pages/api/accountResource/index.jsx +0 -149
  255. package/src/pages/api/index.jsx +0 -163
  256. package/src/pages/api/resource.jsx +0 -18
  257. package/src/pages/flowable/instance/view.jsx +0 -13
  258. package/src/pages/flowable/monitor.jsx +0 -106
  259. package/src/pages/flowable/test/form.jsx +0 -31
  260. package/src/pages/job/logList.jsx +0 -100
  261. package/src/pages/job/status.jsx +0 -84
  262. /package/src/framework/components/{ButtonList.d.ts → system/ButtonList.d.ts} +0 -0
  263. /package/src/framework/{components/EditTable/index.less → field-components/FieldTable.less} +0 -0
  264. /package/src/framework/{components/view → view-components}/ViewPassword.jsx +0 -0
  265. /package/src/{index.js → index.ts} +0 -0
  266. /package/src/{components/flow → pages/flowable}/design/contextPad.js +0 -0
@@ -0,0 +1,152 @@
1
+ // 假设 StrUtil 已经转换为 StrUtils 或有一个对应的类型定义
2
+ // 如果 StrUtil 是一个工具对象,这里可能需要导入它
3
+ import {StringUtils} from "./StringUtils";
4
+
5
+ /**
6
+ * URL 相关操作的工具类
7
+ */
8
+ export class UrlUtils {
9
+
10
+ /**
11
+ * 定义一个类型别名,用于 URL 参数对象
12
+ */
13
+ public type
14
+ ParamsObject = Record<string, string | number | boolean | null | undefined>;
15
+
16
+ /**
17
+ * 获取 URL 的参数对象。
18
+ * 如果不传参数,则使用当前路径 (location.href)。
19
+ * @param url 完整的 URL 字符串,可选。
20
+ * @returns 包含 URL 参数的键值对对象。
21
+ */
22
+ public static getParams(url: string | null = null): UrlUtils.ParamsObject {
23
+ // 1. 确定要解析的 URL
24
+ let targetUrl: string;
25
+ if (url === null || url === undefined) {
26
+ targetUrl = location.href;
27
+ } else {
28
+ targetUrl = url;
29
+ }
30
+
31
+ // 2. 检查是否有查询参数
32
+ if (!StringUtils.contains(targetUrl, '?')) {
33
+ return {};
34
+ }
35
+
36
+ // 3. 提取查询字符串 (问号后面的部分)
37
+ // 假设 StrUtil.subAfter 能够正确获取 '?' 之后的部分
38
+ const search = StringUtils.subAfter(targetUrl, '?');
39
+
40
+ // 4. 使用 URLSearchParams 进行解析 (现代浏览器环境)
41
+ // 注意:在某些旧环境或非浏览器环境中,可能需要不同的解析逻辑
42
+ const params = new URLSearchParams(search);
43
+
44
+ // 5. 转换为普通对象
45
+ const result: UrlUtils.ParamsObject = {} as UrlUtils.ParamsObject;
46
+ for (const [key, value] of params.entries()) {
47
+ // URLSearchParams 的值总是 string,因此这里赋值为 string
48
+ result[key] = value;
49
+ }
50
+
51
+ return result;
52
+ }
53
+
54
+ /**
55
+ * 获取不带参数的基础 URL (pathname)。
56
+ * @param url 完整的 URL 字符串。
57
+ * @returns 不包含查询参数的 URL 部分,如果 url 为 null/undefined,则返回 null。
58
+ */
59
+ public static getPathname(url: string | null | undefined): string | null {
60
+ if (!url) {
61
+ return null;
62
+ }
63
+ // 假设 StrUtil.subBefore 能够正确获取 '?' 之前的部分
64
+ return StringUtils.subBefore(url, '?');
65
+ }
66
+
67
+ /**
68
+ * 将参数对象转换为 URL 中的查询字符串(例如 k1=v1&k2=v2)。
69
+ * @param params 包含参数的键值对对象。
70
+ * @returns 查询字符串,不包含开头的问号 (?)。如果 params 为空,则返回空字符串。
71
+ */
72
+ public static paramsToSearch(params: UrlUtils.ParamsObject | null | undefined): string {
73
+ if (!params) {
74
+ return "";
75
+ }
76
+
77
+ const buffer: string[] = [];
78
+ // 迭代对象的自身属性
79
+ for (const k in params) {
80
+ // 确保只处理对象自身的属性,排除原型链上的属性
81
+ if (Object.prototype.hasOwnProperty.call(params, k)) {
82
+ const v = params[k];
83
+ // 忽略值为 null 或 undefined 的参数,或根据需要进行编码
84
+ if (v !== null && v !== undefined) {
85
+ // 这里对值进行简单的连接,实际应用中建议使用 encodeURIComponent
86
+ buffer.push(`${k}=${v}`);
87
+ }
88
+ }
89
+ }
90
+ return buffer.join('&');
91
+ }
92
+
93
+ /**
94
+ * 设置或删除 URL 中的一个参数,并返回新的 URL。
95
+ * @param url 原始 URL 字符串。
96
+ * @param key 要设置或删除的参数名。
97
+ * @param value 要设置的参数值。如果传入 null 或 undefined,则删除该参数。
98
+ * @returns 带有新参数的新 URL 字符串。
99
+ */
100
+ public static setParam(url: string, key: string, value: string | number | boolean | null | undefined): string {
101
+ // 1. 获取现有参数
102
+ const currentParams = this.getParams(url);
103
+
104
+ // 2. 根据 value 设置或删除参数
105
+ if (value === null || value === undefined) {
106
+ delete currentParams[key];
107
+ } else {
108
+ // 强制转换为 string 存储,以符合 URL 参数的惯例
109
+ currentParams[key] = String(value);
110
+ }
111
+
112
+ // 3. 获取基础路径
113
+ const pathname = this.getPathname(url);
114
+
115
+ // 4. 将新的参数对象转换为查询字符串
116
+ const newSearch = this.paramsToSearch(currentParams);
117
+
118
+ // 5. 组合新的 URL
119
+ if (newSearch.length > 0) {
120
+ return `${pathname}?${newSearch}`;
121
+ }
122
+ // 如果没有参数,则不带问号
123
+ return pathname || url; // 如果 pathname 为 null,则返回原始 url
124
+ }
125
+
126
+ /**
127
+ * @deprecated 使用 setParam 代替。
128
+ * 设置或替换 URL 中的一个参数,功能与 setParam 相同。
129
+ * @param url 原始 URL 字符串。
130
+ * @param key 要替换的参数名。
131
+ * @param value 要替换的参数值。
132
+ * @returns 带有新参数的新 URL 字符串。
133
+ */
134
+ public static replaceParam(url: string, key: string, value: string | number | boolean | null | undefined): string {
135
+ // 直接调用 setParam,并返回结果
136
+ return this.setParam(url, key, value);
137
+ }
138
+
139
+ /**
140
+ * 连接两个路径片段,确保中间只有一个斜杠 (/)。
141
+ * @param path1 第一个路径片段。
142
+ * @param path2 第二个路径片段。
143
+ * @returns 连接后的路径字符串。
144
+ */
145
+ public static join(path1: string, path2: string): string {
146
+ // 假设 StrUtil.removeSuffix/removePrefix 能够处理字符串前后的斜杠
147
+ const cleanPath1 = StringUtils.removeSuffix(path1, "/");
148
+ const cleanPath2 = StringUtils.removePrefix(path2, "/");
149
+
150
+ return `${cleanPath1}/${cleanPath2}`;
151
+ }
152
+ }
@@ -0,0 +1,88 @@
1
+ /**
2
+ * 基于 https://github.com/jchook/uuid-random 的工作进行封装
3
+ */
4
+ export class UuidUtils {
5
+ // 静态属性用于存储随机字节缓冲区和索引
6
+ private static buf: Uint8Array | undefined = undefined;
7
+ private static bufIdx: number = 0;
8
+
9
+ // 预计算 toString(16) 以提高速度
10
+ private static readonly hexBytes: string[] = (() => {
11
+ const bytes = new Array<string>(256);
12
+ for (let i = 0; i < 256; i++) {
13
+ // (i + 0x100).toString(16).substring(1) 确保总是两位十六进制
14
+ bytes[i] = (i + 0x100).toString(16).substring(1);
15
+ }
16
+ return bytes;
17
+ })();
18
+
19
+ // 缓冲区大小,可调整
20
+ private static readonly BUFFER_SIZE: number = 4096;
21
+
22
+ // 随机字节生成函数,使用最佳可用 PRNG
23
+ private static readonly randomBytes = ((n: number): Uint8Array => {
24
+ // Node & Browser 支持
25
+ const lib = typeof crypto !== 'undefined'
26
+ ? crypto
27
+ : (
28
+ typeof window !== 'undefined'
29
+ ? window.crypto || (window as any).msCrypto // window.msCrypto 在 TypeScript 中可能不存在
30
+ : undefined
31
+ );
32
+
33
+ if (lib !== undefined) {
34
+ // Node.js 支持
35
+ if ((lib as any).randomBytes !== undefined) {
36
+ return (lib as any).randomBytes(n);
37
+ }
38
+ // 浏览器支持
39
+ if (lib.getRandomValues !== undefined) {
40
+ return (() => {
41
+ const bytes = new Uint8Array(n);
42
+ lib.getRandomValues(bytes);
43
+ return bytes;
44
+ })();
45
+ }
46
+ }
47
+
48
+ // 降级使用 Math.random
49
+ const r = new Uint8Array(n);
50
+ for (let i = 0; i < n; i++) {
51
+ r[i] = Math.floor(Math.random() * 256);
52
+ }
53
+ return r;
54
+ });
55
+
56
+ /**
57
+ * 生成一个符合 v4 标准的 UUID。
58
+ * @returns 一个 UUID 字符串。
59
+ */
60
+ public static uuidV4(): string {
61
+ // 为加速而缓冲一些随机字节
62
+ if (UuidUtils.buf === undefined || (UuidUtils.bufIdx + 16 > UuidUtils.BUFFER_SIZE)) {
63
+ UuidUtils.bufIdx = 0;
64
+ // randomBytes 的返回类型已确定为 Uint8Array
65
+ UuidUtils.buf = UuidUtils.randomBytes(UuidUtils.BUFFER_SIZE);
66
+ }
67
+
68
+ // 提取 16 个字节。使用 Array.prototype.slice.call 转化为 Array 并不能保证性能,
69
+ // 且 TypeScript 中操作 Uint8Array 更直接。我们直接使用 subarray 提取,性能更优。
70
+ const b = UuidUtils.buf.subarray(UuidUtils.bufIdx, (UuidUtils.bufIdx += 16));
71
+
72
+ // 设置 UUID 版本 (Version 4: 0100)
73
+ b[6] = (b[6] & 0x0f) | 0x40;
74
+ // 设置时钟序列高位 (Variant 1: 10xx)
75
+ b[8] = (b[8] & 0x3f) | 0x80;
76
+
77
+ // 将字节转换为十六进制字符串格式
78
+ const h = UuidUtils.hexBytes;
79
+ return h[b[0]] + h[b[1]]
80
+ + h[b[2]] + h[b[3]] + '-'
81
+ + h[b[4]] + h[b[5]] + '-'
82
+ + h[b[6]] + h[b[7]] + '-'
83
+ + h[b[8]] + h[b[9]] + '-'
84
+ + h[b[10]] + h[b[11]]
85
+ + h[b[12]] + h[b[13]]
86
+ + h[b[14]] + h[b[15]];
87
+ }
88
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * 验证工具类
3
+ */
4
+ export class ValidateUtils {
5
+
6
+ /**
7
+ * 检查给定的字符串是否为有效的电子邮件地址。
8
+ * @param emailStr 要检查的字符串。
9
+ * @returns 如果是有效的电子邮件地址,则返回 true;否则返回 false。
10
+ */
11
+ public static isEmail(emailStr: string): boolean {
12
+ // 匹配大多数常见电子邮件格式的正则表达式
13
+ const reg = /^([\w+.-])+@\w+([.]\w+)+$/;
14
+ return reg.test(emailStr);
15
+ }
16
+
17
+ // 可以在这里添加其他验证方法,例如:
18
+ /*
19
+ public static isPhone(phoneStr: string): boolean {
20
+ // ... 手机号验证逻辑
21
+ return /^\d{10}$/.test(phoneStr);
22
+ }
23
+ */
24
+ }
25
+
26
+ // 示例用法:
27
+ // const isValid = ValidateUtils.isEmail("test@example.com");
28
+ // console.log(isValid); // true
@@ -0,0 +1,16 @@
1
+ export * from "./DateUtils";
2
+ export * from "./ArrUtils";
3
+ export * from "./UrlUtils"
4
+ export * from "./StringUtils"
5
+ export * from "./EventBusUtils";
6
+ export * from "./ColorsUtils"
7
+ export * from "./DomUtils"
8
+ export * from "./UuidUtils";
9
+ export * from "./StringUtils"
10
+ export * from "./TreeUtils";
11
+ export * from './StorageUtils'
12
+ export * from './DeviceUtils'
13
+ export * from './ObjectUtils'
14
+ export * from './ValidateUtils'
15
+ export * from './system'
16
+ export * from './MessageUtils'
@@ -0,0 +1,97 @@
1
+ // 假设的类型定义,你需要确保与你的实际数据结构匹配
2
+ import {SysUtils} from "./SysUtils";
3
+
4
+ export interface DictItem {
5
+ value: string | number;
6
+ label: string;
7
+ color?: string;
8
+ }
9
+
10
+
11
+ // 假设 SysUtil 和 StrUtil 的引入和类型
12
+ // 实际使用时需要确保路径和模块存在
13
+ import {Tag} from 'antd';
14
+ import React from 'react';
15
+ import {StringUtils} from "../StringUtils";
16
+
17
+ // 字典选项的格式
18
+ export interface DictOption {
19
+ value: string|number;
20
+ label: string;
21
+ }
22
+
23
+ /**
24
+ * 字典相关的工具类
25
+ */
26
+ export class DictUtils {
27
+
28
+ /**
29
+ * 根据字典类型code返回字典数据列表。
30
+ * code 支持 驼峰或下划线(都转为下划线进行匹配)。
31
+ * @param code 字典类型编码 (如 'userStatus', 'USER_STATUS')
32
+ * @returns 对应的字典项列表,未找到返回空数组
33
+ */
34
+ public static dictList(code: string): DictItem[] {
35
+ const map = SysUtils.getDictInfo();
36
+ if (map === undefined) {
37
+ return [];
38
+ }
39
+
40
+ code = StringUtils.toUnderlineCase(code).toUpperCase();
41
+
42
+ return map[code] || [];
43
+ }
44
+
45
+ /**
46
+ * 将字典列表转换为 Ant Design Select/Options 格式
47
+ * @param typeCode 字典类型编码
48
+ * @returns 包含 value/label 的选项列表
49
+ */
50
+ public static dictOptions(typeCode: string): DictOption[] {
51
+ const list: DictItem[] = DictUtils.dictList(typeCode);
52
+ return list.map(i => {
53
+ return {
54
+ value: i.value,
55
+ label: i.label,
56
+ }
57
+ });
58
+ }
59
+
60
+
61
+ /**
62
+ * 根据字典类型和字典项code获取对应的名称(name)
63
+ * @param typeCode 字典类型编码
64
+ * @param code 字典项编码
65
+ * @returns 对应的名称,未找到返回 undefined
66
+ */
67
+ public static dictLabel(typeCode: string, code: string | number): string | undefined {
68
+ const items = DictUtils.dictList(typeCode);
69
+ const item = items.find(i => i.value === code);
70
+ return item ? item.label : undefined;
71
+ }
72
+
73
+ /**
74
+ * 根据字典类型和字典项code获取对应的名称,并使用 Ant Design Tag 组件包装 (如果存在 color 属性)
75
+ * @param typeCode 字典类型编码
76
+ * @param code 字典项编码
77
+ * @returns Antd Tag 元素或纯字符串名称或空字符串
78
+ */
79
+ public static dictTag(typeCode: string, code: string | number ): React.ReactElement | string {
80
+ if (typeCode == null || code == null) {
81
+ return null;
82
+ }
83
+ const item = DictUtils.dictList(typeCode).find(i => i.value === code);
84
+
85
+ if (item == null) {
86
+ return null;
87
+ }
88
+ const {label, color} = item;
89
+
90
+ if (color == null) {
91
+ // 如果没有颜色,返回纯文本
92
+ return label;
93
+ }
94
+
95
+ return React.createElement(Tag, {color: color}, label);
96
+ }
97
+ }
@@ -0,0 +1,77 @@
1
+ import * as React from 'react';
2
+
3
+ /**
4
+ * 💡 类型定义同上
5
+ */
6
+ type FormComponent = React.ComponentType<any>;
7
+
8
+ /**
9
+ * 🛠️ FormRegistryUtils
10
+ * 一个静态工具类,用于注册、获取和管理表单组件。
11
+ * 调用时无需实例化,直接使用 FormRegistryUtils.methodName()。
12
+ */
13
+ export class FormRegistryUtils {
14
+ // 静态私有属性:存储表单组件的 Map
15
+ private static forms: Map<string, FormComponent> = new Map<string, FormComponent>();
16
+
17
+ /**
18
+ * 注意:
19
+ * 1. 私有构造函数可以防止该类被外部实例化(可选,但推荐用于纯静态类)。
20
+ * 2. 如果不定义构造函数,TypeScript 默认允许实例化,但因为所有成员都是静态的,实例化没有意义。
21
+ */
22
+ private constructor() {
23
+ // 阻止外部实例化
24
+ }
25
+
26
+ /**
27
+ * 静态方法:注册表单组件
28
+ * @param formKey - 表单唯一标识
29
+ * @param formComponent - React 表单组件
30
+ */
31
+ public static register(formKey: string, formComponent: FormComponent): void {
32
+ if (!formKey || !formComponent) {
33
+ throw new Error("【FormRegistryUtils】表单 Key 和组件不能为空!");
34
+ }
35
+
36
+ // 访问静态属性需要使用 'FormRegistryUtils.'
37
+ if (FormRegistryUtils.forms.has(formKey)) {
38
+ console.warn(`⚠️ 【FormRegistryUtils】表单 "${formKey}" 已存在,将被覆盖!`);
39
+ }
40
+
41
+ FormRegistryUtils.forms.set(formKey, formComponent);
42
+ console.log(`✅ 【FormRegistryUtils】表单 "${formKey}" 注册成功`);
43
+ }
44
+
45
+ /**
46
+ * 静态方法:获取表单组件
47
+ * @param formKey - 表单唯一标识
48
+ * @returns React 表单组件,如果不存在则返回 null
49
+ */
50
+ public static get(formKey: string): FormComponent | null {
51
+ const formComponent = FormRegistryUtils.forms.get(formKey);
52
+
53
+ if (!formComponent) {
54
+ console.warn(`⚠️ 【FormRegistryUtils】表单 "${formKey}" 未注册!`);
55
+ }
56
+
57
+ return formComponent ?? null;
58
+ }
59
+
60
+ /**
61
+ * 静态方法:检查表单是否已注册
62
+ * @param formKey - 表单唯一标识
63
+ * @returns boolean
64
+ */
65
+ public static has(formKey: string): boolean {
66
+ return FormRegistryUtils.forms.has(formKey);
67
+ }
68
+
69
+ /**
70
+ * 静态方法:获取所有已注册的表单 Key
71
+ * @returns string[] - 所有表单 Key 的数组
72
+ */
73
+ public static getAllKeys(): string[] {
74
+ return Array.from(FormRegistryUtils.forms.keys());
75
+ }
76
+ }
77
+