From 64581d7147d2687ba0b8ed41b8dcdfb8a7cc5201 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 8 Mar 2022 14:52:21 +0800 Subject: [PATCH] =?UTF-8?q?hexo=20=E6=A0=B7=E5=BC=8F=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/Hexo/LayoutBase.js | 4 +-- themes/Hexo/components/JumpToTopButton.js | 6 ++-- themes/Hexo/components/MenuList.js | 44 +++++++++++++++++++++++ themes/Hexo/components/TocDrawer.js | 6 ++-- themes/Hexo/components/TocDrawerButton.js | 2 +- themes/Hexo/components/TopNav.js | 4 +-- 6 files changed, 54 insertions(+), 12 deletions(-) create mode 100644 themes/Hexo/components/MenuList.js diff --git a/themes/Hexo/LayoutBase.js b/themes/Hexo/LayoutBase.js index 76322696..25163fcd 100644 --- a/themes/Hexo/LayoutBase.js +++ b/themes/Hexo/LayoutBase.js @@ -55,8 +55,8 @@ const LayoutBase = (props) => { {/* 右下角悬浮 */} -
-
+
+
{floatSlot} diff --git a/themes/Hexo/components/JumpToTopButton.js b/themes/Hexo/components/JumpToTopButton.js index fc1eee83..25a186d7 100644 --- a/themes/Hexo/components/JumpToTopButton.js +++ b/themes/Hexo/components/JumpToTopButton.js @@ -16,10 +16,8 @@ const JumpToTopButton = ({ showPercent = true, percent }) => { } const { locale } = useGlobal() return (
window.scrollTo({ top: 0, behavior: 'smooth' })} > -
- -
- {showPercent && (
{percent}%
)} + {!showPercent &&
} + {showPercent && (
{percent}
)}
) } diff --git a/themes/Hexo/components/MenuList.js b/themes/Hexo/components/MenuList.js new file mode 100644 index 00000000..905a03fd --- /dev/null +++ b/themes/Hexo/components/MenuList.js @@ -0,0 +1,44 @@ +import React from 'react' +import Link from 'next/link' +import { useRouter } from 'next/router' +import { useGlobal } from '@/lib/global' +import CONFIG_HEXO from '../config_hexo' + +const MenuList = (props) => { + const { postCount, customNav } = props + const { locale } = useGlobal() + const router = useRouter() + const archiveSlot =
{postCount}
+ + let links = [ + { icon: 'fas fa-home', name: locale.NAV.INDEX, to: '/' || '/', show: true }, + { icon: 'fas fa-th', name: locale.COMMON.CATEGORY, to: '/category', show: CONFIG_HEXO.MENU_CATEGORY }, + { icon: 'fas fa-tag', name: locale.COMMON.TAGS, to: '/tag', show: CONFIG_HEXO.MENU_TAG }, + { icon: 'fas fa-archive', name: locale.NAV.ARCHIVE, to: '/archive', slot: archiveSlot, show: CONFIG_HEXO.MENU_ARCHIVE }, + { icon: 'fas fa-user', name: locale.NAV.ABOUT, to: '/about', show: CONFIG_HEXO.MENU_ABOUT } + ] + if (customNav) { + links = links.concat(customNav) + } + + return +} +export default MenuList diff --git a/themes/Hexo/components/TocDrawer.js b/themes/Hexo/components/TocDrawer.js index 70f8a41a..54cad1fb 100644 --- a/themes/Hexo/components/TocDrawer.js +++ b/themes/Hexo/components/TocDrawer.js @@ -24,10 +24,10 @@ const TocDrawer = ({ post, cRef }) => { {/* 侧边菜单 */}
+ ' shadow-card animate__animated animate__faster h-36 ' + + ' w-60 duration-200 fixed right-12 bottom-12 rounded overflow-y-auto py-2 bg-white dark:bg-gray-600'}> {post && <> -
+
diff --git a/themes/Hexo/components/TocDrawerButton.js b/themes/Hexo/components/TocDrawerButton.js index fca2f356..4554ca8c 100644 --- a/themes/Hexo/components/TocDrawerButton.js +++ b/themes/Hexo/components/TocDrawerButton.js @@ -14,7 +14,7 @@ const TocDrawerButton = (props) => { return <> } const { locale } = useGlobal() - return (
+ return (
) } diff --git a/themes/Hexo/components/TopNav.js b/themes/Hexo/components/TopNav.js index 4dd4d929..8936325a 100644 --- a/themes/Hexo/components/TopNav.js +++ b/themes/Hexo/components/TopNav.js @@ -5,11 +5,11 @@ import { useEffect, useRef, useState } from 'react' import CategoryGroup from './CategoryGroup' import Collapse from './Collapse' import Logo from './Logo' -import MenuButtonGroup from './MenuButtonGroup' import SearchDrawer from './SearchDrawer' import TagGroups from './TagGroups' import CONFIG_HEXO from '../config_hexo' import MenuButtonGroupTop from './MenuButtonGroupTop' +import MenuList from './MenuList' let windowTop = 0 @@ -108,7 +108,7 @@ const TopNav = (props) => {
- +