window.scrollTo({ top: 0, behavior: 'smooth' })} >
diff --git a/components/Progress.js b/components/Progress.js
index a46ae098..4c4adb9f 100644
--- a/components/Progress.js
+++ b/components/Progress.js
@@ -9,11 +9,12 @@ const Progress = ({ targetRef, showPercent = true }) => {
const currentRef = targetRef?.current || targetRef
const [percent, changePercent] = useState(0)
const scrollListener = () => {
- if (currentRef) {
- const clientHeight = currentRef ? (currentRef.clientHeight) : 0
+ const target = currentRef || document.getElementById('container')
+ if (target) {
+ const clientHeight = target.clientHeight
const scrollY = window.pageYOffset
const fullHeight = clientHeight - window.outerHeight
- let per = parseFloat(((scrollY / fullHeight * 100)).toFixed(0))
+ let per = parseFloat(((scrollY / fullHeight) * 100).toFixed(0))
if (per > 100) per = 100
if (per < 0) per = 0
changePercent(per)
@@ -25,11 +26,18 @@ const Progress = ({ targetRef, showPercent = true }) => {
return () => document.removeEventListener('scroll', scrollListener)
}, [percent])
- return (
-
- {showPercent &&
{percent}%
}
+ return (
+
+
+ {showPercent && (
+
{percent}%
+ )}
-
)
+
+ )
}
export default Progress
diff --git a/components/SideAreaLeft.js b/components/SideAreaLeft.js
index 77d6c66f..51c1bb81 100644
--- a/components/SideAreaLeft.js
+++ b/components/SideAreaLeft.js
@@ -44,7 +44,7 @@ const SideAreaLeft = ({ title, tags, currentTag, post, postCount, categories, cu
{showToc && (
-
+
)}
diff --git a/components/Toc.js b/components/Toc.js
index 4bd1aa21..676dbbd2 100644
--- a/components/Toc.js
+++ b/components/Toc.js
@@ -10,7 +10,7 @@ import Progress from './Progress'
* @returns {JSX.Element}
* @constructor
*/
-const Toc = ({ toc, targetRef }) => {
+const Toc = ({ toc }) => {
// 无目录就直接返回空
if (!toc || toc.length < 1) {
return <>>
@@ -54,7 +54,7 @@ const Toc = ({ toc, targetRef }) => {
return <>
-
+
>
}
diff --git a/components/TocDrawerButton.js b/components/TocDrawerButton.js
index e828290e..06dc454b 100644
--- a/components/TocDrawerButton.js
+++ b/components/TocDrawerButton.js
@@ -16,7 +16,7 @@ const TocDrawerButton = (props) => {
return <>>
}
const { locale } = useGlobal()
- return (
+ return (
)
}
diff --git a/layouts/BaseLayout.js b/layouts/BaseLayout.js
index 7418b0c4..a516fced 100644
--- a/layouts/BaseLayout.js
+++ b/layouts/BaseLayout.js
@@ -96,15 +96,16 @@ const BaseLayout = ({
-
-
-
-
-
- {floatSlot}
+ {/* 右下角悬浮 */}
+
-