Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CivManage
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ReactWeb5
CivManage
Commits
da40eadf
Commit
da40eadf
authored
Oct 16, 2020
by
陈前坚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加登录权限控制,静态菜单
parent
e59c081d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
173 additions
and
43 deletions
+173
-43
BasicLayout.js
src/layouts/BasicLayout.js
+116
-31
index.js
src/pages/user/login/index.js
+25
-6
config.js
src/routes/config.js
+32
-6
No files found.
src/layouts/BasicLayout.js
View file @
da40eadf
import
React
,
{
useState
}
from
'react'
;
import
React
,
{
useState
,
useEffect
}
from
'react'
;
import
axios
from
'axios'
;
import
{
matchRoutes
,
renderRoutes
,
}
from
'react-router-config'
;
import
{
matchRoutes
,
renderRoutes
}
from
'react-router-config'
;
import
{
Link
}
from
'react-router-dom'
;
import
{
GithubOutlined
}
from
'@ant-design/icons'
;
...
...
@@ -11,7 +9,7 @@ import ProLayout, { DefaultFooter } from '@ant-design/pro-layout';
import
logo
from
'../assets/logo.svg'
;
import
RightContent
from
'../components/GlobalHeader/RightContent'
;
import
config
from
'../routes/config'
;
//
import config from '../routes/config';
// const noMatch = (
// <Result
...
...
@@ -47,9 +45,96 @@ const defaultFooterDom = (
]}
/
>
);
const
BasicMenu
=
[
{
path
:
'/dbm'
,
component
:
'BasicLayout'
,
name
:
'数据库管理'
,
icon
:
'icon-dashboard'
,
routes
:
[
{
path
:
'/dbm/dbInit'
,
name
:
'数据库初始化'
,
},
{
path
:
'/dbm/dbsm'
,
name
:
'数据库标准化管理'
,
},
],
},
{
path
:
'/ou'
,
component
:
'BasicLayout'
,
name
:
'机构与用户管理'
,
icon
:
'icon-dashboard'
,
routes
:
[
{
path
:
'/ou/orgList'
,
name
:
'机构列表'
,
},
],
},
{
path
:
'/basicConfig'
,
component
:
'BasicLayout'
,
name
:
'基础通用配置'
,
icon
:
'icon-dashboard'
,
},
{
path
:
'/web5'
,
component
:
'BasicLayout'
,
name
:
'Web5配置'
,
icon
:
'icon-dashboard'
,
},
{
path
:
'/app'
,
component
:
'BasicLayout'
,
name
:
'手持系统配置'
,
icon
:
'icon-dashboard'
,
},
{
path
:
'/miniPro'
,
component
:
'BasicLayout'
,
name
:
'小程序配置'
,
authority
:
[
'admin'
,
'user'
],
icon
:
'icon-dashboard'
,
},
{
path
:
'/log'
,
component
:
'BasicLayout'
,
name
:
'日志管理'
,
icon
:
'icon-dashboard'
,
routes
:
[
{
path
:
'/log/service'
,
name
:
'服务日志'
,
},
{
path
:
'/log/login'
,
name
:
'登录日志'
,
},
],
},
];
const
basicUrl
=
'http://localhost:8080/Cityinterface/rest/services/OMS.svc/'
;
const
BasicLayout
=
props
=>
{
/* eslint-disable no-unused-vars */
const
[
pathname
,
setPathname
]
=
useState
(
'/welcome'
);
const
[
menuData
,
setMenuData
]
=
useState
([]);
console
.
log
(
props
);
useEffect
(()
=>
{
fetch
(
`
${
basicUrl
}
U_GetOUTree?_version=9999`
)
.
then
(
response
=>
response
.
json
())
.
then
(
data
=>
{
const
userMode
=
localStorage
.
getItem
(
'userMode'
);
if
(
userMode
==
'common'
)
{
BasicMenu
.
shift
();
}
setMenuData
(
BasicMenu
||
[]);
});
},
[]);
const
handleMenuCollapse
=
()
=>
{};
// get children authority
matchRoutes
(
props
.
route
.
routes
,
props
.
location
.
pathname
);
...
...
@@ -60,38 +145,38 @@ const BasicLayout = props => {
onMenuHeaderClick
=
{()
=>
{}}
footerRender
=
{()
=>
defaultFooterDom
}
rightContentRender
=
{()
=>
<
RightContent
/>
}
route
=
{{
routes
:
config
.
routes
,
}}
route
=
{
{
// routes: config.routes,
}
}
location
=
{{
pathname
,
}}
menuDataRender
=
{()
=>
[
{
path
:
'/'
,
component
:
'BasicLayout'
,
name
:
'Dashboard'
,
icon
:
'icon-dashboard'
,
routes
:
[
{
path
:
'/Welcome/1'
,
name
:
'一级页面'
,
},
{
path
:
'/Welcome/2'
,
name
:
'二级页面'
,
},
{
path
:
'/Welcome/3'
,
name
:
'三级页面'
,
},
],
},
]}
menuDataRender
=
{
menuDataProps
=>
{
console
.
log
(
menuDataProps
);
menuDataProps
.
forEach
(
item
=>
{
if
(
item
.
name
==
'机构列表'
)
{
console
.
log
(
'机构列表'
);
axios
.
get
(
`
${
basicUrl
}
U_GetOUTree?_version=9999`
).
then
(
result
=>
{
console
.
log
(
result
.
data
);
item
.
routes
=
[
{
path
:
'/ou/orgList'
,
name
:
'机构列表11'
,
},
];
});
}
});
return
menuData
;
}}
menuItemRender
=
{(
menuItemProps
,
defaultDom
)
=>
{
if
(
menuItemProps
.
isUrl
||
!
menuItemProps
.
path
)
{
return
defaultDom
;
}
// console.log(menuItemProps);
return
<
Link
to
=
{
menuItemProps
.
path
}
>
{
defaultDom
}
<
/Link>
;
}}
itemRender
=
{(
route
,
params
,
routes
,
paths
)
=>
{
...
...
src/pages/user/login/index.js
View file @
da40eadf
import
React
,
{
useState
}
from
'react'
;
import
axios
from
'axios'
;
import
{
Alert
,
Checkbox
,
}
from
'antd'
;
import
{
Alert
,
Checkbox
}
from
'antd'
;
import
LoginForm
from
'./components/Login'
;
import
styles
from
'./style.less'
;
...
...
@@ -20,6 +18,7 @@ const LoginMessage = ({ content }) => (
showIcon
/>
);
const
basicUrl
=
'http://localhost:8080/Cityinterface/rest/services/OMS.svc/'
;
const
Login
=
props
=>
{
const
{
userLogin
=
{},
submitting
}
=
props
;
...
...
@@ -28,8 +27,28 @@ const Login = props => {
const
[
type
,
setType
]
=
useState
(
'account'
);
const
handleSubmit
=
values
=>
{
/* eslint-disable no-console */
console
.
log
(
values
);
window
.
location
.
href
=
'/'
;
console
.
log
(
values
);
// eg:{userName: "123", password: "123"}
axios
.
get
(
`
${
basicUrl
}
L_GetCheckUser?loginName=
${
values
.
userName
}
&password=
${
values
.
password
}
`
,
)
.
then
(
result
=>
{
console
.
log
(
result
.
data
);
if
(
result
.
data
.
success
==
true
&&
result
.
data
.
pass
==
true
)
{
const
{
userMode
}
=
result
.
data
;
localStorage
.
setItem
(
'userMode'
,
userMode
);
if
(
userMode
==
'admin'
||
userMode
==
'super'
)
{
window
.
location
.
href
=
'/dbm/dbInit/'
;
}
if
(
userMode
==
'common'
)
{
window
.
location
.
href
=
'/ou/orgList/'
;
}
}
else
{
alert
(
'错误,没有权限'
);
}
});
};
return
(
...
...
src/routes/config.js
View file @
da40eadf
...
...
@@ -20,18 +20,44 @@ export default {
component
:
BasicLayout
,
routes
:
[
{
path
:
'/
Welcome/1
'
,
name
:
'
一级页面
'
,
path
:
'/
dbm/dbInit
'
,
name
:
'
数据库初始化
'
,
component
:
Welcome
,
},
{
path
:
'/
Welcome/2
'
,
name
:
'
二级页面
'
,
path
:
'/
dbm/dbsm
'
,
name
:
'
数据库标准化管理
'
,
component
:
Welcome
,
},
{
path
:
'/Welcome/3'
,
name
:
'三级页面'
,
path
:
'/ou/orgList'
,
name
:
'机构列表'
,
component
:
Welcome
,
},
{
path
:
'/basicConfig'
,
name
:
'基础通用配置'
,
component
:
Welcome
,
},
{
path
:
'/web5'
,
name
:
'Web5配置'
,
component
:
Welcome
,
},
{
path
:
'/app'
,
name
:
'手持系统配置'
,
component
:
Welcome
,
},
{
path
:
'/miniPro'
,
name
:
'小程序配置'
,
authority
:
[
'admin'
,
'user'
],
component
:
Welcome
,
},
{
path
:
'/log'
,
name
:
'日志管理'
,
component
:
Welcome
,
},
],
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment