Commit 7edd22db authored by 张烨's avatar 张烨

feat: login and logout

parent 051fd8c0
......@@ -99,6 +99,7 @@ module.exports = {
'no-param-reassign': 0,
'prefer-const': 0,
'button-has-type': 0,
'symbol-description':0,
},
settings: {
'import/resolver': {
......
......@@ -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);
......@@ -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>
......
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('错误,没有权限');
......
......@@ -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',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment