添加退出登录功能

This commit is contained in:
whyour
2021-03-23 14:32:17 +08:00
parent d41eb582e4
commit 51b0418fa9
5 changed files with 21 additions and 6 deletions
+15
View File
@@ -8,11 +8,16 @@ import {
} from 'darkreader';
import defaultProps from './defaultProps';
import { Link, history } from 'umi';
import { LogoutOutlined } from '@ant-design/icons';
import config from '@/utils/config';
import 'codemirror/mode/shell/shell.js';
import './index.less';
export default function (props: any) {
const logout = () => {
localStorage.removeItem(config.authKey);
};
useEffect(() => {
const isAuth = localStorage.getItem(config.authKey);
if (!isAuth) {
@@ -55,6 +60,16 @@ export default function (props: any) {
}
return <Link to={menuItemProps.path}>{defaultDom}</Link>;
}}
postMenuData={(menuData) => {
return [
...(menuData || []),
{
icon: <LogoutOutlined />,
name: '退出登录',
onTitleClick: () => logout(),
},
];
}}
{...defaultProps}
>
{props.children}