fix: after logging out and entering the knowledge base page again, the data before still exists #1306 (#1597)

### What problem does this PR solve?

fix: after logging out and entering the knowledge base page again, the
data before still exists #1306
### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
balibabu
2024-07-19 09:07:36 +08:00
committed by GitHub
parent cf4fff64f8
commit fb21efd77d
13 changed files with 175 additions and 138 deletions

View File

@ -1,5 +1,4 @@
import ModalManager from '@/components/modal-manager';
import { useFetchKnowledgeList } from '@/hooks/knowledge-hooks';
import { useNextFetchKnowledgeList } from '@/hooks/knowledge-hooks';
import { useSelectUserInfo } from '@/hooks/user-setting-hooks';
import { PlusOutlined, SearchOutlined } from '@ant-design/icons';
import { Button, Empty, Flex, Input, Space, Spin } from 'antd';
@ -7,15 +6,22 @@ import KnowledgeCard from './knowledge-card';
import KnowledgeCreatingModal from './knowledge-creating-modal';
import { useTranslation } from 'react-i18next';
import { useSearchKnowledge, useSelectKnowledgeListByKeywords } from './hooks';
import { useSaveKnowledge, useSearchKnowledge } from './hooks';
import styles from './index.less';
const KnowledgeList = () => {
const { searchString, handleInputChange } = useSearchKnowledge();
const { loading } = useFetchKnowledgeList();
const list = useSelectKnowledgeListByKeywords(searchString);
const { loading, list: data } = useNextFetchKnowledgeList();
const list = data.filter((x) => x.name.includes(searchString));
const userInfo = useSelectUserInfo();
const { t } = useTranslation('translation', { keyPrefix: 'knowledgeList' });
const {
visible,
hideModal,
showModal,
onCreateOk,
loading: creatingLoading,
} = useSaveKnowledge();
return (
<Flex className={styles.knowledge} vertical flex={1}>
@ -36,26 +42,14 @@ const KnowledgeList = () => {
prefix={<SearchOutlined />}
/>
<ModalManager>
{({ visible, hideModal, showModal }) => (
<>
<Button
type="primary"
icon={<PlusOutlined />}
onClick={() => {
showModal();
}}
className={styles.topButton}
>
{t('createKnowledgeBase')}
</Button>
<KnowledgeCreatingModal
visible={visible}
hideModal={hideModal}
></KnowledgeCreatingModal>
</>
)}
</ModalManager>
<Button
type="primary"
icon={<PlusOutlined />}
onClick={showModal}
className={styles.topButton}
>
{t('createKnowledgeBase')}
</Button>
</Space>
</div>
<Spin spinning={loading}>
@ -75,6 +69,12 @@ const KnowledgeList = () => {
)}
</Flex>
</Spin>
<KnowledgeCreatingModal
loading={creatingLoading}
visible={visible}
hideModal={hideModal}
onOk={onCreateOk}
></KnowledgeCreatingModal>
</Flex>
);
};