diff --git a/themes/hexo/components/Card.js b/themes/hexo/components/Card.js
index 26c3093a..285554ca 100644
--- a/themes/hexo/components/Card.js
+++ b/themes/hexo/components/Card.js
@@ -1,7 +1,7 @@
const Card = ({ children, headerSlot, className }) => {
return
<>{headerSlot}>
-
diff --git a/themes/hexo/components/TopNav.js b/themes/hexo/components/TopNav.js
index 4e020cba..374f59ce 100644
--- a/themes/hexo/components/TopNav.js
+++ b/themes/hexo/components/TopNav.js
@@ -18,18 +18,32 @@ let windowTop = 0
* @returns
*/
const TopNav = props => {
+ const searchDrawer = useRef()
const { tags, currentTag, categories, currentCategory } = props
const { locale } = useGlobal()
- const searchDrawer = useRef()
const { isDarkMode } = useGlobal()
const router = useRouter()
+ const [isOpen, changeShow] = useState(false)
+
+ const toggleMenuOpen = () => {
+ changeShow(!isOpen)
+ }
+
+ // 监听滚动
+ useEffect(() => {
+ scrollTrigger()
+ window.addEventListener('scroll', scrollTrigger)
+ return () => {
+ window.removeEventListener('scroll', scrollTrigger)
+ }
+ }, [])
+
const scrollTrigger = () => {
requestAnimationFrame(() => {
const scrollS = window.scrollY
const nav = document.querySelector('#sticky-nav')
const header = document.querySelector('#header')
- const showNav = scrollS <= windowTop || scrollS < 5 || (header && scrollS <= header.clientHeight)// 非首页无大图时影藏顶部 滚动条置顶时隐藏
// 是否将导航栏透明
const navTransparent = (scrollS < document.documentElement.clientHeight - 12 && router.route === '/') || scrollS < 300 // 透明导航条的条件
@@ -47,6 +61,7 @@ const TopNav = props => {
nav && nav.classList.replace('transparent', 'dark:bg-hexo-black-gray')
}
+ const showNav = scrollS <= windowTop || scrollS < 5 || (header && scrollS <= header.clientHeight)// 非首页无大图时影藏顶部 滚动条置顶时隐藏
if (!showNav) {
nav && nav.classList.replace('top-0', '-top-20')
windowTop = scrollS
@@ -70,21 +85,6 @@ const TopNav = props => {
}
}
- const [isOpen, changeShow] = useState(false)
-
- const toggleMenuOpen = () => {
- changeShow(!isOpen)
- }
-
- // 监听滚动
- useEffect(() => {
- scrollTrigger()
- window.addEventListener('scroll', scrollTrigger)
- return () => {
- window.removeEventListener('scroll', scrollTrigger)
- }
- }, [])
-
const searchDrawerSlot = <>
{categories && (
@@ -127,7 +127,7 @@ const TopNav = props => {
{/* 导航栏 */}
-
+
diff --git a/themes/matery/LayoutBase.js b/themes/matery/LayoutBase.js
index 2b32b468..4a1bbc51 100644
--- a/themes/matery/LayoutBase.js
+++ b/themes/matery/LayoutBase.js
@@ -23,14 +23,14 @@ const LayoutBase = props => {
const scrollListener = () => {
requestAnimationFrame(() => {
- const targetRef = document.getElementById('wrapper')
- const clientHeight = targetRef?.clientHeight
+ // const targetRef = document.getElementById('wrapper')
+ // const clientHeight = targetRef?.clientHeight
const scrollY = window.pageYOffset
- const fullHeight = clientHeight - window.outerHeight
- let per = parseFloat(((scrollY / fullHeight) * 100).toFixed(0))
- if (per > 100) per = 100
- const shouldShow = scrollY > 300 && per > 0
-
+ // const fullHeight = clientHeight - window.outerHeight
+ // let per = parseFloat(((scrollY / fullHeight) * 100).toFixed(0))
+ // if (per > 100) per = 100
+ const shouldShow = scrollY > 300
+ console.log(scrollY)
if (shouldShow !== show) {
switchShow(shouldShow)
}
@@ -40,7 +40,7 @@ const LayoutBase = props => {
useEffect(() => {
document.addEventListener('scroll', scrollListener)
return () => document.removeEventListener('scroll', scrollListener)
- }, [show])
+ }, [])
return (
@@ -67,12 +67,8 @@ const LayoutBase = props => {
{/* 右下角悬浮 */}
-
-
+
diff --git a/themes/matery/LayoutSlug.js b/themes/matery/LayoutSlug.js
index 5c076f7b..65cbabbc 100644
--- a/themes/matery/LayoutSlug.js
+++ b/themes/matery/LayoutSlug.js
@@ -1,4 +1,4 @@
-import React from 'react'
+import React, { useEffect } from 'react'
import { ArticleLock } from './components/ArticleLock'
import HeaderArticle from './components/HeaderArticle'
import LayoutBase from './LayoutBase'
@@ -16,16 +16,18 @@ export const LayoutSlug = props => {
const [show, switchShow] = React.useState(false)
const scrollListener = () => {
- const scrollY = window.pageYOffset
- const shouldShow = scrollY > 220 && post?.toc?.length > 0
- if (shouldShow !== show) {
- switchShow(shouldShow)
- }
+ requestAnimationFrame(() => {
+ const scrollY = window.pageYOffset
+ const shouldShow = scrollY > 220 && post?.toc?.length > 0
+ if (shouldShow !== show) {
+ switchShow(shouldShow)
+ }
+ })
}
- React.useEffect(() => {
+ useEffect(() => {
document.addEventListener('scroll', scrollListener)
return () => document.removeEventListener('scroll', scrollListener)
- }, [show])
+ }, [])
if (!post) {
return
{
>
}
- return (
-
}
- {...props}
- showCategory={false}
- showTag={false}
- >
+ return (
}
+ {...props}
+ showCategory={false}
+ showTag={false}
+ >
-
-
-
- {lock &&
}
+
+
+
+ {lock &&
}
- {!lock &&
- { post?.type && post?.type === 'Post' && <>
-
-
- >}
-
-
-
- {/* Notion文章主体 */}
-
-
-
-
- {post.type === 'Post' && }
-
-
-
-
-
- {/* 评论互动 */}
-
-
-
+ {!lock &&
+ {post?.type && post?.type === 'Post' && <>
+
+
+ >}
-
}
-
- {post.type === 'Post' &&
}
+
+
+ {/* Notion文章主体 */}
+
- {post?.toc?.length > 0 &&
-
-
-
-
-
+
+
+ {/* 文章版权说明 */}
+ {post.type === 'Post' &&
}
+
+
+
+
+
+ {/* 评论互动 */}
+
+
+
}
-
-
-
-
+ {/* 文章推荐 */}
+ {post.type === 'Post' && }
+
+ {/* 文章目录 */}
+ {post?.toc?.length > 0 && }
-
+
+
+
+
+
+
+
)
}
diff --git a/themes/matery/components/BlogPostCard.js b/themes/matery/components/BlogPostCard.js
index 34646b1c..b809c723 100644
--- a/themes/matery/components/BlogPostCard.js
+++ b/themes/matery/components/BlogPostCard.js
@@ -15,10 +15,9 @@ const BlogPostCard = ({ post, showSummary, siteInfo }) => {
+ className="w-full mb-4 h-full overflow-auto shadow-md border dark:border-black rounded-xl bg-white dark:bg-hexo-black-gray">
{/* 固定高度 ,空白用图片拉升填充 */}
diff --git a/themes/matery/components/BlogPostListScroll.js b/themes/matery/components/BlogPostListScroll.js
index 555e950f..2a611e98 100644
--- a/themes/matery/components/BlogPostListScroll.js
+++ b/themes/matery/components/BlogPostListScroll.js
@@ -42,10 +42,10 @@ const BlogPostListScroll = ({ posts = [], currentSearch, showSummary = CONFIG_MA
// 监听滚动
React.useEffect(() => {
- window.addEventListener('scroll', scrollTrigger)
- return () => {
- window.removeEventListener('scroll', scrollTrigger)
- }
+ // window.addEventListener('scroll', scrollTrigger)
+ // return () => {
+ // window.removeEventListener('scroll', scrollTrigger)
+ // }
})
const targetRef = React.useRef(null)
diff --git a/themes/matery/components/Catalog.js b/themes/matery/components/Catalog.js
index 9f650f9b..33bebb0a 100644
--- a/themes/matery/components/Catalog.js
+++ b/themes/matery/components/Catalog.js
@@ -13,8 +13,8 @@ const Catalog = ({ toc }) => {
const { locale } = useGlobal()
// 监听滚动事件
React.useEffect(() => {
- window.addEventListener('scroll', actionSectionScrollSpy)
actionSectionScrollSpy()
+ window.addEventListener('scroll', actionSectionScrollSpy)
return () => {
window.removeEventListener('scroll', actionSectionScrollSpy)
}
diff --git a/themes/matery/components/Header.js b/themes/matery/components/Header.js
index 3f062dde..5ad30675 100644
--- a/themes/matery/components/Header.js
+++ b/themes/matery/components/Header.js
@@ -32,13 +32,14 @@ const Header = props => {
if (enableAutoScroll) {
scrollTrigger()
window.addEventListener('scroll', scrollTrigger)
- } window.addEventListener('resize', updateHeaderHeight)
+ }
+ window.addEventListener('resize', updateHeaderHeight)
return () => {
if (enableAutoScroll) {
window.removeEventListener('scroll', scrollTrigger)
} window.removeEventListener('resize', updateHeaderHeight)
}
- })
+ }, [])
const autoScrollEnd = () => {
if (autoScroll) {
diff --git a/themes/matery/components/HeaderArticle.js b/themes/matery/components/HeaderArticle.js
index e48160cb..6d8229c3 100644
--- a/themes/matery/components/HeaderArticle.js
+++ b/themes/matery/components/HeaderArticle.js
@@ -4,8 +4,7 @@ export default function HeaderArticle({ post, siteInfo }) {
return (