@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,246 @@
1
+ import axios, {AxiosRequestConfig, AxiosResponse, Method} from "axios";
2
+ import {message as messageUtil, Modal} from "antd";
3
+ import qs from 'qs';
4
+ import {PageUtils} from "./PageUtils";
5
+ import {MessageUtils} from "../MessageUtils";
6
+
7
+
8
+ const axiosInstance = axios.create({
9
+ withCredentials: true,
10
+ headers: {
11
+ 'Content-Type': 'application/json'
12
+ },
13
+ // 解决get请求时,数组参数的问题
14
+ paramsSerializer: (params) => {
15
+ return qs.stringify(params, {indices: false});
16
+ }
17
+ })
18
+
19
+
20
+ /**
21
+ * @description HTTP请求工具类
22
+ */
23
+ export class HttpUtils {
24
+
25
+
26
+ /**
27
+ * 核心请求函数,处理请求发送、加载状态、响应解析和错误捕获
28
+ * @param config AxiosRequestConfig & RequestOptions
29
+ * @param transformData 是否返回最总的data字段
30
+ * @returns Promise<any>
31
+ */
32
+ // ... existing code ...
33
+ private static coreRequest(config: AxiosRequestConfig, transformData: boolean = true): Promise<any> {
34
+ const url = config.url;
35
+ config.url = url.startsWith('admin') ? '/' + url : url;
36
+
37
+ return new Promise((resolve, reject) => {
38
+ axios(config).then((response: AxiosResponse) => {
39
+ const body = response.data;
40
+ // 假设后端响应结构为 { success: boolean | null, message: string, data: any, code: number }
41
+ let {success, message, data} = body;
42
+ if (success == undefined) { // 如果没有success字段,说明非标准接口
43
+ return response;
44
+ }
45
+
46
+ if (!success) {
47
+ messageUtil.error(message || '操作失败');
48
+ reject('操作失败');
49
+ return
50
+ }
51
+
52
+ // 自动消息提示
53
+ if (message) {
54
+ messageUtil.success(message);
55
+ }
56
+ resolve(transformData ? data : response);
57
+ }).catch((e: unknown) => {
58
+ // 统一异常处理
59
+ let msg = '操作失败';
60
+
61
+ if (axios.isAxiosError(e)) {
62
+ const status = e.response?.status;
63
+ const responseData = e.response?.data;
64
+
65
+ if (status === 401) {
66
+ // 登录过期处理
67
+ MessageUtils.confirm('登录已过期,请重新登录').then(() => {
68
+ PageUtils.redirectToLogin();
69
+ });
70
+ // 阻止后续的错误提示,返回一个特殊 Promise.reject
71
+ reject('登录过期');
72
+ return
73
+ }
74
+ if (status === 504) {
75
+ msg = '504 请求后端服务失败';
76
+ } else if (responseData && responseData.message) {
77
+ msg = responseData.message;
78
+ } else if (e.message) {
79
+ msg = e.message;
80
+ }
81
+ } else if (e instanceof Error) {
82
+ // 可能是后端success=false抛出的自定义错误
83
+ msg = e.message;
84
+ }
85
+
86
+ messageUtil.error(msg);
87
+
88
+ // 将原始错误或处理后的错误信息向外抛出
89
+ reject(e);
90
+ });
91
+ })
92
+
93
+ }
94
+
95
+
96
+ /**
97
+ * 处理文件下载后的blob流
98
+ * @param res AxiosResponse 文件下载响应
99
+ */
100
+ private static handleDownloadBlob(res: AxiosResponse): Promise<void> {
101
+ return new Promise((resolve, reject) => {
102
+ const {data: blob, headers} = res;
103
+
104
+ // 1. 检查是否为错误JSON
105
+ if (blob.type === 'application/json') {
106
+ const reader = new FileReader();
107
+ reader.readAsText(blob, 'utf-8');
108
+ reader.onload = function () {
109
+ try {
110
+ let rs = JSON.parse(reader.result as string);
111
+ Modal.error({
112
+ title: '下载文件失败',
113
+ content: rs.message || '不支持下载'
114
+ });
115
+ reject(new Error(rs.message || '下载错误'));
116
+ } catch (e) {
117
+ Modal.error({title: '下载文件失败', content: '解析错误响应失败'});
118
+ reject(e);
119
+ }
120
+ };
121
+ return;
122
+ }
123
+
124
+ // 2. 获取文件名称
125
+ const contentDisposition = headers['content-disposition'] || headers['Content-Disposition'];
126
+ if (!contentDisposition) {
127
+ Modal.error({title: '获取文件名称失败', content: "缺少Content-Disposition响应头"});
128
+ reject(new Error("缺少Content-Disposition响应头"));
129
+ return;
130
+ }
131
+
132
+ const match = /filename\*?=(?:['"]?)(?:UTF-8''|)(.+?)(?:['"]?$|;)/i.exec(contentDisposition);
133
+ let filename = match && match[1] ? match[1].trim() : 'download.file';
134
+
135
+ try {
136
+ // 尝试进行URI解码
137
+ filename = decodeURIComponent(filename.replace(/"/g, ''));
138
+ } catch (e) {
139
+ // 如果解码失败,保持原样
140
+ filename = filename.replace(/"/g, '');
141
+ }
142
+
143
+ // 3. 开始下载
144
+ const url = window.URL.createObjectURL(new Blob([blob]));
145
+ const link = document.createElement('a');
146
+ link.style.display = 'none';
147
+
148
+ link.href = url;
149
+ link.download = filename;
150
+
151
+ document.body.appendChild(link);
152
+ link.click();
153
+
154
+ document.body.removeChild(link);
155
+ window.URL.revokeObjectURL(url);
156
+ resolve();
157
+ });
158
+ }
159
+
160
+
161
+ /**
162
+ * 发送GET请求
163
+ * @param url 请求地址
164
+ * @param params URL参数
165
+ * @param options 自定义配置 (transformData等)
166
+ * @returns Promise<any> 后端返回的 data 字段
167
+ */
168
+ public static get(url: string, params: any = null, options: Partial<AxiosRequestConfig> = {}): Promise<any> {
169
+ return HttpUtils.coreRequest({
170
+ ...options,
171
+ url,
172
+ method: 'GET',
173
+ params,
174
+ });
175
+ }
176
+
177
+ /**
178
+ * 发送POST请求 (Content-Type: application/json)
179
+ * @param url 请求地址
180
+ * @param data 请求体数据
181
+ * @param params URL参数
182
+ * @param options 自定义配置
183
+ * @returns Promise<any> 后端返回的 data 字段
184
+ */
185
+ public static post(url: string, data: any = null, params: any = null, options: Partial<RequestOptions> = {}): Promise<any> {
186
+ return HttpUtils.coreRequest({
187
+ ...options,
188
+ url,
189
+ method: 'POST',
190
+ data,
191
+ params,
192
+ });
193
+ }
194
+
195
+ /**
196
+ * 发送POST表单请求 (Content-Type: application/x-www-form-urlencoded)
197
+ * @param url 请求地址
198
+ * @param data 表单数据
199
+ * @param options 自定义配置
200
+ * @returns Promise<any> 后端返回的 data 字段
201
+ */
202
+ public static postForm(url: string, data: any, options: Partial<AxiosRequestConfig> = {}): Promise<any> {
203
+ return HttpUtils.coreRequest({
204
+ ...options,
205
+ url,
206
+ method: 'POST',
207
+ data: qs.stringify(data), // 转换为表单格式
208
+ headers: {
209
+ 'Content-Type': 'application/x-www-form-urlencoded'
210
+ },
211
+ });
212
+ }
213
+
214
+ /**
215
+ * 下载文件
216
+ * @param url 请求地址
217
+ * @param data 请求体数据 (POST时使用)
218
+ * @param params URL参数
219
+ * @param method 请求方法,默认为GET
220
+ * @param options 自定义配置
221
+ * @returns Promise<void>
222
+ */
223
+ public static async downloadFile(url: string, data: any = null, params: any = null, method: Method = 'GET', options: Partial<AxiosRequestConfig> = {}): Promise<void> {
224
+
225
+ // 下载请求默认设置:不转换数据,响应类型为 blob
226
+ const downloadConfig: AxiosRequestConfig = {
227
+ responseType: 'blob', // 关键设置
228
+ ...options,
229
+ url,
230
+ method,
231
+ params,
232
+ data,
233
+ };
234
+
235
+ try {
236
+ // coreRequest返回的是完整的 AxiosResponse,因此需要类型断言
237
+ const response = await HttpUtils.coreRequest(downloadConfig, false) as AxiosResponse;
238
+ await HttpUtils.handleDownloadBlob(response);
239
+ } catch (error) {
240
+ // coreRequest已经处理了401、504和通用的错误提示
241
+ return Promise.reject(error);
242
+ }
243
+ }
244
+
245
+
246
+ }
@@ -0,0 +1,153 @@
1
+ import { history } from "umi";
2
+ import {StringUtils} from "../StringUtils";
3
+ import {UrlUtils} from "../UrlUtils";
4
+
5
+ /**
6
+ * 页面相关的工具类,主要用于路由、URL参数和页面跳转操作。
7
+ */
8
+ export class PageUtils {
9
+
10
+ /**
11
+ * 重定向到登录页,并携带当前页面的URL作为回跳参数。
12
+ */
13
+ static redirectToLogin(): void {
14
+ const url = PageUtils.currentUrl();
15
+ // 对URL进行编码,确保参数安全传递
16
+ const encodedUrl = encodeURIComponent(url);
17
+ history.push(`/login?redirect=${encodedUrl}`);
18
+ }
19
+
20
+ /**
21
+ * @deprecated 请使用 currentParams() 代替。
22
+ * 获取当前 URL 的查询参数对象。
23
+ * @returns {Record<string, string | undefined>} 包含查询参数的键值对对象。
24
+ */
25
+ static currentLocationQuery(): Record<string, string | undefined> {
26
+ return this.currentParams();
27
+ }
28
+
29
+ /**
30
+ * 获取当前 URL 的查询参数对象。
31
+ * @returns {Record<string, string | undefined>} 包含查询参数的键值对对象。
32
+ */
33
+ static currentParams(): Record<string, string | undefined> {
34
+ const url = window.location.href;
35
+
36
+ // 检查是否存在查询参数
37
+ const hasQuery = url.indexOf('?') > 0;
38
+ if (!hasQuery) {
39
+ return {};
40
+ }
41
+
42
+ // 提取问号后面的查询字符串
43
+ const search = url.substring(url.indexOf('?') + 1);
44
+ const kvs = search.split('&');
45
+
46
+ const rs: Record<string, string | undefined> = {};
47
+ for (const kv of kvs) {
48
+ const kvArr = kv.split('=');
49
+ const k = kvArr[0];
50
+ let v = kvArr[1];
51
+
52
+ // 值存在时才进行解码
53
+ if (v) {
54
+ // 使用 decodeURIComponent 更安全地处理 URL 编码的值
55
+ try {
56
+ v = decodeURIComponent(v);
57
+ } catch (e) {
58
+ console.error("Failed to decode URL parameter value:", v, e);
59
+ // 解码失败时保留原值
60
+ }
61
+ } else {
62
+ v = undefined; // 如果值为空,设置为 undefined
63
+ }
64
+ rs[k] = v;
65
+ }
66
+
67
+ return rs;
68
+ }
69
+
70
+ /**
71
+ * 获取当前 URL 的路径名(不带查询参数和 Hash 符号 #)。
72
+ * 例如:"http://localhost:8000/#/login?id=1" -> "/login"
73
+ * @returns {string} 不带参的路径。
74
+ */
75
+ static currentPathname(): string {
76
+ // window.location.hash.substring(1) 得到 "/login?id=1"
77
+ const path = window.location.hash.substring(1);
78
+ return StringUtils.subBefore(path, '?');
79
+ }
80
+
81
+ /**
82
+ * @deprecated 请使用 currentUrl() 代替。
83
+ * 获取 hash 后的完整路径 (带参数)。
84
+ * @returns {string} 例如:"/login?id=1"
85
+ */
86
+ static currentPath(): string {
87
+ // window.location.hash.substring(1) 得到 "/login?id=1"
88
+ return window.location.hash.substring(1);
89
+ }
90
+
91
+ /**
92
+ * 获取 hash 后的完整路径 (带参数)。
93
+ * @returns {string} 例如:"/login?id=1"
94
+ */
95
+ static currentUrl(): string {
96
+ return window.location.hash.substring(1);
97
+ }
98
+
99
+ /**
100
+ * 当前路由的最后一个斜杠后面的单词,通常用于基于路径的路由。
101
+ * 例如:"/user/detail/123" -> "123"
102
+ * @returns {string | undefined} 路径的最后一部分或 undefined。
103
+ */
104
+ static currentPathnameLastPart(): string | undefined {
105
+ const path = this.currentPathname();
106
+ return StringUtils.subAfterLast(path, '/') || undefined;
107
+ }
108
+
109
+ /**
110
+ * 打开一个新页面,可选择添加一个 '_label' 参数。
111
+ * @param path 要跳转的路径。
112
+ * @param label 可选,用于在 URL 中添加一个 '_label' 参数。
113
+ */
114
+ static open(path: string, label: string ='临时'): void {
115
+ let targetPath = path;
116
+ if(label) {
117
+ // 假设 UrlUtil.setParam(url, key, value) 存在并返回设置参数后的 URL
118
+ targetPath = UrlUtils.setParam(targetPath, '_label', label);
119
+ }
120
+ history.push(targetPath);
121
+ }
122
+
123
+ /**
124
+ * 打开一个不带菜单、Header 等布局元素的页面。
125
+ * 通过在 URL 中添加 '_noLayout=true' 参数实现。
126
+ * @param path 要跳转的路径。
127
+ */
128
+ static openNoLayout(path: string): void {
129
+ // 假设 UrlUtil.setParam(url, key, value) 存在
130
+ const targetPath = UrlUtils.setParam(path, '_noLayout', true);
131
+ history.push(targetPath);
132
+ }
133
+
134
+ /**
135
+ * 获取当前 URL 参数中名为 '_label' 的值。
136
+ * @returns {string | undefined} '_label' 参数的值。
137
+ */
138
+ static currentLabel(): string | undefined {
139
+ // currentParams 返回 Record<string, string | undefined>
140
+ return this.currentParams()['_label'];
141
+ }
142
+
143
+ /**
144
+ * 发送一个自定义事件来关闭当前页面。
145
+ * 依赖外部监听 'close-page-event' 事件的处理机制。
146
+ */
147
+ static closeCurrent(): void {
148
+ const event = new CustomEvent<{ url: string }>('close-page-event', {
149
+ detail: { url: PageUtils.currentUrl() }
150
+ });
151
+ document.dispatchEvent(event);
152
+ }
153
+ }
@@ -0,0 +1,79 @@
1
+ import {SysUtils} from "./SysUtils";
2
+ import {ArrUtils} from "../ArrUtils";
3
+
4
+ /**
5
+ * 登录用户信息接口,
6
+ */
7
+ interface LoginInfo {
8
+ // ... 其他登录信息字段
9
+ permissions: string[];
10
+ }
11
+
12
+ /**
13
+ * 权限控制工具类
14
+ */
15
+ export class PermUtils {
16
+
17
+ /**
18
+ * 获取当前用户的权限列表信息。
19
+ * @private
20
+ * @returns {string[]} 权限码数组。
21
+ */
22
+ private static getPermissions(): string[] {
23
+ // 假设 SysUtil.getLoginInfo() 返回 LoginInfo 类型的对象
24
+ const info: LoginInfo = SysUtils.getLoginInfo();
25
+ const { permissions } = info;
26
+
27
+ if (permissions == null || permissions.length === 0) {
28
+ return [];
29
+ }
30
+
31
+ return permissions;
32
+ }
33
+
34
+ /**
35
+ * 是否拥有权限
36
+ * * @param perm 权限码 (string)
37
+ * @returns {boolean} 如果拥有权限则为 true,否则为 false。
38
+ */
39
+ public static hasPermission(perm: string | null | undefined): boolean {
40
+ if (perm === null || perm === undefined || perm === '') {
41
+ return false;
42
+ }
43
+
44
+ const permissions: string[] = PermUtils.getPermissions();
45
+
46
+ if (permissions.length === 0) {
47
+ return false;
48
+ }
49
+
50
+ // 检查是否拥有超级权限 '*'
51
+ // 假设 ArrUtils.contains(array, item) 存在且返回 boolean
52
+ if (ArrUtils.contains(permissions, "*")) {
53
+ return true;
54
+ }
55
+
56
+ // 检查是否包含指定的权限码
57
+ return permissions.indexOf(perm) > -1;
58
+ }
59
+
60
+ /**
61
+ * 是否授权,功能上与 hasPermission 相同。
62
+ * * @param p 权限码 (string)
63
+ * @returns {boolean} 如果拥有权限则为 true,否则为 false。
64
+ */
65
+ public static isPermitted(p: string | null | undefined): boolean {
66
+ // 直接调用内部方法
67
+ return PermUtils.hasPermission(p);
68
+ }
69
+
70
+ /**
71
+ * 是否没有权限。
72
+ * * @param p 权限码 (string)
73
+ * @returns {boolean} 如果没有权限则为 true,否则为 false。
74
+ */
75
+ public static notPermitted(p: string | null | undefined): boolean {
76
+ // 使用!取反,并确保方法返回布尔值
77
+ return !PermUtils.isPermitted(p);
78
+ }
79
+ }
@@ -0,0 +1,97 @@
1
+
2
+ // --- 常量定义 ---
3
+ import {StorageUtils} from "../StorageUtils";
4
+
5
+ const SITE_INFO_KEY = "siteInfo";
6
+ const LOGIN_INFO_KEY = "loginInfo";
7
+ const DICT_INFO_KEY = "dictInfo";
8
+
9
+ // 假设 SiteInfo, LoginInfo, DictInfo 是工具类操作的数据结构。
10
+ // 请根据你的实际情况替换为正确的接口或类型。
11
+ interface SiteInfo {
12
+ // 示例属性
13
+ name: string;
14
+ version: string;
15
+ }
16
+
17
+ interface LoginInfo {
18
+ // 示例属性
19
+ token: string;
20
+ userId: number;
21
+ }
22
+
23
+ // 字典数据通常是键值对或数组,这里假设是 Record<string, any>
24
+ type DictInfo = Record<string, any> | null;
25
+
26
+ /**
27
+ * 系统工具类 (Utils Pattern)
28
+ */
29
+ export class SysUtils {
30
+
31
+ /**
32
+ * 获取请求头信息。
33
+ * @returns 一个包含请求头键值对的对象。
34
+ */
35
+ public static getHeaders(): Record<string, string> {
36
+ const headers: Record<string, string> = {};
37
+ // 实际的 headers 逻辑(如添加认证 token 等)应在此处实现
38
+ return headers;
39
+ }
40
+
41
+ /**
42
+ * 设置站点信息。
43
+ * @param data 要存储的站点信息数据。
44
+ * @returns StorageUtil.set 的返回值 (通常是 void 或 Promise<void>)
45
+ */
46
+ public static setSiteInfo(data: SiteInfo): void {
47
+ // 假设 StorageUtil.set 返回 void
48
+ // 请根据实际 StorageUtil 的实现调整返回值类型
49
+ StorageUtils.set(SITE_INFO_KEY, data);
50
+ }
51
+
52
+ /**
53
+ * 获取站点信息。
54
+ * @returns 站点信息对象,如果不存在则返回一个空对象。
55
+ */
56
+ public static getSiteInfo(): SiteInfo {
57
+ // 假设 StorageUtil.getDefinition 内部处理了 JSON.parse,并返回对应类型或 null
58
+ return StorageUtils.get(SITE_INFO_KEY) || {} as SiteInfo;
59
+ }
60
+
61
+ /**
62
+ * 设置登录信息。
63
+ * @param data 要存储的登录信息数据。
64
+ */
65
+ public static setLoginInfo(data: LoginInfo): void {
66
+ StorageUtils.set(LOGIN_INFO_KEY, data);
67
+ }
68
+
69
+ /**
70
+ * 获取登录信息。
71
+ * @returns 登录信息对象,如果不存在则返回一个空对象。
72
+ */
73
+ public static getLoginInfo(): LoginInfo {
74
+ return StorageUtils.get(LOGIN_INFO_KEY) || {} as LoginInfo;
75
+ }
76
+
77
+ /**
78
+ * 设置字典信息。
79
+ * @param data 要存储的字典信息数据。
80
+ */
81
+ public static setDictInfo(data: DictInfo): void {
82
+ StorageUtils.set(DICT_INFO_KEY, data);
83
+ }
84
+
85
+ /**
86
+ * 获取字典信息。
87
+ * @returns 字典信息对象,如果不存在则返回 null。
88
+ */
89
+ public static getDictInfo(): DictInfo {
90
+ return StorageUtils.get(DICT_INFO_KEY);
91
+ }
92
+ }
93
+
94
+ // 导出常量(保持不变,但通常将常量放在类内部作为 static readonly 属性更符合 class 模式,
95
+ // 不过为了兼容性,我先保留外部导出,同时建议在类中使用常量)
96
+
97
+ export { SITE_INFO_KEY, LOGIN_INFO_KEY, DICT_INFO_KEY };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * 主题相关的工具类
3
+ */
4
+ export class ThemeUtils {
5
+ // 使用 readonly 属性来定义主题常量,保持其不可变性
6
+ public static readonly theme = {
7
+ "primary-color": "#1961AC",
8
+ "success-color": "#52c41a",
9
+ "warning-color": "#faad14",
10
+ "error-color": "#ff4d4f",
11
+ "background-color": "#f5f5f5",
12
+
13
+ "primary-color-hover": "#4990CD",
14
+ "primary-color-click": "#124B93"
15
+ };
16
+
17
+ /**
18
+ * @description 可选:提供一个获取主题颜色的静态方法,增强工具类的可用性
19
+ * @param key 主题颜色键名
20
+ * @returns 对应的颜色值,如果键名不存在则返回undefined
21
+ */
22
+ public static getColor(key: keyof typeof ThemeUtils.theme): string | undefined {
23
+ return ThemeUtils.theme[key];
24
+ }
25
+ }
26
+
27
+
@@ -0,0 +1,7 @@
1
+ export * from './DictUtils'
2
+ export * from './PermUtils'
3
+ export * from './PageUtils'
4
+ export * from "./SysUtils"
5
+ export * from './HttpUtils'
6
+ export * from './FormRegistryUtils'
7
+ export * from './ThemeUtils'
@@ -0,0 +1,4 @@
1
+ export function ViewBoolean(props) {
2
+ let {value} = props;
3
+ return value == null ? null : (value ? '是' : '否')
4
+ }
@@ -0,0 +1,3 @@
1
+ // 查看组件,主要是value 属性
2
+ export * from './ViewPassword';
3
+ export * from './ViewBoolean';
@@ -1,7 +1,7 @@
1
1
  import {matchRoutes, useAppData} from "umi";
2
2
  import React from "react";
3
3
  import {Result} from "antd";
4
- import {UrlUtil} from "../framework";
4
+ import {UrlUtils} from "../framework";
5
5
 
6
6
  /**
7
7
  * 通过指定 pathname 渲染页面
@@ -55,7 +55,7 @@ class _PageRender extends React.Component {
55
55
  const key = pathname.substring(1); // 移除第一个斜杠
56
56
  let componentType = map[key] || map[key + '/index']
57
57
  if (componentType) {
58
- let params =search ? UrlUtil.getParams(search): {}
58
+ let params =search ? UrlUtils.getParams(search): {}
59
59
  const location = {pathname, search, params}
60
60
  return React.createElement(componentType, {location});
61
61
  }