mirror of https://github.com/fantasticit/think.git
client: improve component render time
parent
5e6f283032
commit
d1f51707a8
|
@ -1,5 +1,5 @@
|
|||
import { IconArticle, IconChevronLeft } from '@douyinfe/semi-icons';
|
||||
import { Button, Nav, Popover, Skeleton, Space, Spin, Tooltip, Typography } from '@douyinfe/semi-ui';
|
||||
import { IconChevronLeft } from '@douyinfe/semi-icons';
|
||||
import { Button, Nav, Skeleton, Space, Spin, Tooltip, Typography } from '@douyinfe/semi-ui';
|
||||
import { DataRender } from 'components/data-render';
|
||||
import { Divider } from 'components/divider';
|
||||
import { DocumentCollaboration } from 'components/document/collaboration';
|
||||
|
@ -50,16 +50,20 @@ export const DocumentEditor: React.FC<IProps> = ({ documentId }) => {
|
|||
});
|
||||
}, [document, documentId]);
|
||||
|
||||
const actions = (
|
||||
<Space>
|
||||
{document && authority.readable && (
|
||||
<DocumentCollaboration key="collaboration" wikiId={document.wikiId} documentId={documentId} />
|
||||
)}
|
||||
<DocumentShare key="share" documentId={documentId} />
|
||||
<DocumentVersion key="version" documentId={documentId} onSelect={triggerUseDocumentVersion} />
|
||||
<DocumentStar key="star" documentId={documentId} />
|
||||
<DocumentStyle />
|
||||
</Space>
|
||||
const actions = useMemo(
|
||||
() =>
|
||||
docAuthLoading ? null : (
|
||||
<Space>
|
||||
{document && authority.readable && (
|
||||
<DocumentCollaboration key="collaboration" wikiId={document.wikiId} documentId={documentId} />
|
||||
)}
|
||||
<DocumentShare key="share" documentId={documentId} />
|
||||
<DocumentVersion key="version" documentId={documentId} onSelect={triggerUseDocumentVersion} />
|
||||
<DocumentStar key="star" documentId={documentId} />
|
||||
<DocumentStyle />
|
||||
</Space>
|
||||
),
|
||||
[docAuthLoading, documentId, document, authority]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
@ -76,27 +76,28 @@ export const DocumentReader: React.FC<IProps> = ({ documentId }) => {
|
|||
}, [document]);
|
||||
|
||||
const actions = useMemo(
|
||||
() => (
|
||||
<Space>
|
||||
{document && authority.readable && (
|
||||
<DocumentCollaboration key="collaboration" wikiId={document.wikiId} documentId={documentId} />
|
||||
)}
|
||||
{authority && authority.editable && (
|
||||
<Tooltip key="edit" content="编辑" position="bottom">
|
||||
<Button icon={<IconEdit />} onMouseDown={gotoEdit} />
|
||||
</Tooltip>
|
||||
)}
|
||||
{authority && authority.readable && (
|
||||
<>
|
||||
<DocumentShare key="share" documentId={documentId} />
|
||||
<DocumentVersion key="version" documentId={documentId} />
|
||||
<DocumentStar key="star" documentId={documentId} />
|
||||
</>
|
||||
)}
|
||||
<DocumentStyle />
|
||||
</Space>
|
||||
),
|
||||
[document, documentId, authority, gotoEdit]
|
||||
() =>
|
||||
docAuthLoading ? null : (
|
||||
<Space>
|
||||
{document && authority.readable && (
|
||||
<DocumentCollaboration key="collaboration" wikiId={document.wikiId} documentId={documentId} />
|
||||
)}
|
||||
{authority && authority.editable && (
|
||||
<Tooltip key="edit" content="编辑" position="bottom">
|
||||
<Button icon={<IconEdit />} onMouseDown={gotoEdit} />
|
||||
</Tooltip>
|
||||
)}
|
||||
{authority && authority.readable && (
|
||||
<>
|
||||
<DocumentShare key="share" documentId={documentId} />
|
||||
<DocumentVersion key="version" documentId={documentId} />
|
||||
<DocumentStar key="star" documentId={documentId} />
|
||||
</>
|
||||
)}
|
||||
<DocumentStyle />
|
||||
</Space>
|
||||
),
|
||||
[docAuthLoading, document, documentId, authority, gotoEdit]
|
||||
);
|
||||
|
||||
const editBtnStyle = useMemo(() => getEditBtnStyle(isMobile ? 16 : 100), [isMobile]);
|
||||
|
|
|
@ -263,7 +263,7 @@ export const useWikiTocs = (wikiId) => {
|
|||
const { data, error, refetch } = useQuery(
|
||||
WikiApiDefinition.getTocsById.client(wikiId),
|
||||
() => (wikiId ? getWikiTocs(wikiId) : null),
|
||||
{ staleTime: 3000 }
|
||||
{ staleTime: 2000 }
|
||||
);
|
||||
const loading = !data && !error;
|
||||
|
||||
|
|
Loading…
Reference in New Issue