From 6cbe623e97cbea4fb4b87a0406ac0d4a74c5b13d Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Fri, 5 Nov 2021 17:21:59 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E6=AE=B5=E9=80=82=E9=85=8D?= =?UTF-8?q?=EF=BC=8C=E5=8A=A0=E5=85=A5=E6=B7=B1=E5=A4=9C=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/BlogPostListEmpty.js | 16 ++++------------ components/BlogPostListScroll.js | 4 ++-- components/DarkModeButton.js | 2 +- components/JumpToTopButton.js | 13 ++++++------- components/SideBar.js | 3 ++- components/TagsBar.js | 2 +- components/TocDrawerButton.js | 8 ++++---- components/TopNav.js | 2 +- layouts/BaseLayout.js | 31 ++++++++++++++++++++++++++----- 9 files changed, 47 insertions(+), 34 deletions(-) diff --git a/components/BlogPostListEmpty.js b/components/BlogPostListEmpty.js index 0cca9919..37982cd9 100644 --- a/components/BlogPostListEmpty.js +++ b/components/BlogPostListEmpty.js @@ -6,18 +6,10 @@ import { useEffect } from 'react' * @returns {JSX.Element} * @constructor */ -const BlogPostListEmpty = () => { - const router = useRouter() - useEffect(() => { - setTimeout(() => { - router.push('/').then(() => { - console.log('空博客列表跳回首页') - }) - }, 3000) - }) - return
-
-

没有文章了,3秒后返回首页

+const BlogPostListEmpty = ({ currentSearch }) => { + return
+
+

没有找到文章 {(currentSearch &&

{currentSearch}
)}

} diff --git a/components/BlogPostListScroll.js b/components/BlogPostListScroll.js index e1092954..5d8d7a29 100644 --- a/components/BlogPostListScroll.js +++ b/components/BlogPostListScroll.js @@ -49,9 +49,9 @@ const BlogPostListScroll = ({ posts = [], tags, currentSearch, currentCategory, const targetRef = useRef(null) if (!postsToShow || postsToShow.length === 0) { - return + return } else { - return
+ return
{currentCategory && (
diff --git a/components/DarkModeButton.js b/components/DarkModeButton.js index 8f7325c7..7450ac3d 100644 --- a/components/DarkModeButton.js +++ b/components/DarkModeButton.js @@ -9,7 +9,7 @@ const DarkModeButton = () => { saveTheme(newTheme) changeTheme(newTheme) } - return
+ return
diff --git a/components/JumpToTopButton.js b/components/JumpToTopButton.js index 73dd706a..71dea964 100644 --- a/components/JumpToTopButton.js +++ b/components/JumpToTopButton.js @@ -1,5 +1,4 @@ -import React, { useCallback, useEffect, useState } from 'react' -import throttle from 'lodash.throttle' +import React, { useEffect, useState } from 'react' import { useGlobal } from '@/lib/global' /** @@ -33,15 +32,15 @@ const JumpToTopButton = ({ targetRef, showPercent = true }) => { }, [show]) return ( -
-
+
+
window.scrollTo({ top: 0, behavior: 'smooth' })} style={{ boxShadow: 'rgba(41, 50, 60, 0.5) 0px 2px 16px', borderRadius: '28px' }} - className={(show ? 'animate__fadeInUp' : 'animate__fadeOutUp') + ' bg-gray-700 px-2.5 py-2 cursor-pointer animate__animated animate__faster shadow-2xl'}> + className={(show ? 'animate__fadeInUp' : 'animate__fadeOutUp') + ' bg-gray-700 px-1 py-1 cursor-pointer animate__animated animate__faster shadow-2xl'}>
-
- {showPercent && (
 {percent}%
)} +
+ {showPercent && (
{percent}
)}
diff --git a/components/SideBar.js b/components/SideBar.js index 9c8b43f9..7f3ba827 100644 --- a/components/SideBar.js +++ b/components/SideBar.js @@ -6,6 +6,7 @@ import LatestPosts from '@/components/LatestPosts' import PostsCategories from '@/components/PostsCategories' import Toc from '@/components/Toc' import SearchInput from '@/components/SearchInput' +import DarkModeButton from '@/components/DarkModeButton' /** * 侧边栏 @@ -28,7 +29,7 @@ const SideBar = ({ tags, currentTag, post, posts, categories, currentCategory }) }).slice(0, 5) } - return