diff --git a/components/Header.js b/components/Header.js index bd9776a9..23c0bba2 100644 --- a/components/Header.js +++ b/components/Header.js @@ -12,9 +12,14 @@ import Typed from 'typed.js' export default function Header () { const [typed, changeType] = useState() useEffect(() => { - if (!typed) { + if (!typed && window && document.getElementById('typed')) { changeType(new Typed('#typed', { - stringsElement: '#typed-strings', typeSpeed: 200, showCursor: false + strings: ['Hi,我是一个程序员', 'Hi,我是一个打工人', 'Hi,我是一个干饭人', '欢迎来到我的博客🎉'], + typeSpeed: 200, + backSpeed: 100, + backDelay: 400, + showCursor: true, + smartBackspace: true })) } }) @@ -23,8 +28,20 @@ export default function Header () { } const { theme } = useGlobal() - // 监听滚动自动分页加载 + // 监听滚动 + let windowTop = 0 const scrollTrigger = useCallback(throttle(() => { + if (window.scrollY > windowTop & window.scrollY < window.innerHeight) { + scrollToCenter() + } + if (window.scrollY < windowTop & window.scrollY < window.innerHeight) { + window.scroll({ top: 0, behavior: 'smooth' }) + } + windowTop = window.scrollY + updateTopNav() + }, 500)) + + const updateTopNav = () => { if (theme !== 'dark') { const stickyNavElement = document.getElementById('sticky-nav') if (window.scrollY < window.innerHeight) { @@ -33,27 +50,26 @@ export default function Header () { stickyNavElement.classList.remove('dark') } } - }, 500)) + } // 监听滚动 useEffect(() => { - scrollTrigger() + updateTopNav() window.addEventListener('scroll', scrollTrigger) return () => { window.removeEventListener('scroll', scrollTrigger) } }) - return
-
-
-

唐风集里,收卷波澜。

-
-
+ return
+ +
+
-
+ +
-
+
} diff --git a/components/LatestPostsGroup.js b/components/LatestPostsGroup.js index 27b132c8..06ccddd4 100644 --- a/components/LatestPostsGroup.js +++ b/components/LatestPostsGroup.js @@ -34,7 +34,7 @@ const LatestPostsGroup = ({ posts, sliceCount = 5 }) => {
+ 'hover:text-blue-500 dark:hover:text-blue-400 cursor-pointer hover:underline truncate' }> {post.title}
diff --git a/components/SideAreaRight.js b/components/SideAreaRight.js index 5d827e8f..5cb5a387 100644 --- a/components/SideAreaRight.js +++ b/components/SideAreaRight.js @@ -74,7 +74,7 @@ const SideAreaRight = ({ -
+
{showToc && (
@@ -124,7 +124,7 @@ const SideAreaRight = ({ )} {/* 分类 */} - {post && categories && ( + {categories && (
{locale.COMMON.CATEGORY}
diff --git a/components/TopNav.js b/components/TopNav.js index cee4c089..f5a0b912 100644 --- a/components/TopNav.js +++ b/components/TopNav.js @@ -22,7 +22,7 @@ const TopNav = ({ tags, currentTag, post, posts, categories, currentCategory }) alt={BLOG.title} layout='fill' loading='lazy' - src='/avatar.svg' + src='/favicon.svg' className='border-black' />
diff --git a/layouts/BaseLayout.js b/layouts/BaseLayout.js index deb2e576..0efc1bfb 100644 --- a/layouts/BaseLayout.js +++ b/layouts/BaseLayout.js @@ -10,6 +10,8 @@ import { useGlobal } from '@/lib/global' import throttle from 'lodash.throttle' import PropTypes from 'prop-types' import React, { useCallback, useEffect, useRef } from 'react' +import { useRouter } from 'next/router' +import Header from '@/components/Header' /** * 基础布局 采用左右两侧布局,移动端使用顶部导航栏 * @param children @@ -63,6 +65,7 @@ const BaseLayout = ({ }, []) const { onLoading } = useGlobal() const targetRef = useRef(null) + const router = useRouter() return (
@@ -71,9 +74,10 @@ const BaseLayout = ({ {/* 顶部导航栏 */} - {/* {useRouter().asPath === '/' &&
} */} + {/* 首页头图 */} + {router.asPath === '/' &&
} -
+
{/*
@@ -89,7 +93,7 @@ const BaseLayout = ({
diff --git a/public/bg_image.jpg b/public/bg_image.jpg new file mode 100644 index 00000000..d00e604c Binary files /dev/null and b/public/bg_image.jpg differ diff --git a/styles/globals.css b/styles/globals.css index f82ddd54..e8731ca2 100644 --- a/styles/globals.css +++ b/styles/globals.css @@ -151,12 +151,12 @@ nav { .glassmorphism{ background: rgba(255, 255, 255, 0.2); - -webkit-backdrop-filter: blur(5px); - backdrop-filter: blur(5px); + -webkit-backdrop-filter: blur(3px); + backdrop-filter: blur(3px); } .dark .glassmorphism{ - background: rgba(31, 41, 55, .5); - -webkit-backdrop-filter: blur(5px); - backdrop-filter: blur(5px); + background: rgba(31, 41, 55, 0.2); + -webkit-backdrop-filter: blur(3px); + backdrop-filter: blur(3px); } \ No newline at end of file