From e4fbf78de299c0f8b58a2dc57fa09a6a0722f2f3 Mon Sep 17 00:00:00 2001 From: hackrobot Date: Wed, 2 Apr 2025 06:52:46 -0500 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/book/index.scss | 42 +++++++++++++++++++++++++-------------- src/pages/book/index.tsx | 4 +++- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/pages/book/index.scss b/src/pages/book/index.scss index 9ecf6c8..7b3bbdd 100644 --- a/src/pages/book/index.scss +++ b/src/pages/book/index.scss @@ -1,11 +1,29 @@ // 在 src/index.scss 中引入 GitHub Markdown 主题 @import "github-markdown-css/github-markdown.css"; -.book_header_div{ + +// marktext的换行处理 +.markdown-body p, +.markdown-body blockquote, +.markdown-body ul, +.markdown-body ol, +.markdown-body dl, +.markdown-body table, +.markdown-body pre, +.markdown-body details { + margin-bottom: 10px; +} + +.markdown-body li>p { + margin-top: 0px; +} + + +.book_header_div { width: 100%; height: 80px; } -.book_header{ +.book_header { position: fixed; top: 0px; width: 100%; @@ -13,13 +31,13 @@ // background-color: aquamarine; // background-color: #f0f5ff; border-bottom: 2px solid #f0f5ff; - background-color: rgb(255 255 255/var(--tw-bg-opacity,1)); + background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1)); display: flex; flex-direction: row; align-items: center; justify-content: space-between; - .book_header_left{ + .book_header_left { width: 100px; display: flex; flex-direction: row; @@ -27,17 +45,15 @@ justify-content: center; color: #69b1ff; } - .book_header_middle{ + .book_header_middle { flex: 1; display: flex; flex-direction: row; align-items: center; justify-content: center; color: #69b1ff; - - } - .book_header_right{ + .book_header_right { width: 100px; // background-color: yellow; display: flex; @@ -45,10 +61,7 @@ align-items: center; justify-content: center; color: #69b1ff; - - } - } .Book { padding: 40px; @@ -71,13 +84,12 @@ // background-color: aqua; .at-list__item-container { - .at-list__item-content {} + .at-list__item-content { + } } } } } - - } @media (min-width: 1536px) { @@ -110,4 +122,4 @@ background-color: greenyellow; } } -} \ No newline at end of file +} diff --git a/src/pages/book/index.tsx b/src/pages/book/index.tsx index b142a62..d479cfe 100644 --- a/src/pages/book/index.tsx +++ b/src/pages/book/index.tsx @@ -70,7 +70,9 @@ const Book = () => { const handleJump = (text) => { const h1Elements = contentRef.current.querySelectorAll("h1"); for (let h1 of h1Elements) { - if (h1.textContent === text) { + if (h1.textContent.trim() === text.trim()) { + console.log("Current h1 text:", h1.textContent); // 输出每个 h1 的文本 + // if (h1.textContent === text) { h1.scrollIntoView({ behavior: "smooth" }); break; }