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
7edd22db
Commit
7edd22db
authored
Nov 03, 2020
by
张烨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: login and logout
parent
051fd8c0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
12 deletions
+31
-12
.eslintrc.js
.eslintrc.js
+1
-0
AvatarDropdown.js
src/components/GlobalHeader/AvatarDropdown.js
+16
-4
index.js
src/containers/App/index.js
+3
-3
index.js
src/pages/user/login/index.js
+5
-5
constants.js
src/utils/constants.js
+6
-0
No files found.
.eslintrc.js
View file @
7edd22db
...
...
@@ -99,6 +99,7 @@ module.exports = {
'no-param-reassign'
:
0
,
'prefer-const'
:
0
,
'button-has-type'
:
0
,
'symbol-description'
:
0
,
},
settings
:
{
'import/resolver'
:
{
...
...
src/components/GlobalHeader/AvatarDropdown.js
View file @
7edd22db
...
...
@@ -5,12 +5,24 @@ import {
}
from
'@ant-design/icons'
;
import
{
Avatar
,
Menu
,
Spin
}
from
'antd'
;
import
React
from
'react'
;
import
{
withRouter
}
from
'react-router-dom'
;
import
HeaderDropdown
from
'../HeaderDropdown'
;
import
styles
from
'./index.less'
;
import
{
setAuthority
}
from
'@/utils/authority'
;
class
AvatarDropdown
extends
React
.
Component
{
/* eslint-disable no-unused-vars */
onMenuClick
=
event
=>
{};
onMenuClick
=
event
=>
{
const
{
history
}
=
this
.
props
;
switch
(
event
.
key
)
{
case
'logout'
:
setAuthority
([]);
history
.
push
(
'/user/login'
);
break
;
default
:
break
;
}
};
render
()
{
const
{
...
...
@@ -26,7 +38,7 @@ class AvatarDropdown extends React.Component {
selectedKeys
=
{[]}
onClick
=
{
this
.
onMenuClick
}
>
{
{
/* {
<Menu.Item key="center">
<UserOutlined />
个人中心
...
...
@@ -38,7 +50,7 @@ class AvatarDropdown extends React.Component {
个人设置
</Menu.Item>
}
{
<
Menu
.
Divider
/>
}
{<Menu.Divider />}
*/
}
<
Menu
.
Item
key
=
"logout"
>
<
LogoutOutlined
/>
...
...
@@ -72,4 +84,4 @@ class AvatarDropdown extends React.Component {
}
}
export
default
AvatarDropdown
;
export
default
withRouter
(
AvatarDropdown
)
;
src/containers/App/index.js
View file @
7edd22db
...
...
@@ -6,7 +6,7 @@ import config from '../../routes/config';
import
Authozed
from
'@/utils/authority'
;
import
UserLogin
from
'@/pages/user/login'
;
import
UserLayout
from
'@/layouts/UserLayout'
;
import
{
AUTHORITY
,
BASENAME
}
from
'@/utils/constants'
;
export
default
function
App
()
{
return
(
<>
...
...
@@ -19,9 +19,9 @@ export default function App() {
<
UserLogin
/>
<
/UserLayout
>
}
authority
=
"login"
authority
=
{[
AUTHORITY
.
LOGIN
]}
>
<
Router
basename
=
{
process
.
env
.
PUBLIC_PATH
||
'reactOMS'
}
>
<
Router
basename
=
{
BASENAME
}
>
<
Switch
>
{
renderRoutes
(
config
.
routes
)}
<
/Switch
>
<
/Router
>
<
/Authozed
>
...
...
src/pages/user/login/index.js
View file @
7edd22db
import
React
,
{
useState
}
from
'react'
;
import
{
Alert
,
Checkbox
}
from
'antd'
;
import
{
login
}
from
'@/services/user/api'
;
import
{
USER_MODE
}
from
'@/utils/constants'
;
import
{
AUTHORITY
,
BASENAME
,
USER_MODE
}
from
'@/utils/constants'
;
import
LoginForm
from
'./components/Login'
;
import
styles
from
'./style.less'
;
import
{
setAuthority
}
from
'@/utils/authority'
;
...
...
@@ -33,12 +33,12 @@ const Login = props => {
const
{
userMode
}
=
result
;
localStorage
.
setItem
(
'userMode'
,
userMode
);
if
(
userMode
===
USER_MODE
.
ADMIN
||
userMode
===
USER_MODE
.
SUPER
)
{
setAuthority
([
'login'
,
USER_MODE
.
ADMIN
,
USER_MODE
.
SUPER
]);
window
.
location
.
href
=
'/dbm/dbInit/'
;
setAuthority
([
AUTHORITY
.
LOGIN
,
AUTHORITY
[
userMode
]
]);
window
.
location
.
href
=
`/
${
BASENAME
}
/dbm/dbInit/`
;
}
if
(
userMode
===
USER_MODE
.
COMMON
)
{
setAuthority
([
'login'
,
USER_MODE
.
COMMON
]);
window
.
location
.
href
=
'/ou/orgList/'
;
setAuthority
([
AUTHORITY
.
LOGIN
,
AUTHORITY
.
COMMON
]);
window
.
location
.
href
=
`/
${
BASENAME
}
/ou/orgList/`
;
}
}
else
{
alert
(
'错误,没有权限'
);
...
...
src/utils/constants.js
View file @
7edd22db
...
...
@@ -2,6 +2,12 @@ export const RESTART_ON_REMOUNT = '@@saga-injector/restart-on-remount';
export
const
DAEMON
=
'@@saga-injector/daemon'
;
export
const
ONCE_TILL_UNMOUNT
=
'@@saga-injector/once-till-unmount'
;
export
const
BASENAME
=
process
.
env
.
PUBLIC_PATH
||
'reactOMS'
;
export
const
AUTHORITY
=
{
LOGIN
:
'LOGIN'
,
admin
:
'admin'
,
super
:
'super'
,
};
export
const
USER_MODE
=
{
ADMIN
:
'admin'
,
SUPER
:
'super'
,
...
...
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