client: update documents when need refresh

This commit is contained in:
fantasticit 2022-06-05 21:11:01 +08:00
parent 1407117eb0
commit 287fdb3a66
2 changed files with 10 additions and 3 deletions

View File

@ -292,6 +292,15 @@ export const useWikiDocuments = (wikiId) => {
const { data, error, isLoading, refetch } = useQuery(WikiApiDefinition.getDocumentsById.client(wikiId), () => const { data, error, isLoading, refetch } = useQuery(WikiApiDefinition.getDocumentsById.client(wikiId), () =>
getWikiDocuments(wikiId) getWikiDocuments(wikiId)
); );
useEffect(() => {
event.on(REFRESH_TOCS, refetch);
return () => {
event.off(REFRESH_TOCS, refetch);
};
}, [refetch]);
return { data, loading: isLoading, error, refresh: refetch }; return { data, loading: isLoading, error, refresh: refetch };
}; };

View File

@ -1,4 +1,4 @@
import { List, TabPane, Tabs, Typography } from '@douyinfe/semi-ui'; import { List, TabPane, Tabs } from '@douyinfe/semi-ui';
import { IWiki, WikiApiDefinition } from '@think/domains'; import { IWiki, WikiApiDefinition } from '@think/domains';
import { DataRender } from 'components/data-render'; import { DataRender } from 'components/data-render';
import { DocumentCard, DocumentCardPlaceholder } from 'components/document/card'; import { DocumentCard, DocumentCardPlaceholder } from 'components/document/card';
@ -20,8 +20,6 @@ interface IProps {
wikiId: string; wikiId: string;
} }
const { Title } = Typography;
const grid = { const grid = {
gutter: 16, gutter: 16,
xs: 24, xs: 24,