diff --git a/components/Drawer.js b/components/Drawer.js deleted file mode 100644 index 7d0964f2..00000000 --- a/components/Drawer.js +++ /dev/null @@ -1,92 +0,0 @@ -import SearchInput from '@/components/SearchInput' -import MenuButtonGroup from '@/components/MenuButtonGroup' -import React, { useImperativeHandle, useState } from 'react' -import InfoCard from '@/components/InfoCard' -import TagList from '@/components/TagList' -import Logo from '@/components/Logo' -import LatestPosts from '@/components/LatestPosts' -import PostsCategories from '@/components/PostsCategories' - -/** - * 抽屉面板,可以从侧面拉出 - * @returns {JSX.Element} - * @constructor - */ -const Drawer = ({ post, currentTag, cRef, tags, posts, categories, currentCategory }) => { - // 暴露给父组件 通过cRef.current.handleMenuClick 调用 - useImperativeHandle(cRef, () => { - return { - handleMenuClick: () => handleMenuClick() - } - }) - const [isHidden, changeHiddenStatus] = useState(true) - // 点击按钮更改侧边抽屉状态 - const handleMenuClick = () => { - changeHiddenStatus(!isHidden) - } - return <> -
- {/* LOGO */} -
-
-
- -
- -
-
- - {/* 侧边菜单 */} -
-
- {/* 搜索框 */} -
- -
- - {/* 信息卡 */} - -
- - -
- - {/* 最新文章 */} - {posts && ( -
- -
- )} - - {/* 分类 */} - {categories && ( -
- -
- )} - - {/* 标签云 */} - {tags && ( -
-
-
标签
-
-
- -
-
- )} - -
-
-
- {/* 背景蒙版 */} -
- -} -export default Drawer diff --git a/components/DrawerRight.js b/components/DrawerRight.js deleted file mode 100644 index 4dd2711d..00000000 --- a/components/DrawerRight.js +++ /dev/null @@ -1,51 +0,0 @@ -import TocBar from '@/components/TocBar' -import React, { useImperativeHandle, useState } from 'react' - -/** - * 右侧边栏 - * @param toc - * @param post - * @returns {JSX.Element} - * @constructor - */ -const DrawerRight = ({ post, cRef }) => { -// 暴露给父组件 通过cRef.current.handleMenuClick 调用 - useImperativeHandle(cRef, () => { - return { - handleMenuClick: () => handleMenuClick() - } - }) - const [showDrawer, switchShowDrawer] = useState(false) - const handleMenuClick = () => { - switchShowDrawer(!showDrawer) - } - - return
-
-
- {/* LOGO */} -
-
文章目录 -
-
- -
-
-
- - {/* 侧边菜单 */} -
-
- {post && } -
-
-
- {/* 背景蒙版 */} -
-
-} -export default DrawerRight diff --git a/components/JumpToTop.js b/components/JumpToTopButton.js similarity index 93% rename from components/JumpToTop.js rename to components/JumpToTopButton.js index 2cadb9c9..73dd706a 100644 --- a/components/JumpToTop.js +++ b/components/JumpToTopButton.js @@ -10,7 +10,7 @@ import { useGlobal } from '@/lib/global' * @returns {JSX.Element} * @constructor */ -const JumpToTop = ({ targetRef, showPercent = true }) => { +const JumpToTopButton = ({ targetRef, showPercent = true }) => { const { locale } = useGlobal() const [show, switchShow] = useState(false) const [percent, changePercent] = useState(0) @@ -33,7 +33,7 @@ const JumpToTop = ({ targetRef, showPercent = true }) => { }, [show]) return ( -
+
window.scrollTo({ top: 0, behavior: 'smooth' })} @@ -50,4 +50,4 @@ const JumpToTop = ({ targetRef, showPercent = true }) => { ) } -export default JumpToTop +export default JumpToTopButton diff --git a/components/SideBar.js b/components/SideBar.js index dc18cdc7..9c8b43f9 100644 --- a/components/SideBar.js +++ b/components/SideBar.js @@ -4,7 +4,20 @@ import InfoCard from '@/components/InfoCard' import TagList from '@/components/TagList' import LatestPosts from '@/components/LatestPosts' import PostsCategories from '@/components/PostsCategories' +import Toc from '@/components/Toc' +import SearchInput from '@/components/SearchInput' +/** + * 侧边栏 + * @param tags + * @param currentTag + * @param post + * @param posts + * @param categories + * @param currentCategory + * @returns {JSX.Element} + * @constructor + */ const SideBar = ({ tags, currentTag, post, posts, categories, currentCategory }) => { // 按时间排序 if (posts) { @@ -15,47 +28,60 @@ const SideBar = ({ tags, currentTag, post, posts, categories, currentCategory }) }).slice(0, 5) } - return