diff --git a/packages/client/src/components/document/reader/author.tsx b/packages/client/src/components/document/reader/author.tsx index 87dd930c..b16e8723 100644 --- a/packages/client/src/components/document/reader/author.tsx +++ b/packages/client/src/components/document/reader/author.tsx @@ -21,19 +21,19 @@ export const Author: React.FC = ({ document }) => { }} > - +

创建者: - {document.createUser && document.createUser.name} + {document && document.createUser && document.createUser.name}

最近更新日期: - + {' ⦁ '}阅读量: - {document.views} + {document && document.views}

diff --git a/packages/client/src/components/document/reader/public/index.tsx b/packages/client/src/components/document/reader/public/index.tsx index 31bdaa19..56a85ccb 100644 --- a/packages/client/src/components/document/reader/public/index.tsx +++ b/packages/client/src/components/document/reader/public/index.tsx @@ -25,7 +25,6 @@ import { IsOnMobile } from 'hooks/use-on-mobile'; import Link from 'next/link'; import React, { useCallback, useMemo, useRef } from 'react'; import { createPortal } from 'react-dom'; -import { DocumentSkeleton } from 'tiptap/components/skeleton'; import { CollaborationEditor } from 'tiptap/editor'; import { Author } from '../author'; @@ -72,6 +71,57 @@ export const DocumentPublicReader: React.FC = ({ documentId, hideLogo = if (!documentId) return null; + const content = useMemo(() => { + if (error) { + // @ts-ignore + if (error.statusCode === 400) { + return ( +
+ +
($form.current = formApi)} + labelPosition="left" + onSubmit={handleOk} + layout="horizontal" + > + + + +
+ ); + } + // @ts-ignore + return {error.message || error || '未知错误'}; + } + + return ( +
+ {data && } + {mounted && } + + document.querySelector('#js-share-document-editor-container').parentNode} + /> +
+ ) + }, [error, data, mounted]) + return (
@@ -111,62 +161,7 @@ export const DocumentPublicReader: React.FC = ({ documentId, hideLogo =
- { - if (error.statusCode === 400) { - return ( -
- -
($form.current = formApi)} - labelPosition="left" - onSubmit={handleOk} - layout="horizontal" - > - - - -
- ); - } - return {error.message || error || '未知错误'}; - }} - loadingContent={ -
- -
- } - normalContent={() => { - return ( -
- - {mounted && } - - document.querySelector('#js-share-document-editor-container').parentNode} - /> -
- ); - }} - /> + {content}
); diff --git a/packages/client/src/tiptap/editor/collaboration/collaboration/type.ts b/packages/client/src/tiptap/editor/collaboration/collaboration/type.ts index 06e68704..39a0e62e 100644 --- a/packages/client/src/tiptap/editor/collaboration/collaboration/type.ts +++ b/packages/client/src/tiptap/editor/collaboration/collaboration/type.ts @@ -28,12 +28,6 @@ export interface ICollaborationEditorProps { */ user: ILoginUser | null; - /** - * 初始内容 - * websocket 连接比较耗时,可以先用初始内容展现 - */ - initialContent?: string; - /** * 文档标题变动 */