feat: add logout
This commit is contained in:
parent
6b91b62ab9
commit
9a23521524
@ -7,15 +7,18 @@ import {
|
||||
CodeOutlined,
|
||||
DashboardOutlined,
|
||||
HomeOutlined,
|
||||
LogoutOutlined,
|
||||
MessageOutlined,
|
||||
ReadOutlined,
|
||||
RocketOutlined,
|
||||
SmileOutlined,
|
||||
SwapOutlined,
|
||||
SwitcherOutlined,
|
||||
UserOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import { useNavigate } from 'react-router';
|
||||
import { useMemo } from 'react';
|
||||
import { query } from '../query';
|
||||
const meun = [
|
||||
{
|
||||
title: 'Your profile',
|
||||
@ -98,6 +101,17 @@ export const LayoutUser = () => {
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
<div
|
||||
className='flex items-center p-4 hover:bg-gray-100 cursor-pointer'
|
||||
onClick={() => {
|
||||
query.removeToken();
|
||||
window.open('/user/login', '_self');
|
||||
}}>
|
||||
<div className='mr-4'>
|
||||
<LogoutOutlined />
|
||||
</div>
|
||||
<div>Login Out</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
@ -15,13 +15,13 @@ query.beforeRequest = async (config) => {
|
||||
};
|
||||
query.afterResponse = async (res) => {
|
||||
if (res.code === 401) {
|
||||
modal.setOpen(true);
|
||||
}
|
||||
if (res.code === 403) {
|
||||
if (!res?.message) {
|
||||
message.error('Unauthorized');
|
||||
}
|
||||
}
|
||||
if (res.code === 403) {
|
||||
modal.setOpen(true);
|
||||
}
|
||||
return res;
|
||||
};
|
||||
export const request = query.post;
|
||||
|
Loading…
x
Reference in New Issue
Block a user