client: fix nav-item active judge

pull/64/head
fantasticit 2022-05-31 22:36:04 +08:00
parent 0e66e9663a
commit 3c1bc0b08f
1 changed files with 2 additions and 3 deletions

View File

@ -23,13 +23,12 @@ interface IProps {
const { Text } = Typography; const { Text } = Typography;
export const WikiTocs: React.FC<IProps> = ({ export const WikiTocs: React.FC<IProps> = ({
// pageTitle,
wikiId, wikiId,
documentId = null, documentId = null,
docAsLink = '/wiki/[wikiId]/document/[documentId]', docAsLink = '/wiki/[wikiId]/document/[documentId]',
getDocLink = (documentId) => `/wiki/${wikiId}/document/${documentId}`, getDocLink = (documentId) => `/wiki/${wikiId}/document/${documentId}`,
}) => { }) => {
const { pathname } = useRouter(); const { pathname, query } = useRouter();
const { data: wiki, loading: wikiLoading, error: wikiError } = useWikiDetail(wikiId); const { data: wiki, loading: wikiLoading, error: wikiError } = useWikiDetail(wikiId);
const { data: tocs, loading: tocsLoading, error: tocsError, refresh } = useWikiTocs(wikiId); const { data: tocs, loading: tocsLoading, error: tocsError, refresh } = useWikiTocs(wikiId);
const [parentIds, setParentIds] = useState<Array<string>>([]); const [parentIds, setParentIds] = useState<Array<string>>([]);
@ -91,7 +90,7 @@ export const WikiTocs: React.FC<IProps> = ({
pathname: `/wiki/[wikiId]`, pathname: `/wiki/[wikiId]`,
query: { wikiId }, query: { wikiId },
}} }}
isActive={pathname === '/wiki/[wikiId]'} isActive={pathname === '/wiki/[wikiId]' || (query && wiki && query.documentId === wiki.homeDocumentId)}
/> />
<NavItem <NavItem