feat: fixed the issue that some PDF documents could not be displayed on the chunk list page in small screens and logout (#105)

* feat: logout

* feat: fixed the issue that some PDF documents could not be displayed on the chunk list page in small screens
This commit is contained in:
balibabu
2024-03-07 11:38:32 +08:00
committed by GitHub
parent aaf3084324
commit 6048926a4d
10 changed files with 89 additions and 50 deletions

View File

@ -1,19 +1,27 @@
import { useFetchUserInfo, useSelectUserInfo } from '@/hooks/userSettingHook';
import {
useFetchUserInfo,
useLogout,
useSelectUserInfo,
} from '@/hooks/userSettingHook';
import authorizationUtil from '@/utils/authorizationUtil';
import type { MenuProps } from 'antd';
import { Avatar, Button, Dropdown } from 'antd';
import React, { useMemo } from 'react';
import React, { useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { history } from 'umi';
const App: React.FC = () => {
const { t } = useTranslation();
const userInfo = useSelectUserInfo();
const logout = useLogout();
const logout = () => {
authorizationUtil.removeAll();
history.push('/login');
};
const handleLogout = useCallback(async () => {
const retcode = await logout();
if (retcode === 0) {
authorizationUtil.removeAll();
history.push('/login');
}
}, [logout]);
const toSetting = () => {
history.push('/setting');
@ -23,7 +31,7 @@ const App: React.FC = () => {
return [
{
key: '1',
onClick: logout,
onClick: handleLogout,
label: <Button type="text">{t('header.logout')}</Button>,
},
{
@ -32,7 +40,7 @@ const App: React.FC = () => {
label: <Button type="text">{t('header.setting')}</Button>,
},
];
}, [t]);
}, [t, handleLogout]);
useFetchUserInfo();