From 064dff131aad61305aadb7480b56048c6455dbba Mon Sep 17 00:00:00 2001 From: lilingfengdev Date: Fri, 11 Oct 2024 20:31:12 +0800 Subject: [PATCH] fix some --- .../DocItem/Layout/{index.tsx => index.js} | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) rename src/theme/DocItem/Layout/{index.tsx => index.js} (95%) diff --git a/src/theme/DocItem/Layout/index.tsx b/src/theme/DocItem/Layout/index.js similarity index 95% rename from src/theme/DocItem/Layout/index.tsx rename to src/theme/DocItem/Layout/index.js index 53d7b42dc..d368f0cc4 100644 --- a/src/theme/DocItem/Layout/index.tsx +++ b/src/theme/DocItem/Layout/index.js @@ -11,40 +11,35 @@ import DocItemTOCDesktop from '@theme/DocItem/TOC/Desktop'; import DocItemContent from '@theme/DocItem/Content'; import DocBreadcrumbs from '@theme/DocBreadcrumbs'; import ContentVisibility from '@theme/ContentVisibility'; -import type {Props} from '@theme/DocItem/Layout'; +import styles from './styles.module.css'; import { FloatButton, Modal } from 'antd'; import { FilePdfOutlined, PrinterOutlined } from '@ant-design/icons'; - -import styles from './styles.module.css'; - /** * Decide if the toc should be rendered, on mobile or desktop viewports */ function useDocTOC() { const {frontMatter, toc} = useDoc(); const windowSize = useWindowSize(); - const hidden = frontMatter.hide_table_of_contents; const canRender = !hidden && toc.length > 0; - const mobile = canRender ? : undefined; - const desktop = canRender && (windowSize === 'desktop' || windowSize === 'ssr') ? ( ) : undefined; - return { hidden, mobile, desktop, }; } - -export default function DocItemLayout({children}: Props): JSX.Element { +export default function DocItemLayout({children}) { const docTOC = useDocTOC(); const {metadata} = useDoc(); + const printArticle = () => { + window.print(); + }; const downloadPDF = () => { Modal.info({ title: '下载PDF', @@ -60,9 +55,6 @@ export default function DocItemLayout({children}: Props): JSX.Element { }, }) }; - const printArticle = () => { - window.print(); - }; return (
@@ -81,9 +73,9 @@ export default function DocItemLayout({children}: Props): JSX.Element {
{docTOC.desktop &&
{docTOC.desktop}
} + } title="打印文档" onClick={printArticle}/> } title="下载PDF" onClick={downloadPDF}/> -
);