mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
feat: prevent the user from entering the knowledge base if he is not logged in (#45)
This commit is contained in:
@ -1,38 +1,53 @@
|
||||
import React, { useMemo } from 'react';
|
||||
import authorizationUtil from '@/utils/authorizationUtil';
|
||||
import type { MenuProps } from 'antd';
|
||||
import { Button, Dropdown, } from 'antd';
|
||||
import { history } from 'umi'
|
||||
import { useTranslation, Trans } from 'react-i18next'
|
||||
import { Button, Dropdown } from 'antd';
|
||||
import React, { useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { history } from 'umi';
|
||||
|
||||
const App: React.FC = () => {
|
||||
const { t } = useTranslation()
|
||||
const logout = () => { history.push('/login') }
|
||||
const toSetting = () => { history.push('/setting') }
|
||||
const items: MenuProps['items'] = useMemo(() => {
|
||||
return [
|
||||
{
|
||||
key: '1',
|
||||
label: (
|
||||
<Button type="text" onClick={logout}>{t('header.logout')}</Button>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: '2',
|
||||
label: (
|
||||
<Button type="text" onClick={toSetting}>{t('header.setting')}</Button>
|
||||
),
|
||||
},
|
||||
]
|
||||
}, []);
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (<>
|
||||
<Dropdown menu={{ items }} placement="bottomLeft" arrow>
|
||||
<img
|
||||
style={{ width: '50px', height: '50px', borderRadius: '25px' }}
|
||||
src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"
|
||||
/>
|
||||
</Dropdown>
|
||||
</>)
|
||||
}
|
||||
const logout = () => {
|
||||
authorizationUtil.removeAll();
|
||||
history.push('/login');
|
||||
};
|
||||
|
||||
export default App;
|
||||
const toSetting = () => {
|
||||
history.push('/setting');
|
||||
};
|
||||
|
||||
const items: MenuProps['items'] = useMemo(() => {
|
||||
return [
|
||||
{
|
||||
key: '1',
|
||||
label: (
|
||||
<Button type="text" onClick={logout}>
|
||||
{t('header.logout')}
|
||||
</Button>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: '2',
|
||||
label: (
|
||||
<Button type="text" onClick={toSetting}>
|
||||
{t('header.setting')}
|
||||
</Button>
|
||||
),
|
||||
},
|
||||
];
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Dropdown menu={{ items }} placement="bottomLeft" arrow>
|
||||
<img
|
||||
style={{ width: '50px', height: '50px', borderRadius: '25px' }}
|
||||
src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"
|
||||
/>
|
||||
</Dropdown>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default App;
|
||||
|
||||
Reference in New Issue
Block a user