mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-17 17:54:32 +08:00
添加退出登录功能
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -11,7 +11,7 @@ const FormItem = Form.Item;
|
||||
const Login = () => {
|
||||
const handleOk = (values: any) => {
|
||||
request
|
||||
.post(`${config.apiPrefix}auth`, {
|
||||
.post(`${config.apiPrefix}login`, {
|
||||
data: {
|
||||
username: values.username,
|
||||
password: values.password,
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
auto as followSystemColorScheme,
|
||||
setFetchMethod,
|
||||
} from 'darkreader';
|
||||
import { history } from 'umi';
|
||||
|
||||
const optionsWithDisabled = [
|
||||
{ label: '亮色', value: 'light' },
|
||||
@@ -34,9 +35,8 @@ const Password = () => {
|
||||
},
|
||||
})
|
||||
.then((data: any) => {
|
||||
notification.success({
|
||||
message: data.msg,
|
||||
});
|
||||
localStorage.removeItem(config.authKey);
|
||||
history.push('/login');
|
||||
})
|
||||
.catch((error: any) => {
|
||||
console.log(error);
|
||||
|
||||
Reference in New Issue
Block a user