@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,76 @@
1
+ /**
2
+ * Based on the work of https://github.com/jchook/uuid-random
3
+ */
4
+
5
+ let
6
+ buf,
7
+ bufIdx = 0
8
+ const hexBytes = new Array(256)
9
+
10
+ // Pre-calculate toString(16) for speed
11
+ for (let i = 0; i < 256; i++) {
12
+ hexBytes[ i ] = (i + 0x100).toString(16).substring(1)
13
+ }
14
+
15
+ // Use best available PRNG
16
+ const randomBytes = (() => {
17
+ // Node & Browser support
18
+ const lib = typeof crypto !== 'undefined'
19
+ ? crypto
20
+ : (
21
+ typeof window !== 'undefined'
22
+ ? window.crypto || window.msCrypto
23
+ : void 0
24
+ )
25
+
26
+ if (lib !== void 0) {
27
+ if (lib.randomBytes !== void 0) {
28
+ return lib.randomBytes
29
+ }
30
+ if (lib.getRandomValues !== void 0) {
31
+ return n => {
32
+ const bytes = new Uint8Array(n)
33
+ lib.getRandomValues(bytes)
34
+ return bytes
35
+ }
36
+ }
37
+ }
38
+
39
+ return n => {
40
+ const r = []
41
+ for (let i = n; i > 0; i--) {
42
+ r.push(Math.floor(Math.random() * 256))
43
+ }
44
+ return r
45
+ }
46
+ })()
47
+
48
+ // Buffer random numbers for speed
49
+ // Reduce memory usage by decreasing this number (min 16)
50
+ // or improve speed by increasing this number (try 16384)
51
+ const BUFFER_SIZE = 4096
52
+
53
+
54
+
55
+ export const UidUtil = {
56
+ uid () {
57
+ // Buffer some random bytes for speed
58
+ if (buf === void 0 || (bufIdx + 16 > BUFFER_SIZE)) {
59
+ bufIdx = 0
60
+ buf = randomBytes(BUFFER_SIZE)
61
+ }
62
+
63
+ const b = Array.prototype.slice.call(buf, bufIdx, (bufIdx += 16))
64
+ b[ 6 ] = (b[ 6 ] & 0x0f) | 0x40
65
+ b[ 8 ] = (b[ 8 ] & 0x3f) | 0x80
66
+
67
+ return hexBytes[ b[ 0 ] ] + hexBytes[ b[ 1 ] ]
68
+ + hexBytes[ b[ 2 ] ] + hexBytes[ b[ 3 ] ] + '-'
69
+ + hexBytes[ b[ 4 ] ] + hexBytes[ b[ 5 ] ] + '-'
70
+ + hexBytes[ b[ 6 ] ] + hexBytes[ b[ 7 ] ] + '-'
71
+ + hexBytes[ b[ 8 ] ] + hexBytes[ b[ 9 ] ] + '-'
72
+ + hexBytes[ b[ 10 ] ] + hexBytes[ b[ 11 ] ]
73
+ + hexBytes[ b[ 12 ] ] + hexBytes[ b[ 13 ] ]
74
+ + hexBytes[ b[ 14 ] ] + hexBytes[ b[ 15 ] ]
75
+ }
76
+ }
@@ -0,0 +1,84 @@
1
+ import {StrUtil} from "./str";
2
+
3
+ export const UrlUtil = {
4
+ /**
5
+ * 获取url的参数, 如果不传参数,则使用当前路径
6
+ * @param url 字符串
7
+ */
8
+ getParams(url = null) {
9
+ if (!url) {
10
+ url = location.href
11
+ }
12
+
13
+ if (!StrUtil.contains(url, '?')) {
14
+ return {}
15
+ }
16
+
17
+ const search = StrUtil.subAfter(url, '?')
18
+
19
+
20
+ const params = new URLSearchParams(search);
21
+
22
+ const result = {}
23
+ for (const [key, value] of params.entries()) {
24
+ result[key] = value;
25
+ }
26
+
27
+ return result
28
+ },
29
+
30
+ /**
31
+ * 去掉参数的基础url
32
+ * @param url
33
+ */
34
+ getPathname(url) {
35
+ if (!url) {
36
+ return null
37
+ }
38
+
39
+ return StrUtil.subBefore(url, '?')
40
+ },
41
+
42
+
43
+ /**
44
+ * 将参数对象转换为 url中的
45
+ * @param params
46
+ */
47
+ paramsToSearch(params) {
48
+ if (!params) {
49
+ return "";
50
+ }
51
+ const buffer = []
52
+ for (let k in params) {
53
+ let v = params[k]
54
+ buffer.push(k + '=' + v);
55
+ }
56
+ return buffer.join('&')
57
+ },
58
+
59
+ setParam(url, key, value) {
60
+ const p = this.getParams(url)
61
+ p[key] = value;
62
+ if (value == null) {
63
+ delete p[key]
64
+ }
65
+ return this.getPathname(url) + '?' + this.paramsToSearch(p);
66
+ },
67
+
68
+ /**
69
+ * @deprecated
70
+ * @param url
71
+ * @param key
72
+ * @param value
73
+ */
74
+ replaceParam(url, key, value) {
75
+ this.setParam(url, key, value)
76
+ },
77
+
78
+ join(path1, path2) {
79
+ path1 = StrUtil.removeSuffix(path1,"/")
80
+ path2 = StrUtil.removePrefix(path2,"/")
81
+ let path = path1 + "/" + path2;
82
+ return path;
83
+ }
84
+ }
@@ -0,0 +1,9 @@
1
+
2
+ export const ValidateUtil = {
3
+ isEmail(emailStr) {
4
+ const reg = /^([\w+\.])+@\w+([.]\w+)+$/;
5
+ return reg.test(emailStr)
6
+ }
7
+ }
8
+
9
+
package/src/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./layouts"
2
+ export * from "./framework"
@@ -0,0 +1,22 @@
1
+ // @ts-ignore
2
+ import React from "react";
3
+
4
+ declare type PageRenderProps = {
5
+
6
+ /**
7
+ * 路径 如 /flowable/task/form
8
+ */
9
+ pathname: string;
10
+ /***
11
+ * 搜索参数 如 /?id=1
12
+ */
13
+ search?:string;
14
+
15
+ /***
16
+ * 是否把location信息透传到真正页面
17
+ */
18
+ passLocation?: boolean
19
+ };
20
+
21
+ export class PageRender extends React.Component<PageRenderProps, any> {
22
+ }
@@ -0,0 +1,90 @@
1
+ import {matchRoutes, useAppData} from "umi";
2
+ import React from "react";
3
+ import {Result} from "antd";
4
+ import {UrlUtil} from "../framework";
5
+
6
+ /**
7
+ * 通过指定 pathname 渲染页面
8
+ * @param props
9
+ * 为了规范,接收参数何router保持一致,
10
+ * pathname: 路径 如 /flowable/task/form
11
+ * search:搜索参数 如 /?id=1
12
+ *
13
+ * passLocation: 是否把location信息透传到真正页面
14
+ *
15
+ * @returns {React.JSX.Element|*}
16
+ * @constructor
17
+ */
18
+
19
+ let APP_DATA_CACHE = null
20
+
21
+
22
+ /**
23
+ * 写函数组件主要为了使用hooks
24
+ * @param props
25
+ * @returns {Element}
26
+ * @constructor
27
+ */
28
+ export function PageRender(props) {
29
+ let {pathname, search, passLocation} = props
30
+
31
+ let appData = useAppData()
32
+ if(Object.keys(appData).length === 0){
33
+ appData = APP_DATA_CACHE
34
+ }else {
35
+ APP_DATA_CACHE = appData;
36
+ }
37
+
38
+ return <_PageRender appData={appData} pathname={pathname} search={search}
39
+ passLocation={passLocation}/>
40
+ }
41
+
42
+ class _PageRender extends React.Component {
43
+
44
+ render() {
45
+ if (this.props.passLocation) {
46
+ return this.passLocationRender()
47
+ }
48
+ return this.defaultRender()
49
+ }
50
+
51
+ passLocationRender = () => {
52
+ let {pathname, search, appData} = this.props
53
+
54
+ const map = appData.routeComponents
55
+ const key = pathname.substring(1); // 移除第一个斜杠
56
+ let componentType = map[key] || map[key + '/index']
57
+ if (componentType) {
58
+ let params =search ? UrlUtil.getParams(search): {}
59
+ const location = {pathname, search, params}
60
+ return React.createElement(componentType, {location});
61
+ }
62
+ };
63
+
64
+
65
+ defaultRender = () => {
66
+ let {pathname, appData} = this.props
67
+ let matchArr = matchRoutes(appData.clientRoutes, pathname)
68
+
69
+ if (matchArr != null) {
70
+ if (pathname === '/') {
71
+ // 匹配结果为1,表示未定义index.jsx ,导致死循环
72
+ if (matchArr.length === 1) { // 如果项目中没有定义index.jsx
73
+ return <Result icon={null} title='未定义首页'></Result>
74
+ }
75
+ }
76
+ // 取最匹配的那个
77
+ const mathResult = matchArr[matchArr.length - 1].route
78
+ if(mathResult){
79
+ return mathResult.element;
80
+ }
81
+ }
82
+
83
+ // 如果实在找不到页面组件,则404
84
+ return <Result
85
+ status={404}
86
+ title='页面不存在!'
87
+ subTitle={<div>路由地址:{pathname}</div>}
88
+ />
89
+ };
90
+ }
@@ -0,0 +1,104 @@
1
+ import {Badge, Dropdown} from "antd";
2
+ import {NotificationOutlined, QuestionCircleOutlined, SettingOutlined, UserOutlined} from "@ant-design/icons";
3
+ import React from "react";
4
+ import {history} from "umi";
5
+ import {HttpUtil, isMobileDevice, MsgBox, PageUtil, SysUtil} from "../../framework";
6
+
7
+
8
+ const ID = 'header-right';
9
+ export default class HeaderRight extends React.Component {
10
+
11
+ state = {
12
+ isMobileDevice: false
13
+ };
14
+
15
+ componentDidMount() {
16
+ document.dispatchEvent(new CustomEvent('componentDidMount', {detail: ID}))
17
+ if (isMobileDevice()) {
18
+ this.setState({isMobileDevice: true})
19
+ }
20
+ }
21
+
22
+
23
+
24
+ logout = () => {
25
+ HttpUtil.post('admin/auth/logout').then(async () => {
26
+ localStorage.clear()
27
+ await MsgBox.alert('退出登录成功');
28
+ history.replace('/login')
29
+ }).catch(async e => {
30
+ let confirm = await MsgBox.confirm('退出登录失败,是否清空缓存');
31
+ if (confirm) {
32
+ localStorage.clear();
33
+ history.replace('/login')
34
+ }
35
+ })
36
+ }
37
+
38
+ userCenter = () => {
39
+ PageUtil.open('/userCenter', '个人中心')
40
+ }
41
+
42
+ render() {
43
+ const info = SysUtil.getLoginInfo()
44
+
45
+ if (this.state.isMobileDevice) {
46
+ return <div className='header-right'>
47
+ <a onClick={this.logout}>退出</a>
48
+ </div>
49
+ }
50
+
51
+ return <div className='header-right'>
52
+
53
+ <div className='item'>
54
+ <UserOutlined/> {info.name}
55
+ </div>
56
+
57
+
58
+ <div className='item' onClick={() => PageUtil.open('/userCenter/message', '我的消息')}>
59
+ <Badge count={info.messageCount} size="small">
60
+ <NotificationOutlined/>
61
+ </Badge>
62
+ </div>
63
+
64
+ <div className='item' title='操作手册' onClick={() => PageUtil.open('/userCenter/manual', '操作手册')}>
65
+ <QuestionCircleOutlined/>
66
+ </div>
67
+
68
+
69
+ <div className='item'>
70
+
71
+ <Dropdown menu={{
72
+ onClick: ({key}) => {
73
+ switch (key) {
74
+ case 'userCenter':
75
+ this.userCenter()
76
+ break;
77
+ case 'logout':
78
+ this.logout();
79
+ break;
80
+ case 'about':
81
+ this.about()
82
+ break
83
+ }
84
+ },
85
+ items: [
86
+ {key: 'userCenter', label: '个人中心'},
87
+ {key: 'about', label: '关于系统'},
88
+ {key: 'logout', label: '退出登录'},
89
+
90
+ ]
91
+ }}><SettingOutlined/>
92
+
93
+ </Dropdown>
94
+
95
+ </div>
96
+
97
+ </div>
98
+ }
99
+
100
+
101
+ about = () => {
102
+ history.push("/about")
103
+ }
104
+ }
@@ -0,0 +1,158 @@
1
+ import React from "react";
2
+ import {withRouter} from "umi";
3
+ import {Tabs} from "antd";
4
+ import {PageRender} from "../PageRender";
5
+ import {PageUtil} from "../../framework";
6
+
7
+ class TabPageRender extends React.Component {
8
+
9
+ state = {
10
+ active: null,
11
+ urlLabelMap: {},
12
+ tabs: [],
13
+ }
14
+
15
+ componentDidMount() {
16
+ const url = this.getUrl(this.props)
17
+ this.onUrlChange(url);
18
+
19
+ document.addEventListener('close-page-event', (e)=>{
20
+ const url = e.detail.url
21
+ this.onRemove(url)
22
+ })
23
+ }
24
+
25
+ componentDidUpdate(prevProps, prevState, snapshot) {
26
+ const url = this.getUrl(this.props)
27
+ const pUrl = this.getUrl(prevProps)
28
+
29
+ if (url !== pUrl) {
30
+ this.onUrlChange(url);
31
+ }
32
+ }
33
+
34
+ onUrlChange = url => {
35
+ const {location} = this.props
36
+
37
+ const {pathname, search} = location
38
+ let {tabs} = this.state
39
+
40
+ const old = tabs.find(t => t.key === url)
41
+ if (old == null) {
42
+ const cmp = <PageRender pathname={pathname} search={search}/>
43
+ let label = this.getLabel(pathname);
44
+ tabs.push({
45
+ key: url,
46
+ label: label,
47
+ children: cmp
48
+ });
49
+ this.setState({tabs: [...tabs]})
50
+ }else {
51
+ const menu = this.props.pathMenuMap[pathname]
52
+ if (menu && menu.refreshOnTabClick) {
53
+ this.refresh(pathname)
54
+ }
55
+ }
56
+
57
+ this.setState({active: url})
58
+ };
59
+
60
+ getLabel(path) {
61
+ if (path === '/') {
62
+ return '首页'
63
+ }
64
+ let label = PageUtil.currentLabel();
65
+
66
+ if (!label) {
67
+ const menu = this.props.pathMenuMap[path]
68
+ if (menu) {
69
+ return menu.name
70
+ }
71
+ }
72
+
73
+ return label;
74
+ }
75
+
76
+
77
+ render() {
78
+ let {tabs} = this.state
79
+ if (tabs.length === 0) {
80
+ return null
81
+ }
82
+
83
+ return <>
84
+ <Tabs
85
+ items={tabs}
86
+ activeKey={this.state.active}
87
+ onChange={this.onChange}
88
+ onEdit={this.onRemove}
89
+
90
+ hideAdd
91
+ size='small'
92
+ type='editable-card'
93
+ style={{background: 'white'}}
94
+ rootClassName='tmgg-layout-tabs'
95
+
96
+ onTabClick={this.onTabClick}
97
+
98
+ >
99
+ </Tabs>
100
+ </>
101
+ }
102
+
103
+ lastTabClickTime = 0
104
+ onTabClick = (key, event) => {
105
+ let now = new Date().getTime();
106
+ let doubleClick = now - this.lastTabClickTime < 300;
107
+ // 双击时刷新
108
+ if (doubleClick) {
109
+ this.refresh(key);
110
+ }
111
+
112
+ this.lastTabClickTime = now
113
+ };
114
+
115
+ refresh = key => {
116
+ const tabs = this.state.tabs;
117
+ const tab = tabs.find(t => t.key === key)
118
+ if(tab != null){
119
+ const old = tab.children
120
+ if(old != null){
121
+ console.log('准备刷新:', key)
122
+ tab.children = '刷新中...'
123
+ this.setState({tabs}, () => {
124
+ console.log('刷新节点', tab)
125
+ tab.children = old
126
+ this.setState({tabs})
127
+ })
128
+ }
129
+ }
130
+ };
131
+
132
+ onChange = url => {
133
+ if (url !== this.state.active) {
134
+ this.props.history.push(url)
135
+ }
136
+ };
137
+
138
+ onRemove = url => {
139
+ let {tabs} = this.state
140
+ tabs = tabs.filter(t => t.key !== url)
141
+
142
+ this.setState({tabs})
143
+ if (tabs.length > 0) {
144
+ this.setState({active: tabs[tabs.length - 1].key})
145
+ }
146
+ };
147
+
148
+ getUrl = props => {
149
+ const {location} = props
150
+ const {pathname, search} = location
151
+ return pathname + search;
152
+ }
153
+
154
+ }
155
+
156
+
157
+ // 让组件有路由相关的参数,如 this.props.location
158
+ export default withRouter(TabPageRender)