@jiangood/springboot-admin-starter 0.0.1

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 (213) hide show
  1. package/config/config.js +10 -0
  2. package/config/config.local.js +10 -0
  3. package/config/defaultConfig.js +35 -0
  4. package/config/plugins/forms.js +44 -0
  5. package/config/plugins/routes.js +82 -0
  6. package/package.json +41 -0
  7. package/src/.npmignore +6 -0
  8. package/src/app.js +0 -0
  9. package/src/asserts/login_bg.jpg +0 -0
  10. package/src/asserts/welcome.png +0 -0
  11. package/src/components/InstanceInfo.jsx +138 -0
  12. package/src/components/InstanceStatusInfo.jsx +79 -0
  13. package/src/components/StreamLog.jsx +27 -0
  14. package/src/components/flow/BpmnUtils.js +85 -0
  15. package/src/components/flow/customTranslate/customTranslate.js +19 -0
  16. package/src/components/flow/customTranslate/translations.js +79 -0
  17. package/src/components/flow/design/contextPad.js +50 -0
  18. package/src/components/flow/design/form/ConditionForm.jsx +316 -0
  19. package/src/components/flow/design/form/ServiceTaskForm.jsx +55 -0
  20. package/src/components/flow/design/form/TimerEventDefinitionForm.jsx +62 -0
  21. package/src/components/flow/design/form/UserTaskForm.jsx +211 -0
  22. package/src/components/flow/design/palette.js +39 -0
  23. package/src/components/monitor/AllDefinition.jsx +46 -0
  24. package/src/components/monitor/AllInstance.jsx +76 -0
  25. package/src/forms/demoForm.jsx +16 -0
  26. package/src/framework/components/ButtonList.d.ts +9 -0
  27. package/src/framework/components/ButtonList.jsx +91 -0
  28. package/src/framework/components/DownloadFileButton.d.ts +11 -0
  29. package/src/framework/components/DownloadFileButton.jsx +33 -0
  30. package/src/framework/components/Echarts/index.d.ts +10 -0
  31. package/src/framework/components/Echarts/index.jsx +49 -0
  32. package/src/framework/components/EditTable/index.d.ts +11 -0
  33. package/src/framework/components/EditTable/index.jsx +85 -0
  34. package/src/framework/components/EditTable/index.less +29 -0
  35. package/src/framework/components/Ellipsis.jsx +39 -0
  36. package/src/framework/components/Ellipsis.less +8 -0
  37. package/src/framework/components/FieldRemoteTree.jsx +20 -0
  38. package/src/framework/components/Gap/index.d.ts +10 -0
  39. package/src/framework/components/Gap/index.jsx +15 -0
  40. package/src/framework/components/Gap/index.less +3 -0
  41. package/src/framework/components/HasPerm.jsx +18 -0
  42. package/src/framework/components/ImageView.d.ts +12 -0
  43. package/src/framework/components/ImageView.jsx +64 -0
  44. package/src/framework/components/LinkButton.d.ts +14 -0
  45. package/src/framework/components/LinkButton.jsx +13 -0
  46. package/src/framework/components/MsgBox.jsx +180 -0
  47. package/src/framework/components/NamedIcon.tsx +15 -0
  48. package/src/framework/components/OrgTree.jsx +60 -0
  49. package/src/framework/components/Page/index.d.ts +10 -0
  50. package/src/framework/components/Page/index.jsx +30 -0
  51. package/src/framework/components/Page/index.less +10 -0
  52. package/src/framework/components/PageLoading.jsx +31 -0
  53. package/src/framework/components/Panel/index.d.ts +11 -0
  54. package/src/framework/components/Panel/index.jsx +24 -0
  55. package/src/framework/components/Panel/index.less +0 -0
  56. package/src/framework/components/ProModal/index.tsx +66 -0
  57. package/src/framework/components/ProTable/components/ToolBar/index.jsx +124 -0
  58. package/src/framework/components/ProTable/components/ToolBar/index.less +53 -0
  59. package/src/framework/components/ProTable/index.d.ts +38 -0
  60. package/src/framework/components/ProTable/index.jsx +258 -0
  61. package/src/framework/components/ProTable/index.less +3 -0
  62. package/src/framework/components/ProTable/utils/index.js +43 -0
  63. package/src/framework/components/RoleTree.jsx +53 -0
  64. package/src/framework/components/ValueType/index.jsx +34 -0
  65. package/src/framework/components/ValueType/registry.jsx +38 -0
  66. package/src/framework/components/field/FieldAutoTime/index.tsx +46 -0
  67. package/src/framework/components/field/FieldBoolean/index.tsx +92 -0
  68. package/src/framework/components/field/FieldEditTable/index.d.ts +13 -0
  69. package/src/framework/components/field/FieldEditTable/index.jsx +103 -0
  70. package/src/framework/components/field/FieldEditTable/index.less +29 -0
  71. package/src/framework/components/field/FieldEditor.jsx +48 -0
  72. package/src/framework/components/field/FieldFileBase64/index.d.ts +15 -0
  73. package/src/framework/components/field/FieldFileBase64/index.jsx +23 -0
  74. package/src/framework/components/field/FieldImageBase64/index.d.ts +15 -0
  75. package/src/framework/components/field/FieldImageBase64/index.jsx +22 -0
  76. package/src/framework/components/field/FieldInput.jsx +13 -0
  77. package/src/framework/components/field/FieldOrgTree/index.tsx +45 -0
  78. package/src/framework/components/field/FieldPassword.jsx +11 -0
  79. package/src/framework/components/field/FieldProps.ts +19 -0
  80. package/src/framework/components/field/FieldRemoteTreeCascader.jsx +75 -0
  81. package/src/framework/components/field/FieldRemoteTreeCheckable.jsx +81 -0
  82. package/src/framework/components/field/FieldRemoteTreeMultipleSelect.jsx +100 -0
  83. package/src/framework/components/field/FieldRemoteTreeSelect.jsx +82 -0
  84. package/src/framework/components/field/FieldSelectPosition/index.tsx +85 -0
  85. package/src/framework/components/field/FieldTree.jsx +45 -0
  86. package/src/framework/components/field/dict/index.tsx +110 -0
  87. package/src/framework/components/field/flat-multiple-select/index.d.ts +4 -0
  88. package/src/framework/components/field/flat-multiple-select/index.jsx +116 -0
  89. package/src/framework/components/field/flat-multiple-select/index.less +12 -0
  90. package/src/framework/components/field/flat-select/index.d.ts +4 -0
  91. package/src/framework/components/field/flat-select/index.jsx +107 -0
  92. package/src/framework/components/field/flat-select/index.less +12 -0
  93. package/src/framework/components/field/index.js +33 -0
  94. package/src/framework/components/field/input-number-percent/index.d.ts +11 -0
  95. package/src/framework/components/field/input-number-percent/index.jsx +28 -0
  96. package/src/framework/components/field/select/FieldSelect/index.d.ts +39 -0
  97. package/src/framework/components/field/select/FieldSelect/index.jsx +156 -0
  98. package/src/framework/components/field/select/FieldTableSelect/index.d.ts +29 -0
  99. package/src/framework/components/field/select/FieldTableSelect/index.jsx +155 -0
  100. package/src/framework/components/field/select/index.jsx +2 -0
  101. package/src/framework/components/field/switch-y-n/index.d.ts +11 -0
  102. package/src/framework/components/field/switch-y-n/index.jsx +31 -0
  103. package/src/framework/components/field/text/index.tsx +7 -0
  104. package/src/framework/components/field/time/DatePickerString.tsx +37 -0
  105. package/src/framework/components/field/time/DateTimePickerString.tsx +42 -0
  106. package/src/framework/components/field/time/FieldDateRange.d.ts +9 -0
  107. package/src/framework/components/field/time/FieldDateRange.jsx +49 -0
  108. package/src/framework/components/field/time/HHmmPickerString.tsx +42 -0
  109. package/src/framework/components/field/time/MonthPickerString.tsx +45 -0
  110. package/src/framework/components/field/time/TimePickerTool.ts +14 -0
  111. package/src/framework/components/field/time/YearPickerString.tsx +41 -0
  112. package/src/framework/components/field/time/YearQuarterString.tsx +38 -0
  113. package/src/framework/components/field/time/index.tsx +7 -0
  114. package/src/framework/components/field/upload/FieldUploadCropImage/index.d.ts +22 -0
  115. package/src/framework/components/field/upload/FieldUploadCropImage/index.jsx +11 -0
  116. package/src/framework/components/field/upload/FieldUploadFile.d.ts +35 -0
  117. package/src/framework/components/field/upload/FieldUploadFile.jsx +145 -0
  118. package/src/framework/components/field/upload/FieldUploadImage.d.ts +7 -0
  119. package/src/framework/components/field/upload/FieldUploadImage.jsx +16 -0
  120. package/src/framework/components/field/upload/index.jsx +3 -0
  121. package/src/framework/components/index.js +25 -0
  122. package/src/framework/components/system.jsx +29 -0
  123. package/src/framework/components/view/ViewBoolean.jsx +15 -0
  124. package/src/framework/components/view/ViewBooleanEnableDisable.jsx +16 -0
  125. package/src/framework/components/view/ViewEllipsis.d.ts +11 -0
  126. package/src/framework/components/view/ViewEllipsis.jsx +30 -0
  127. package/src/framework/components/view/ViewFile.d.ts +10 -0
  128. package/src/framework/components/view/ViewFile.jsx +50 -0
  129. package/src/framework/components/view/ViewFileButton.d.ts +10 -0
  130. package/src/framework/components/view/ViewFileButton.jsx +0 -0
  131. package/src/framework/components/view/ViewImage.d.ts +9 -0
  132. package/src/framework/components/view/ViewImage.jsx +61 -0
  133. package/src/framework/components/view/ViewPassword.jsx +24 -0
  134. package/src/framework/components/view/ViewRange/index.d.ts +16 -0
  135. package/src/framework/components/view/ViewRange/index.jsx +20 -0
  136. package/src/framework/components/view/ViewText.jsx +9 -0
  137. package/src/framework/components/view/index.js +12 -0
  138. package/src/framework/index.js +3 -0
  139. package/src/framework/system/FormRegistry.js +58 -0
  140. package/src/framework/system/dict.js +88 -0
  141. package/src/framework/system/http.jsx +290 -0
  142. package/src/framework/system/index.js +13 -0
  143. package/src/framework/system/page.js +109 -0
  144. package/src/framework/system/permission.js +44 -0
  145. package/src/framework/system/sys.js +60 -0
  146. package/src/framework/system/theme.js +17 -0
  147. package/src/framework/utils/arr.js +118 -0
  148. package/src/framework/utils/browser.js +24 -0
  149. package/src/framework/utils/color.js +269 -0
  150. package/src/framework/utils/date.js +173 -0
  151. package/src/framework/utils/debounce.js +33 -0
  152. package/src/framework/utils/dom.js +16 -0
  153. package/src/framework/utils/eventBus.js +70 -0
  154. package/src/framework/utils/html.js +13 -0
  155. package/src/framework/utils/index.js +17 -0
  156. package/src/framework/utils/obj.js +72 -0
  157. package/src/framework/utils/storage.js +37 -0
  158. package/src/framework/utils/str.js +297 -0
  159. package/src/framework/utils/tree.js +175 -0
  160. package/src/framework/utils/uid.js +76 -0
  161. package/src/framework/utils/url.js +84 -0
  162. package/src/framework/utils/validate.js +9 -0
  163. package/src/index.js +2 -0
  164. package/src/layouts/PageRender.d.ts +22 -0
  165. package/src/layouts/PageRender.jsx +90 -0
  166. package/src/layouts/admin/HeaderRight.jsx +104 -0
  167. package/src/layouts/admin/TabPageRender.jsx +158 -0
  168. package/src/layouts/admin/index.jsx +174 -0
  169. package/src/layouts/admin/index.less +64 -0
  170. package/src/layouts/index.jsx +163 -0
  171. package/src/layouts/index.less +45 -0
  172. package/src/loading.jsx +18 -0
  173. package/src/pages/404.jsx +13 -0
  174. package/src/pages/about.jsx +14 -0
  175. package/src/pages/api/accessLog/index.jsx +108 -0
  176. package/src/pages/api/accountResource/index.jsx +149 -0
  177. package/src/pages/api/doc.jsx +135 -0
  178. package/src/pages/api/index.jsx +163 -0
  179. package/src/pages/api/resource.jsx +18 -0
  180. package/src/pages/flowable/design/index.css +7 -0
  181. package/src/pages/flowable/design/index.jsx +297 -0
  182. package/src/pages/flowable/index.jsx +128 -0
  183. package/src/pages/flowable/instance/view.jsx +13 -0
  184. package/src/pages/flowable/monitor.jsx +106 -0
  185. package/src/pages/flowable/task/form.jsx +99 -0
  186. package/src/pages/flowable/task/index.jsx +200 -0
  187. package/src/pages/flowable/test/form.jsx +31 -0
  188. package/src/pages/flowable/test/index.jsx +54 -0
  189. package/src/pages/index.jsx +25 -0
  190. package/src/pages/job/index.jsx +239 -0
  191. package/src/pages/job/logList.jsx +100 -0
  192. package/src/pages/job/status.jsx +84 -0
  193. package/src/pages/login.jsx +144 -0
  194. package/src/pages/login.less +53 -0
  195. package/src/pages/system/config/index.jsx +136 -0
  196. package/src/pages/system/dict/Dict.jsx +73 -0
  197. package/src/pages/system/dict/DictItem.jsx +177 -0
  198. package/src/pages/system/dict/index.jsx +25 -0
  199. package/src/pages/system/file/index.jsx +152 -0
  200. package/src/pages/system/log/index.jsx +78 -0
  201. package/src/pages/system/org/index.jsx +263 -0
  202. package/src/pages/system/role/index.jsx +314 -0
  203. package/src/pages/system/role/perm.jsx +111 -0
  204. package/src/pages/system/sysManual/index.jsx +127 -0
  205. package/src/pages/system/user/UserPerm.jsx +132 -0
  206. package/src/pages/system/user/index.jsx +261 -0
  207. package/src/pages/test.jsx +16 -0
  208. package/src/pages/ureport/index.jsx +43 -0
  209. package/src/pages/userCenter/ChangePassword.jsx +64 -0
  210. package/src/pages/userCenter/index.jsx +90 -0
  211. package/src/pages/userCenter/manual.jsx +63 -0
  212. package/src/pages/userCenter/message.jsx +105 -0
  213. package/src/style/global.less +51 -0
@@ -0,0 +1,24 @@
1
+ import React from "react";
2
+ import {Space} from "antd";
3
+ import {EyeInvisibleOutlined, EyeOutlined} from "@ant-design/icons";
4
+
5
+ export class ViewPassword extends React.Component {
6
+
7
+ state = {
8
+ visible: false
9
+ }
10
+
11
+ render() {
12
+ let v = this.props.value;
13
+ if (v == null) {
14
+ return null
15
+ }
16
+ let visible = this.state.visible;
17
+ return <Space>
18
+ <span>{this.state.visible ? v : '******'}</span>
19
+ <a onClick={() => this.setState({visible: !visible})}>
20
+ {visible ? <EyeOutlined/> : <EyeInvisibleOutlined/>}
21
+ </a>
22
+ </Space>
23
+ }
24
+ }
@@ -0,0 +1,16 @@
1
+ // @ts-ignore
2
+ import React from "react";
3
+
4
+ declare type ViewRangeProps = {
5
+
6
+ min:any;
7
+ max:any;
8
+ };
9
+
10
+ /**
11
+ * 显示一个区间,如开始时间,结束时间
12
+ */
13
+ export class ViewRange extends React.Component<ViewRangeProps, any> {
14
+
15
+
16
+ }
@@ -0,0 +1,20 @@
1
+ import React from "react";
2
+
3
+ export class ViewRange extends React.Component {
4
+
5
+ static defaultProps = {
6
+ min : '未知',max : '未知'
7
+ }
8
+
9
+ render() {
10
+ let {min,max} = this.props
11
+ if(min == null && max == null){
12
+ return null;
13
+ }
14
+ min = min == null ? '未知': min;
15
+ max = max == null ? '未知': max;
16
+
17
+ return min + ' - ' + max;
18
+
19
+ }
20
+ }
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import {Typography} from "antd";
3
+
4
+ export class ViewText extends React.Component{
5
+
6
+ render() {
7
+ return <Typography.Text> {this.props.value}</Typography.Text>;
8
+ }
9
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 相对form,显示的是文本
3
+ * 统一有个值叫value
4
+ */
5
+ export * from './ViewEllipsis'
6
+ export * from './ViewBoolean'
7
+ export * from './ViewBooleanEnableDisable'
8
+ export * from './ViewImage'
9
+ export * from './ViewRange'
10
+ export * from './ViewFile'
11
+ export * from './ViewText'
12
+ export * from './ViewPassword'
@@ -0,0 +1,3 @@
1
+ export * from './components'
2
+ export * from './system'
3
+ export * from './utils'
@@ -0,0 +1,58 @@
1
+ class ReactFormRegistry {
2
+ constructor() {
3
+ this.forms = new Map(); // 存储 React 表单组件,key: 表单标识(如 'leave'),value: React 组件
4
+ }
5
+
6
+ /**
7
+ * 注册 React 表单组件
8
+ * @param {string} formKey - 表单唯一标识(如 'leave'、'expense')
9
+ * @param {React.Component} formComponent - React 表单组件
10
+ */
11
+ register(formKey, formComponent) {
12
+ if (!formKey || !formComponent) {
13
+ throw new Error("表单 Key 和组件不能为空!");
14
+ }
15
+ if (this.forms.has(formKey)) {
16
+ console.warn(`⚠️ 表单 "${formKey}" 已存在,将被覆盖!`);
17
+ }
18
+ this.forms.set(formKey, formComponent);
19
+ console.log(`✅ React 表单 "${formKey}" 注册成功`);
20
+ }
21
+
22
+ /**
23
+ * 获取 React 表单组件
24
+ * @param {string} formKey - 表单唯一标识
25
+ * @returns {React.Component|null} React 表单组件,如果不存在则返回 null
26
+ */
27
+ get(formKey) {
28
+ const formComponent = this.forms.get(formKey);
29
+ if (!formComponent) {
30
+ console.warn(`⚠️ React 表单 "${formKey}" 未注册!`);
31
+ }
32
+ return formComponent || null;
33
+ }
34
+
35
+ /**
36
+ * 检查表单是否已注册
37
+ * @param {string} formKey
38
+ * @returns {boolean}
39
+ */
40
+ has(formKey) {
41
+ return this.forms.has(formKey);
42
+ }
43
+
44
+ /**
45
+ * 获取所有已注册的表单 Key
46
+ * @returns {string[]}
47
+ */
48
+ getAllKeys() {
49
+ return Array.from(this.forms.keys());
50
+ }
51
+ }
52
+
53
+ // 创建全局单例(推荐)
54
+ const formRegistry = new ReactFormRegistry();
55
+
56
+ // 导出单例(项目里直接 import { reactFormRegistry } 使用)
57
+ export { formRegistry };
58
+
@@ -0,0 +1,88 @@
1
+ /***
2
+ *
3
+ * @param code
4
+ */
5
+ import {Tag} from 'antd';
6
+ import React from 'react';
7
+ import {SysUtil} from "./sys";
8
+ import {StrUtil} from "../utils";
9
+
10
+ // 根据字典类型code返回字典数据列表, code 支持 驼峰或下划线(都转为下划线比较)
11
+ export function dictList(code) {
12
+ const dictTypeTree = SysUtil.getDictInfo()
13
+ if (dictTypeTree === undefined) {
14
+ return [];
15
+ }
16
+
17
+ let filtered = dictTypeTree.filter((item) => {
18
+ return item.code === code || StrUtil.toUnderlineCase(item.code) === StrUtil.toUnderlineCase(code);
19
+ }
20
+ );
21
+
22
+ if (filtered.length === 0) {
23
+ console.log('字典' + code + '不存在,请刷新或在后台添加字典');
24
+ return [];
25
+ }
26
+ const tree = filtered[0].children;
27
+ if (tree === undefined) {
28
+ return [];
29
+ }
30
+ return tree;
31
+ }
32
+
33
+ export function dictMap(typeCode) {
34
+ const list = dictList(typeCode);
35
+
36
+ if (list == null) {
37
+ console.log('未找到数据字典, code=' + typeCode);
38
+ return {};
39
+ }
40
+ const map = {};
41
+ list.forEach((i) => {
42
+ const code = i.code;
43
+
44
+ // @ts-ignore
45
+ map[code] = i;
46
+ });
47
+
48
+ return map;
49
+ }
50
+
51
+ export function dictValue(typeCode, code) {
52
+ const item = dictData(typeCode, code);
53
+ if (item) {
54
+ return item.name;
55
+ }
56
+ }
57
+
58
+ export function dictValueTag(typeCode, dataCode) {
59
+ if (dataCode == null) {
60
+ return '';
61
+ }
62
+ const data = dictData(typeCode, dataCode);
63
+ if (data != null) {
64
+ const {name, color} = data;
65
+
66
+ if (color == null) {
67
+ return name;
68
+ }
69
+
70
+ // js 方式创建 ,等同于 <Tag color={color}>{name}</Tag>
71
+ return React.createElement(Tag, {color: color}, name);
72
+ }
73
+ return '';
74
+ }
75
+
76
+ export function dictData(typeCode, code) {
77
+ if (code == null) {
78
+ return null;
79
+ }
80
+ const map = dictMap(typeCode);
81
+ // @ts-ignore
82
+ let item = map[code];
83
+ if (item == null) {
84
+ // @ts-ignore
85
+ item = map[code + ''];
86
+ }
87
+ return item;
88
+ }
@@ -0,0 +1,290 @@
1
+ import axios from "axios";
2
+ import {message as messageUtil, Modal} from "antd";
3
+ import {SysUtil} from "./sys";
4
+ import qs from 'qs'
5
+ import {MsgBox} from "../components";
6
+ import {PageUtil} from "./page";
7
+
8
+
9
+ export const HttpUtil = {
10
+
11
+ create() {
12
+ return new Util();
13
+ },
14
+
15
+
16
+ get(url, params = null) {
17
+ const util = new Util();
18
+ util.enableShowMessage()
19
+ util.enableTransformData()
20
+ return util.get(url, params)
21
+ },
22
+
23
+ post(url, data = null, params = null) {
24
+ const util = new Util();
25
+ util.enableShowMessage()
26
+ util.enableTransformData()
27
+
28
+ return util.post(url, data, params)
29
+ },
30
+
31
+
32
+ postForm(url, data) {
33
+ console.warn('不推荐调用本方法,设计urlEncode等,对于特殊字符可能会有问题')
34
+ const util = new Util();
35
+ util.enableShowMessage()
36
+ util.enableTransformData()
37
+
38
+ let config = {
39
+ url,
40
+ method: 'POST',
41
+ data,
42
+ headers: {
43
+ 'Content-Type': 'application/x-www-form-urlencoded'
44
+ },
45
+ };
46
+
47
+ return util.request(config)
48
+ },
49
+
50
+ /**
51
+ * 分页请求, 为antd的ProTable
52
+ */
53
+ pageData(url, params) {
54
+ const { _exportType, ...data} = params || {};
55
+
56
+ if (_exportType) {
57
+ return this.downloadFileGet(url, data, {'X-Export-Type': _exportType})
58
+ }
59
+
60
+ return this.get(url, data)
61
+ },
62
+ /**
63
+ * 下载
64
+ * @deprecated
65
+ */
66
+ downloadFile(url, params, method = 'GET') {
67
+ const util = new Util();
68
+ util.enableShowMessage()
69
+
70
+ const get = method === 'GET';
71
+ if (get) {
72
+ return this.downloadFileGet(url, params)
73
+ }
74
+
75
+ return this.downloadFilePost(url, params)
76
+ },
77
+
78
+ downloadFilePost(url, data, params, headers) {
79
+ const util = new Util();
80
+ util.enableShowMessage()
81
+ return util.downloadFile(url, data, params, 'POST', headers)
82
+ },
83
+ downloadFileGet(url, params,headers) {
84
+ const util = new Util();
85
+ util.enableShowMessage()
86
+ return util.downloadFile(url, null, params, 'GET',headers)
87
+ }
88
+ }
89
+
90
+ class Util {
91
+ _showLoading = false
92
+
93
+ // 请求成功结果,返回data那一层(忽略 success,code )
94
+ _transformData = false
95
+
96
+ // 自动显示成功消息(message)、失败消息(modal)
97
+ _showMessage = false
98
+
99
+ request = config => {
100
+ const defaultConfig = {
101
+ withCredentials: true, // 带cookie
102
+ baseURL: SysUtil.getServerUrl(),
103
+ headers: {
104
+ 'Content-Type': 'application/json'
105
+ },
106
+ paramsSerializer: params => {
107
+ return qs.stringify(params, { indices: false })
108
+ }
109
+ }
110
+
111
+
112
+ let finalConfig = Object.assign({}, defaultConfig, config);
113
+
114
+ const {...axiosConfig} = finalConfig
115
+
116
+ if (axiosConfig.url.startsWith("//")) {
117
+ axiosConfig.url = axiosConfig.url.substring(1)
118
+ }
119
+
120
+
121
+ return new Promise((resolve, reject) => {
122
+ let hideLoading = null
123
+ if (this._showLoading) {
124
+ hideLoading = messageUtil.loading('处理中...', 0)
125
+ }
126
+
127
+ axios(axiosConfig).then(response => {
128
+ const body = response.data;
129
+ const {success, message, data, code} = body;
130
+
131
+ if (this._showMessage && success != null && message) { // 有可能是下载
132
+ if (success) {
133
+ messageUtil.success(message)
134
+ } else {
135
+ messageUtil.error(message)
136
+ }
137
+ }
138
+
139
+ if (!this._transformData) {
140
+ resolve(response);
141
+ return;
142
+ }
143
+
144
+
145
+ if (success == null) { // 返回结果没有success标志,则原样
146
+ resolve(body);
147
+ return
148
+ }
149
+
150
+ if (success) {
151
+ resolve(data)
152
+ } else {
153
+ reject(message)
154
+ }
155
+
156
+
157
+ }).catch(e => {
158
+ if (!this._showMessage) {
159
+ reject(e)
160
+ return
161
+ }
162
+ let title = "请求异常";
163
+ let msg = '操作失败';
164
+
165
+ if(e.status === 401){
166
+ MsgBox.confirm('登录已过期,请重新登录').then(rs=>{
167
+ PageUtil.redirectToLogin()
168
+ })
169
+ return;
170
+ }
171
+
172
+ if(e.status === 504){
173
+ msg = '504 请求后端服务失败'
174
+ }else {
175
+ if (e.response && e.response.data) {
176
+ const rs = e.response.data
177
+ msg = rs.message
178
+ }
179
+ if (msg == null && e.message) {
180
+ msg = e.message
181
+ }
182
+ }
183
+
184
+ messageUtil.error(msg)
185
+
186
+
187
+ reject(e)
188
+ }).finally(() => {
189
+ if (hideLoading) {
190
+ hideLoading()
191
+ }
192
+
193
+ })
194
+ })
195
+
196
+ };
197
+
198
+
199
+ get(url, params = null) {
200
+ let config = {
201
+ url,
202
+ method: 'GET',
203
+ params,
204
+ };
205
+
206
+ return this.request(config)
207
+ }
208
+
209
+ post(url, data, params = null) {
210
+ let config = {
211
+ url,
212
+ method: 'POST',
213
+ params,
214
+ data,
215
+ };
216
+
217
+ return this.request(config)
218
+ }
219
+
220
+ downloadFile(url, data, params, method = 'GET', headers = {}) {
221
+ let config = {
222
+ url,
223
+ params,
224
+ method,
225
+ responseType: 'blob',
226
+ data,
227
+ headers
228
+ };
229
+
230
+
231
+ return this.request(config).then(res => {
232
+ const {data: blob, headers} = res
233
+ if (blob.type === 'application/json') {// 可能是错误了,否则不应该返回json
234
+ const reader = new FileReader();
235
+ reader.readAsText(blob, 'utf-8');
236
+ reader.onload = function (e) {
237
+ let rs = JSON.parse(reader.result);
238
+ Modal.error({
239
+ title: '下载文件失败',
240
+ content: rs.message || '不支持下载'
241
+ })
242
+ }
243
+ return;
244
+ }
245
+
246
+ // 获取文件名称
247
+ const contentDisposition = headers.get('content-disposition');
248
+ if (contentDisposition == null) {
249
+ Modal.error({
250
+ title: '获取文件名称失败',
251
+ content: "缺少content-disposition响应头"
252
+ })
253
+ return
254
+ }
255
+
256
+
257
+ let regExp = new RegExp('filename=(.*)');
258
+ const result = regExp.exec(contentDisposition);
259
+ let filename = result[1];
260
+
261
+ filename = decodeURIComponent(filename);
262
+ filename = filename.replaceAll('"', '');
263
+ filename = filename.replace(/^["](.*)["]$/g, '$1')
264
+
265
+
266
+ const url = window.URL.createObjectURL(new Blob([blob]));
267
+ const link = document.createElement('a');
268
+ link.style.display = 'none';
269
+
270
+ link.href = url;
271
+ link.download = decodeURI(filename); // 下载后文件名
272
+
273
+ document.body.appendChild(link);
274
+ link.click();
275
+
276
+ document.body.removeChild(link); // 下载完成移除元素
277
+ window.URL.revokeObjectURL(url);
278
+ })
279
+
280
+ }
281
+ enableShowMessage() {
282
+ this._showMessage = true
283
+ return this
284
+ }
285
+
286
+ enableTransformData() {
287
+ this._transformData = true
288
+ return this
289
+ }
290
+ }
@@ -0,0 +1,13 @@
1
+ export * from './page'
2
+ export * from './dict'
3
+ export * from './permission'
4
+
5
+
6
+ export * from './page'
7
+
8
+
9
+ export * from "./sys"
10
+
11
+ export * from './http'
12
+ export * from './FormRegistry'
13
+ export * from './theme'
@@ -0,0 +1,109 @@
1
+ import {history} from "umi";
2
+ import {StrUtil, UrlUtil} from "../utils";
3
+
4
+ export class PageUtil {
5
+
6
+ static redirectToLogin(){
7
+ let url = PageUtil.currentUrl();
8
+ url =encodeURIComponent(url)
9
+ history.push('/login?redirect='+ url)
10
+ }
11
+
12
+ /**
13
+ * @deprecated
14
+ * @returns {{}}
15
+ */
16
+ static currentLocationQuery() {
17
+ return this.currentParams()
18
+ }
19
+
20
+ static currentParams(){
21
+ let url = window.location.href
22
+
23
+
24
+ let hasQuery = url.indexOf('?') > 0
25
+ if (!hasQuery) {
26
+ return {}
27
+ }
28
+
29
+ const search = url.substring(url.indexOf('?') + 1);
30
+ const kvs = search.split('&')
31
+
32
+ const rs = {}
33
+ for (let kv of kvs) {
34
+ const kvArr = kv.split('=')
35
+ const k = kvArr[0];
36
+ let v = kvArr[1];
37
+ if(v){
38
+ v = decodeURI(v)
39
+ }
40
+ rs[k] = v;
41
+ }
42
+
43
+ return rs
44
+ }
45
+
46
+ //"http://localhost:8000/#/login?id=1"
47
+ // 返回不带参的路径
48
+ static currentPathname() {
49
+ let path = window.location.hash.substring(1);
50
+ return StrUtil.subBefore(path, '?')
51
+ }
52
+
53
+ /**
54
+ * @deprecated
55
+ * @returns {{}}
56
+ */
57
+ static currentPath() {
58
+ let path = window.location.hash.substring(1);
59
+ return path
60
+ }
61
+
62
+ /**
63
+ * hash后的路径
64
+ * @returns {string}
65
+ */
66
+ static currentUrl() {
67
+ let path = window.location.hash.substring(1);
68
+ return path
69
+ }
70
+
71
+ /**
72
+ * 当前路由的最后一个斜杠后面的单词, 通常用于基于路径的路由
73
+ * @returns {string|null}
74
+ */
75
+ static currentPathnameLastPart() {
76
+ const path = this.currentPathname()
77
+ return StrUtil.subAfterLast(path, '/')
78
+ }
79
+
80
+ static open(path,label) {
81
+ if(label) {
82
+ path = UrlUtil.setParam(path,'_label', label)
83
+ }
84
+ history.push(path)
85
+ }
86
+
87
+ /**
88
+ * 打开一个不带菜单,header的页面
89
+ * @param path
90
+ */
91
+ static openNoLayout(path) {
92
+ path = UrlUtil.setParam(path,'_noLayout', true)
93
+
94
+ history.push(path)
95
+ }
96
+
97
+
98
+ static currentLabel(){
99
+ return this.currentParams()['_label']
100
+ }
101
+
102
+ static closeCurrent(){
103
+ const event = new CustomEvent('close-page-event', {
104
+ detail: { url: PageUtil.currentUrl() }
105
+ });
106
+ document.dispatchEvent(event)
107
+ }
108
+
109
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * 控制按钮是否显示
3
+ */
4
+ import {SysUtil} from "./sys";
5
+ import {ArrUtil} from "../utils";
6
+
7
+
8
+ export const PermUtil = {
9
+
10
+ /**
11
+ * 是否拥有权限
12
+ * @param perm 权限码
13
+ */
14
+ hasPermission(perm) {
15
+ if (perm === null || perm === '') {
16
+ return false;
17
+ }
18
+
19
+ const info = SysUtil.getLoginInfo();
20
+ const { permissions } = info;
21
+ if(permissions == null || permissions.length === 0){
22
+ return false
23
+ }
24
+
25
+ if (ArrUtil.contains(permissions,"*")) {
26
+ return true;
27
+ }
28
+
29
+ return permissions.indexOf(perm) > -1;
30
+ },
31
+
32
+ /**
33
+ * 是否授权, 同 hasPermission
34
+ * @param p
35
+ * @returns {boolean}
36
+ */
37
+ isPermitted(p){
38
+ return PermUtil.hasPermission(p)
39
+ },
40
+ notPermitted(p){
41
+ !PermUtil.isPermitted(p)
42
+ }
43
+
44
+ }