@jiangood/open-admin 1.0.0-beta.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 (186) hide show
  1. package/config/common-plugin.js +94 -0
  2. package/config/config.js +58 -0
  3. package/config/utils.js +73 -0
  4. package/package.json +42 -0
  5. package/src/.umi-production/appData.json +2365 -0
  6. package/src/.umi-production/core/EmptyRoute.tsx +9 -0
  7. package/src/.umi-production/core/defineApp.ts +16 -0
  8. package/src/.umi-production/core/helmet.ts +10 -0
  9. package/src/.umi-production/core/helmetContext.ts +4 -0
  10. package/src/.umi-production/core/history.ts +72 -0
  11. package/src/.umi-production/core/historyIntelli.ts +132 -0
  12. package/src/.umi-production/core/plugin.ts +40 -0
  13. package/src/.umi-production/core/pluginConfig.ts +324 -0
  14. package/src/.umi-production/core/pluginConfigJoi.d.ts +7 -0
  15. package/src/.umi-production/core/polyfill.ts +220 -0
  16. package/src/.umi-production/core/route.tsx +54 -0
  17. package/src/.umi-production/core/routeProps.js +5 -0
  18. package/src/.umi-production/core/routeProps.ts +6 -0
  19. package/src/.umi-production/core/terminal.ts +37 -0
  20. package/src/.umi-production/exports.ts +17 -0
  21. package/src/.umi-production/testBrowser.tsx +90 -0
  22. package/src/.umi-production/tsconfig.json +44 -0
  23. package/src/.umi-production/typings.d.ts +136 -0
  24. package/src/.umi-production/umi.ts +83 -0
  25. package/src/framework/components/DownloadFileButton/index.d.ts +11 -0
  26. package/src/framework/components/DownloadFileButton/index.jsx +33 -0
  27. package/src/framework/components/Gap/index.d.ts +23 -0
  28. package/src/framework/components/Gap/index.jsx +46 -0
  29. package/src/framework/components/LinkButton/index.d.ts +14 -0
  30. package/src/framework/components/LinkButton/index.jsx +10 -0
  31. package/src/framework/components/NamedIcon/index.d.ts +5 -0
  32. package/src/framework/components/NamedIcon/index.jsx +11 -0
  33. package/src/framework/components/OrgTree/index.d.ts +4 -0
  34. package/src/framework/components/OrgTree/index.jsx +58 -0
  35. package/src/framework/components/Page/index.d.ts +17 -0
  36. package/src/framework/components/Page/index.jsx +30 -0
  37. package/src/framework/components/Page/index.less +10 -0
  38. package/src/framework/components/PageLoading/index.d.ts +1 -0
  39. package/src/framework/components/PageLoading/index.jsx +25 -0
  40. package/src/framework/components/ProModal/index.tsx +66 -0
  41. package/src/framework/components/ProTable/components/ToolBar/index.jsx +123 -0
  42. package/src/framework/components/ProTable/components/ToolBar/index.less +53 -0
  43. package/src/framework/components/ProTable/index.d.ts +42 -0
  44. package/src/framework/components/ProTable/index.jsx +260 -0
  45. package/src/framework/components/ProTable/index.less +14 -0
  46. package/src/framework/components/ProTable/utils/index.js +43 -0
  47. package/src/framework/components/RoleTree/index.d.ts +4 -0
  48. package/src/framework/components/RoleTree/index.jsx +50 -0
  49. package/src/framework/components/ValueType/index.jsx +34 -0
  50. package/src/framework/components/ValueType/registry.jsx +26 -0
  51. package/src/framework/components/ViewRange/index.d.ts +14 -0
  52. package/src/framework/components/ViewRange/index.jsx +20 -0
  53. package/src/framework/components/index.ts +13 -0
  54. package/src/framework/components/system/ButtonList.d.ts +8 -0
  55. package/src/framework/components/system/ButtonList.jsx +42 -0
  56. package/src/framework/components/system/HasPerm.tsx +14 -0
  57. package/src/framework/components/system/index.tsx +29 -0
  58. package/src/framework/fields/FieldBoolean/index.d.ts +9 -0
  59. package/src/framework/fields/FieldBoolean/index.jsx +73 -0
  60. package/src/framework/fields/FieldDate/index.d.ts +23 -0
  61. package/src/framework/fields/FieldDate/index.jsx +116 -0
  62. package/src/framework/fields/FieldDateRange/index.d.ts +22 -0
  63. package/src/framework/fields/FieldDateRange/index.jsx +103 -0
  64. package/src/framework/fields/FieldDictSelect/index.d.ts +12 -0
  65. package/src/framework/fields/FieldDictSelect/index.jsx +16 -0
  66. package/src/framework/fields/FieldEditor/index.d.ts +14 -0
  67. package/src/framework/fields/FieldEditor/index.jsx +59 -0
  68. package/src/framework/fields/FieldNumberRange/index.d.ts +10 -0
  69. package/src/framework/fields/FieldNumberRange/index.jsx +55 -0
  70. package/src/framework/fields/FieldPercent/index.d.ts +8 -0
  71. package/src/framework/fields/FieldPercent/index.jsx +30 -0
  72. package/src/framework/fields/FieldRemoteSelect/index.d.ts +44 -0
  73. package/src/framework/fields/FieldRemoteSelect/index.jsx +125 -0
  74. package/src/framework/fields/FieldRemoteSelectMultiple/index.d.ts +20 -0
  75. package/src/framework/fields/FieldRemoteSelectMultiple/index.jsx +85 -0
  76. package/src/framework/fields/FieldRemoteSelectMultipleInline/index.d.ts +21 -0
  77. package/src/framework/fields/FieldRemoteSelectMultipleInline/index.jsx +88 -0
  78. package/src/framework/fields/FieldRemoteTree/index.d.ts +20 -0
  79. package/src/framework/fields/FieldRemoteTree/index.jsx +50 -0
  80. package/src/framework/fields/FieldRemoteTreeCascader/index.d.ts +18 -0
  81. package/src/framework/fields/FieldRemoteTreeCascader/index.jsx +59 -0
  82. package/src/framework/fields/FieldRemoteTreeSelect/index.d.ts +19 -0
  83. package/src/framework/fields/FieldRemoteTreeSelect/index.jsx +57 -0
  84. package/src/framework/fields/FieldRemoteTreeSelectMultiple/index.d.ts +20 -0
  85. package/src/framework/fields/FieldRemoteTreeSelectMultiple/index.jsx +62 -0
  86. package/src/framework/fields/FieldSysOrgTree/index.d.ts +9 -0
  87. package/src/framework/fields/FieldSysOrgTree/index.jsx +20 -0
  88. package/src/framework/fields/FieldSysOrgTreeSelect/index.d.ts +9 -0
  89. package/src/framework/fields/FieldSysOrgTreeSelect/index.jsx +22 -0
  90. package/src/framework/fields/FieldTable/index.d.ts +14 -0
  91. package/src/framework/fields/FieldTable/index.jsx +108 -0
  92. package/src/framework/fields/FieldTable/styles.less +29 -0
  93. package/src/framework/fields/FieldTableSelect/index.d.ts +19 -0
  94. package/src/framework/fields/FieldTableSelect/index.jsx +60 -0
  95. package/src/framework/fields/FieldUploadFile/index.d.ts +31 -0
  96. package/src/framework/fields/FieldUploadFile/index.jsx +139 -0
  97. package/src/framework/fields/index.ts +22 -0
  98. package/src/framework/fields/types.ts +16 -0
  99. package/src/framework/index.ts +5 -0
  100. package/src/framework/pages/LoginPage.d.ts +16 -0
  101. package/src/framework/pages/LoginPage.jsx +135 -0
  102. package/src/framework/pages/LoginPage.less +53 -0
  103. package/src/framework/pages/LoginPageUtils.ts +36 -0
  104. package/src/framework/pages/index.ts +2 -0
  105. package/src/framework/utils/ArrUtils.ts +229 -0
  106. package/src/framework/utils/ColorsUtils.ts +378 -0
  107. package/src/framework/utils/DateUtils.ts +187 -0
  108. package/src/framework/utils/DeviceUtils.ts +46 -0
  109. package/src/framework/utils/DomUtils.ts +50 -0
  110. package/src/framework/utils/EventBusUtils.ts +144 -0
  111. package/src/framework/utils/Logger.ts +40 -0
  112. package/src/framework/utils/MessageUtils.tsx +170 -0
  113. package/src/framework/utils/ObjectUtils.ts +118 -0
  114. package/src/framework/utils/StorageUtils.ts +50 -0
  115. package/src/framework/utils/StringUtils.ts +436 -0
  116. package/src/framework/utils/TreeUtils.ts +251 -0
  117. package/src/framework/utils/UrlUtils.ts +152 -0
  118. package/src/framework/utils/UuidUtils.ts +88 -0
  119. package/src/framework/utils/ValidateUtils.ts +28 -0
  120. package/src/framework/utils/index.ts +15 -0
  121. package/src/framework/utils/system/DictUtils.ts +97 -0
  122. package/src/framework/utils/system/FormRegistryUtils.ts +77 -0
  123. package/src/framework/utils/system/HttpUtils.ts +247 -0
  124. package/src/framework/utils/system/PageUtils.ts +163 -0
  125. package/src/framework/utils/system/PermUtils.ts +79 -0
  126. package/src/framework/utils/system/SysUtils.ts +97 -0
  127. package/src/framework/utils/system/ThemeUtils.ts +27 -0
  128. package/src/framework/utils/system/index.ts +7 -0
  129. package/src/framework/views/ViewApproveStatus/index.d.ts +3 -0
  130. package/src/framework/views/ViewApproveStatus/index.jsx +21 -0
  131. package/src/framework/views/ViewBoolean/index.d.ts +3 -0
  132. package/src/framework/views/ViewBoolean/index.jsx +4 -0
  133. package/src/framework/views/ViewBooleanEnableDisable/index.d.ts +5 -0
  134. package/src/framework/views/ViewBooleanEnableDisable/index.jsx +15 -0
  135. package/src/framework/views/ViewFile/index.d.ts +10 -0
  136. package/src/framework/views/ViewFile/index.jsx +49 -0
  137. package/src/framework/views/ViewFileButton/index.d.ts +10 -0
  138. package/src/framework/views/ViewFileButton/index.jsx +22 -0
  139. package/src/framework/views/ViewImage/index.d.ts +6 -0
  140. package/src/framework/views/ViewImage/index.jsx +60 -0
  141. package/src/framework/views/ViewPassword/index.d.ts +5 -0
  142. package/src/framework/views/ViewPassword/index.jsx +24 -0
  143. package/src/framework/views/ViewProcessInstanceProgress/index.d.ts +12 -0
  144. package/src/framework/views/ViewProcessInstanceProgress/index.jsx +97 -0
  145. package/src/framework/views/ViewProcessInstanceProgressButton/index.d.ts +6 -0
  146. package/src/framework/views/ViewProcessInstanceProgressButton/index.jsx +24 -0
  147. package/src/framework/views/ViewText/index.d.ts +16 -0
  148. package/src/framework/views/ViewText/index.jsx +42 -0
  149. package/src/framework/views/index.ts +12 -0
  150. package/src/framework/views/types.ts +26 -0
  151. package/src/index.ts +2 -0
  152. package/src/layouts/PageRender.d.ts +22 -0
  153. package/src/layouts/PageRender.jsx +90 -0
  154. package/src/layouts/admin/HeaderRight.jsx +104 -0
  155. package/src/layouts/admin/TabPageRender.jsx +158 -0
  156. package/src/layouts/admin/index.jsx +159 -0
  157. package/src/layouts/admin/index.less +65 -0
  158. package/src/layouts/index.jsx +187 -0
  159. package/src/layouts/index.less +24 -0
  160. package/src/loading.jsx +18 -0
  161. package/src/pages/404.jsx +13 -0
  162. package/src/pages/about.jsx +12 -0
  163. package/src/pages/index.jsx +10 -0
  164. package/src/pages/login.jsx +16 -0
  165. package/src/pages/system/api/ApiDoc.jsx +148 -0
  166. package/src/pages/system/api/index.jsx +267 -0
  167. package/src/pages/system/api/perm.jsx +69 -0
  168. package/src/pages/system/dict/Dict.jsx +67 -0
  169. package/src/pages/system/dict/DictItem.jsx +175 -0
  170. package/src/pages/system/dict/index.jsx +25 -0
  171. package/src/pages/system/file/index.jsx +147 -0
  172. package/src/pages/system/job/index.jsx +324 -0
  173. package/src/pages/system/log/index.jsx +77 -0
  174. package/src/pages/system/org/index.jsx +260 -0
  175. package/src/pages/system/role/index.jsx +302 -0
  176. package/src/pages/system/role/perm.jsx +107 -0
  177. package/src/pages/system/sysManual/index.jsx +126 -0
  178. package/src/pages/system/user/UserPerm.jsx +94 -0
  179. package/src/pages/system/user/index.jsx +253 -0
  180. package/src/pages/test/views.jsx +95 -0
  181. package/src/pages/ureport/index.jsx +16 -0
  182. package/src/pages/userCenter/ChangePassword.jsx +64 -0
  183. package/src/pages/userCenter/index.jsx +90 -0
  184. package/src/pages/userCenter/manual.jsx +57 -0
  185. package/src/pages/userCenter/message.jsx +103 -0
  186. package/src/style/global.less +51 -0
@@ -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 {DeviceUtils, HttpUtils, MessageUtils, PageUtils, SysUtils} 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 (DeviceUtils.isMobileDevice()) {
18
+ this.setState({isMobileDevice: true})
19
+ }
20
+ }
21
+
22
+
23
+
24
+ logout = () => {
25
+ HttpUtils.post('admin/auth/logout').then(async () => {
26
+ localStorage.clear()
27
+ await MessageUtils.alert('退出登录成功');
28
+ history.replace('/login')
29
+ }).catch(async e => {
30
+ let confirm = await MessageUtils.confirm('退出登录失败,是否清空缓存');
31
+ if (confirm) {
32
+ localStorage.clear();
33
+ history.replace('/login')
34
+ }
35
+ })
36
+ }
37
+
38
+ userCenter = () => {
39
+ PageUtils.open('/userCenter', '个人中心')
40
+ }
41
+
42
+ render() {
43
+ const info = SysUtils.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={() => PageUtils.open('/userCenter/message', '我的消息')}>
59
+ <Badge count={info.messageCount} size="small">
60
+ <NotificationOutlined/>
61
+ </Badge>
62
+ </div>
63
+
64
+ <div className='item' title='操作手册' onClick={() => PageUtils.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 {PageUtils} 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 = PageUtils.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)
@@ -0,0 +1,159 @@
1
+ import React from 'react';
2
+ import {Badge, Layout, Menu, Watermark} from 'antd';
3
+
4
+ import {history, Link} from 'umi';
5
+ import "./index.less"
6
+ import {Gap, HttpUtils, NamedIcon, PageUtils, SysUtils, ThemeUtils, TreeUtils} from "../../framework";
7
+
8
+ import HeaderRight from "./HeaderRight";
9
+ import TabPageRender from "./TabPageRender";
10
+
11
+ const {Header, Sider, Content} = Layout;
12
+ /**
13
+ * 带菜单的布局,主要处理布局宇框架结构
14
+ */
15
+ export default class extends React.Component {
16
+
17
+ state = {
18
+ loginInfo: {},
19
+
20
+ menuTree: [],
21
+ menuMap: {},
22
+ pathMenuMap: {},
23
+
24
+
25
+ currentMenuKey: null,
26
+
27
+
28
+ siteInfo: {},
29
+ }
30
+
31
+
32
+ componentDidMount() {
33
+ console.log('Admin Layout didMount')
34
+ // 判断是否手机端,自动收起菜单
35
+
36
+
37
+ let siteInfo = SysUtils.getSiteInfo();
38
+ const loginInfo = SysUtils.getLoginInfo()
39
+ this.setState({siteInfo, loginInfo})
40
+
41
+ this.initMenu()
42
+ }
43
+
44
+
45
+ initMenu = () => {
46
+ HttpUtils.get('/admin/menuInfo').then(info => {
47
+ const {menuTree, pathMenuMap, menuMap} = info
48
+ this.setState({menuMap})
49
+
50
+ let pathname = PageUtils.currentPathname();
51
+
52
+ TreeUtils.walk(menuTree, (item) => {
53
+ item.icon = <NamedIcon name={item.icon || 'AppstoreOutlined'} style={{fontSize: 12}}/>
54
+ })
55
+
56
+ if (pathname !== "" && pathname !== "/") {
57
+ let menu = pathMenuMap[pathname]
58
+ if (menu) {
59
+ this.setState({currentMenuKey: menu.key})
60
+ }
61
+ }
62
+
63
+ this.setState({menuTree, pathMenuMap})
64
+
65
+ this.loadBadge(menuMap)
66
+ })
67
+
68
+
69
+ }
70
+ actionRef = React.createRef()
71
+
72
+
73
+ loadBadge = menuMap => {
74
+ for (let id in menuMap) {
75
+ const item = menuMap[id]
76
+ const {messageCountUrl} = item;
77
+ if (!messageCountUrl) {
78
+ continue
79
+ }
80
+ HttpUtils.get(messageCountUrl).then(rs => {
81
+ const {menuTree} = this.state
82
+ const menu = TreeUtils.findByKey(id, menuTree, 'key')
83
+ if (menu) {
84
+ menu.icon = <Badge dot count={rs} size={"small"}>{menu.icon}</Badge>
85
+ this.setState({menuTree: [...menuTree]})
86
+ }
87
+
88
+ })
89
+ }
90
+ };
91
+
92
+
93
+ render() {
94
+ const {siteInfo, loginInfo} = this.state
95
+
96
+ return <Layout className='main-layout'>
97
+ <Header className='header'>
98
+ <div className='header-left'>
99
+ {siteInfo.logoUrl &&
100
+ <img className='logo-img' src={siteInfo.logoUrl} onClick={() => history.push('/')} alt='logo'/>}
101
+ <h3 className='hide-on-mobile'>
102
+ <Link to="/" style={{color: ThemeUtils.getColor("primary-color")}}>{siteInfo.title} </Link>
103
+ </h3>
104
+
105
+ </div>
106
+ <HeaderRight/>
107
+ </Header>
108
+
109
+ <Layout style={{height: '100%'}}>
110
+ <Sider id='left-sider'
111
+ collapsible
112
+ breakpoint={'md'}
113
+ >
114
+ <Gap/>
115
+
116
+
117
+ <Menu items={this.state.menuTree}
118
+ theme='dark'
119
+ mode="inline"
120
+ className='left-menu'
121
+ onClick={({key}) => {
122
+ const menu = this.state.menuMap[key]
123
+ let {path} = menu;
124
+ this.setState({currentMenuKey: key})
125
+ history.push(path)
126
+ }}
127
+ selectedKeys={[this.state.currentMenuKey]}
128
+ inlineIndent={16}
129
+ >
130
+ </Menu>
131
+
132
+ </Sider>
133
+
134
+ <Content id='admin-layout-content'>
135
+ {this.getContent(loginInfo)}
136
+ </Content>
137
+
138
+ </Layout>
139
+ </Layout>
140
+ }
141
+
142
+
143
+ getContent = () => {
144
+ const {siteInfo, loginInfo} = this.state
145
+ if (this.state.menuTree.length === 0) { // 加载菜单中
146
+ return <></>
147
+ }
148
+ let tabPageRenderNode = <TabPageRender pathMenuMap={this.state.pathMenuMap}/>;
149
+ if (siteInfo.waterMark === true) {
150
+ return <Watermark content={[loginInfo.name, loginInfo.account]}>
151
+ {tabPageRenderNode}
152
+ </Watermark>
153
+ }
154
+
155
+ return tabPageRenderNode
156
+ };
157
+ }
158
+
159
+
@@ -0,0 +1,65 @@
1
+ .main-layout {
2
+ min-height: 100vh;
3
+ .header {
4
+ padding: 0 20px;
5
+ height: 48px;
6
+ display: flex;
7
+ justify-content: space-between;
8
+ align-items: center;
9
+ border-bottom: 1px solid rgb(233, 237, 240);
10
+ background-color: rgb(246, 248, 250);
11
+
12
+ .header-left {
13
+
14
+ display: flex;
15
+ align-items: center;
16
+ gap: 8px;
17
+
18
+ .logo-img {
19
+ height: 38px;
20
+ cursor: pointer;
21
+ }
22
+ }
23
+
24
+ .header-right {
25
+ line-height: 36px;
26
+ display: flex;
27
+ align-items: center;
28
+
29
+ .item {
30
+ padding: 0 0.5rem;
31
+ cursor: pointer;
32
+
33
+ &:hover {
34
+ background: #063A69;
35
+ color: white;
36
+ }
37
+ }
38
+ }
39
+
40
+ }
41
+
42
+
43
+ #left-sider {
44
+ .left-menu {
45
+ overflow: auto;
46
+ scrollbar-width: thin;
47
+ scrollbar-color: unset;
48
+
49
+ .ant-menu-submenu-selected {
50
+ div {
51
+ color: white !important;
52
+ }
53
+ }
54
+ }
55
+
56
+ }
57
+
58
+ #admin-layout-content {
59
+ .tmgg-layout-tabs {
60
+ &>.ant-tabs-nav {
61
+ margin-bottom: 8px;
62
+ }
63
+ }
64
+ }
65
+ }
@@ -0,0 +1,187 @@
1
+ import AdminLayout from "./admin"
2
+ import React from "react";
3
+ import {ConfigProvider} from "antd";
4
+
5
+ import {Outlet, withRouter} from "umi";
6
+ import zhCN from 'antd/locale/zh_CN';
7
+ import {
8
+ ArrUtils,
9
+ HttpUtils,
10
+ MessageHolder,
11
+ PageLoading,
12
+ PageUtils, StringUtils,
13
+ SysUtils,
14
+ ThemeUtils,
15
+ } from "../framework";
16
+ import dayjs from 'dayjs';
17
+ import 'dayjs/locale/zh-cn';
18
+
19
+ import '../style/global.less'
20
+ import './index.less'
21
+ import {Logger} from "../framework/utils/Logger";
22
+
23
+ dayjs.locale('zh-cn');
24
+
25
+ // 不需要登录的页面
26
+ const SIMPLE_URLS = ['/login', '/test']
27
+
28
+ function checkIsSimplePage(pathname) {
29
+ if(pathname === '/' || pathname === '/index'){
30
+ return false;
31
+ }
32
+ // 测试页面
33
+ if(pathname.startsWith("/test/")){
34
+ return true
35
+ }
36
+ let count = StringUtils.count(pathname,'/');
37
+ return ArrUtils.contains(SIMPLE_URLS, pathname) || count === 1;
38
+ }
39
+
40
+ function checkIsPurePage(pathname){
41
+ if(pathname.startsWith("/test/")){
42
+ return true
43
+ }
44
+ return false
45
+ }
46
+
47
+ class _Layouts extends React.Component {
48
+
49
+ log = Logger.getLogger('Layouts')
50
+
51
+ state = {
52
+ messageHolderInit:false,
53
+ siteInfoLoading: true,
54
+ loginInfoFinish: false
55
+ }
56
+
57
+ onMessageHolderFinish = () => {
58
+ this.loadSiteInfo()
59
+ this.setState({messageHolderInit:true});
60
+ }
61
+
62
+
63
+ loadSiteInfo = () => {
64
+ HttpUtils.get("/admin/public/site-info").then(rs => {
65
+ SysUtils.setSiteInfo(rs)
66
+ this.setState({siteInfoLoading: false})
67
+ this.loadLoginInfo()
68
+ })
69
+ };
70
+
71
+ componentDidUpdate(prevProps, prevState, snapshot) {
72
+ const pre = prevProps.location.pathname
73
+ const cur = this.props.location.pathname
74
+ if (pre !== cur) {
75
+ this.loadLoginInfo()
76
+ }
77
+ }
78
+
79
+
80
+
81
+ loadLoginInfo = () => {
82
+ let {pathname} = this.props.location;
83
+ if (checkIsPurePage(pathname) || checkIsSimplePage(pathname) || this.state.loginInfoFinish) {
84
+ return;
85
+ }
86
+
87
+ HttpUtils.get('/admin/public/checkLogin')
88
+ .then(rs => {
89
+ const {needUpdatePwd, dictMap, loginInfo} = rs
90
+ SysUtils.setDictInfo(dictMap)
91
+ SysUtils.setLoginInfo(loginInfo)
92
+ if (!needUpdatePwd) {
93
+ this.setState({loginInfoFinish: true});
94
+ return;
95
+ }
96
+
97
+ if (needUpdatePwd) {
98
+ PageUtils.open('/userCenter/ChangePassword', '修改密码')
99
+ return;
100
+ }
101
+ })
102
+ .catch(async () => {
103
+ PageUtils.redirectToLogin()
104
+ })
105
+ }
106
+
107
+ render() {
108
+ return <ConfigProvider
109
+ input={{autoComplete: 'off'}}
110
+ form={{
111
+ validateMessages: {
112
+ required: '必填项'
113
+ }, colon: false
114
+ }}
115
+ button={{
116
+ autoInsertSpace: false
117
+ }}
118
+ locale={zhCN}
119
+ theme={{
120
+ token: {
121
+ colorPrimary: ThemeUtils.getColor("primary-color"),
122
+ colorSuccess: ThemeUtils.getColor("success-color"),
123
+ colorWarning: ThemeUtils.getColor("warning-color"),
124
+ colorError: ThemeUtils.getColor("error-color"),
125
+ borderRadius: 4,
126
+ },
127
+ components: {
128
+ Menu: {
129
+ darkItemBg: ThemeUtils.getColor("primary-color"),
130
+ darkPopupBg: ThemeUtils.getColor("primary-color"),
131
+ darkItemSelectedBg: ThemeUtils.getColor("primary-color-click"),
132
+ darkItemHoverBg: ThemeUtils.getColor("primary-color-hover"),
133
+ darkSubMenuItemBg: ThemeUtils.getColor("primary-color")
134
+ },
135
+ Layout: {
136
+ siderBg: ThemeUtils.getColor("primary-color"),
137
+ triggerBg: ThemeUtils.getColor("primary-color-click"),
138
+ headerBg: 'white',
139
+ triggerHeight: 32
140
+ }
141
+ }
142
+ }}>
143
+
144
+ <MessageHolder onFinish={this.onMessageHolderFinish} />
145
+ {this.renderContent()}
146
+ </ConfigProvider>
147
+ }
148
+
149
+
150
+ renderContent = () => {
151
+ let {pathname} = this.props.location;
152
+
153
+ if(checkIsPurePage(pathname)){
154
+ return <Outlet/>
155
+ }
156
+
157
+ if(!this.state.messageHolderInit) {
158
+ this.log.info('加载message holder...')
159
+ return <PageLoading message='加载消息组件...'/>
160
+ }
161
+
162
+ let {params = {}} = this.props.location;
163
+ console.log('layout: params', params)
164
+ if (checkIsSimplePage(pathname) || params.hasOwnProperty('_noLayout')) {
165
+ return <Outlet/>
166
+ }
167
+
168
+
169
+
170
+ if (this.state.siteInfoLoading) {
171
+ return <PageLoading message='加载站点信息...'/>
172
+ }
173
+
174
+
175
+
176
+ if (!this.state.loginInfoFinish) {
177
+ return <PageLoading message='加载登录信息...'/>
178
+ }
179
+
180
+ return <AdminLayout path={this.state.path} logo={this.props.logo}/>
181
+ };
182
+ }
183
+
184
+
185
+ export const Layouts = withRouter(_Layouts);
186
+ export default Layouts
187
+ export * from './PageRender'
@@ -0,0 +1,24 @@
1
+ html,body{
2
+ margin: 0;
3
+ padding: 0;
4
+ }
5
+
6
+ @media print {
7
+ .no-print {
8
+ display: none;
9
+ }
10
+ }
11
+
12
+ .hide-on-mobile{ //电脑端css
13
+ }
14
+
15
+ @media (max-width: 767px) { //移动端css
16
+
17
+ .hide-on-mobile{
18
+ display: none !important;
19
+ }
20
+
21
+ }
22
+
23
+
24
+