diff --git a/packages/client/src/components/document/reader/public/index.tsx b/packages/client/src/components/document/reader/public/index.tsx index 52995bc0..eec226b3 100644 --- a/packages/client/src/components/document/reader/public/index.tsx +++ b/packages/client/src/components/document/reader/public/index.tsx @@ -1,7 +1,20 @@ import React, { useMemo, useEffect } from 'react'; import cls from 'classnames'; -import { Layout, Nav, Space, Button, Typography, Skeleton, Input, Popover, Modal, BackTop } from '@douyinfe/semi-ui'; +import { + Layout, + Nav, + Space, + Button, + Typography, + Skeleton, + Input, + Popover, + Modal, + Breadcrumb, + BackTop, +} from '@douyinfe/semi-ui'; import { IconArticle } from '@douyinfe/semi-icons'; +import Link from 'next/link'; import { Seo } from 'components/seo'; import { LogoImage, LogoText } from 'components/logo'; import { DataRender } from 'components/data-render'; @@ -91,9 +104,14 @@ export const DocumentPublicReader: React.FC = ({ documentId, hideLogo = } loading={true} /> } normalContent={() => ( - - {data.title} - + + + + {data?.wiki?.name} + + + {data.title} + )} /> diff --git a/packages/client/src/components/document/share/index.tsx b/packages/client/src/components/document/share/index.tsx index 6c6f6742..24fb9a83 100644 --- a/packages/client/src/components/document/share/index.tsx +++ b/packages/client/src/components/document/share/index.tsx @@ -49,6 +49,25 @@ export const DocumentShare: React.FC = ({ documentId, render }) => { onCancel={() => toggleVisible(false)} maskClosable={false} style={{ maxWidth: '96vw' }} + footer={ + <> + + + {isPublic && ( + + )} + + } > = ({ icon, text, rightNode, href, isActive = false, hoverable = true }) => { +export const NavItem: React.FC = ({ + icon, + text, + rightNode, + href, + isActive = false, + hoverable = true, + openNewTab = false, +}) => { const right = rightNode ? {rightNode} : null; const content = ( <> @@ -32,7 +41,9 @@ export const NavItem: React.FC = ({ icon, text, rightNode, href, isActiv > {href ? ( - {content} + + {content} + ) : (
{content}
diff --git a/packages/client/src/components/wiki/tocs/index.tsx b/packages/client/src/components/wiki/tocs/index.tsx index cb3420c9..1b9b618b 100644 --- a/packages/client/src/components/wiki/tocs/index.tsx +++ b/packages/client/src/components/wiki/tocs/index.tsx @@ -1,6 +1,6 @@ import { useRouter } from 'next/router'; import { useEffect, useState } from 'react'; -import { Avatar, Button, Typography, Skeleton } from '@douyinfe/semi-ui'; +import { Avatar, Button, Typography, Skeleton, Tooltip } from '@douyinfe/semi-ui'; import { IconPlus } from '@douyinfe/semi-icons'; import { useWikiDetail, useWikiTocs } from 'data/wiki'; import { useToggle } from 'hooks/use-toggle'; @@ -13,6 +13,7 @@ import { EventEmitter } from 'helpers/event-emitter'; import { NavItem } from './NavItem'; import { Tree } from './tree'; import styles from './index.module.scss'; +import { isPublicWiki } from '@think/domains'; const em = new EventEmitter(); const EVENT_KEY = 'REFRESH_TOCS'; @@ -127,6 +128,45 @@ export const WikiTocs: React.FC = ({ isActive={pathname === '/wiki/[wikiId]/setting'} /> + + } + text={} + /> + } + error={wikiError} + normalContent={() => + isPublicWiki(wiki.status) ? ( + } + text={ + + 公开地址 + + } + href={{ + pathname: `/share/wiki/[wikiId]`, + query: { wikiId }, + }} + isActive={pathname === '/share/wiki/[wikiId]'} + openNewTab + /> + ) : null + } + /> + { */ export const usePublicDocument = (documentId: string) => { const [fetch] = useAsyncLoading(getPublicDocumentDetail); - const [document, setDocument] = useState(null); + const [document, setDocument] = useState<(IDocument & { createUse: IUser; wiki: IWiki }) | null>(null); const [error, setError] = useState<(Error & { statusCode?: number }) | null>(null); const loading = !document && !error; diff --git a/packages/server/src/services/document.service.ts b/packages/server/src/services/document.service.ts index 04aa7d72..5469192b 100644 --- a/packages/server/src/services/document.service.ts +++ b/packages/server/src/services/document.service.ts @@ -552,8 +552,9 @@ export class DocumentService { await this.viewService.create({ userId: 'public', documentId, userAgent }); const views = await this.viewService.getDocumentTotalViews(documentId); const createUser = await this.userService.findById(document.createUserId); + const wiki = await this.wikiService.getPublicWikiDetail(document.wikiId); - return { ...document, views, createUser }; + return { ...document, views, wiki, createUser }; } /**