From a81c1426b534f0bb4dd3bcac3558e5fcdb4492ba Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Mon, 29 Apr 2024 10:22:19 +0800 Subject: [PATCH] =?UTF-8?q?hexo=20=E4=B8=BB=E9=A2=98=20=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E9=A3=8E=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/hexo/components/MenuItemCollapse.js | 6 +-- themes/hexo/components/MenuItemDrop.js | 10 +++-- themes/hexo/components/MenuListSide.js | 48 +++++++++++++++++----- themes/hexo/components/SideBar.js | 37 +++++++++++------ themes/matery/components/MenuItemDrop.js | 7 +++- themes/matery/components/MenuListTop.js | 43 +++++++++++++++---- 6 files changed, 111 insertions(+), 40 deletions(-) diff --git a/themes/hexo/components/MenuItemCollapse.js b/themes/hexo/components/MenuItemCollapse.js index 828079c7..1782ce52 100644 --- a/themes/hexo/components/MenuItemCollapse.js +++ b/themes/hexo/components/MenuItemCollapse.js @@ -29,13 +29,13 @@ export const MenuItemCollapse = props => { return ( <>
{!hasSubMenu && ( + className=' font-extralight flex justify-between pl-2 pr-4 dark:text-gray-200 no-underline tracking-widest pb-1'> {link?.icon && } {link?.name} @@ -63,7 +63,7 @@ export const MenuItemCollapse = props => { return (
+ className='dark:hover:bg-indigo-500 hover:bg-indigo-500 hover:text-white dark:bg-black dark:text-gray-200 text-left px-10 justify-start bg-gray-50 tracking-widest transition-all duration-200 py-3 pr-6'> {link?.icon && }{' '} diff --git a/themes/hexo/components/MenuItemDrop.js b/themes/hexo/components/MenuItemDrop.js index b74d7a8f..18ea74b6 100644 --- a/themes/hexo/components/MenuItemDrop.js +++ b/themes/hexo/components/MenuItemDrop.js @@ -1,6 +1,10 @@ import Link from 'next/link' import { useState } from 'react' - +/** + * 支持二级展开的菜单 + * @param {*} param0 + * @returns + */ export const MenuItemDrop = ({ link }) => { const [show, changeShow] = useState(false) const hasSubMenu = link?.subMenus?.length > 0 @@ -25,7 +29,7 @@ export const MenuItemDrop = ({ link }) => { {hasSubMenu && ( <> -
+
{link?.icon && } {link?.name} @@ -42,7 +46,7 @@ export const MenuItemDrop = ({ link }) => { return (
  • + className='cursor-pointer hover:bg-indigo-500 hover:text-white tracking-widest transition-all duration-200 dark:border-gray-800 py-1 pr-6 pl-3'> {link?.icon &&   } diff --git a/themes/hexo/components/MenuListSide.js b/themes/hexo/components/MenuListSide.js index 3a146d43..ab0b4278 100644 --- a/themes/hexo/components/MenuListSide.js +++ b/themes/hexo/components/MenuListSide.js @@ -1,17 +1,41 @@ -import { useGlobal } from '@/lib/global' import { siteConfig } from '@/lib/config' -import { MenuItemCollapse } from './MenuItemCollapse' +import { useGlobal } from '@/lib/global' import CONFIG from '../config' - -export const MenuListSide = (props) => { +import { MenuItemCollapse } from './MenuItemCollapse' +/** + * 侧拉抽屉菜单 + * @param {*} props + * @returns + */ +export const MenuListSide = props => { const { customNav, customMenu } = props const { locale } = useGlobal() let links = [ - { icon: 'fas fa-archive', name: locale.NAV.ARCHIVE, to: '/archive', show: siteConfig('HEXO_MENU_ARCHIVE', null, CONFIG) }, - { icon: 'fas fa-search', name: locale.NAV.SEARCH, to: '/search', show: siteConfig('HEXO_MENU_SEARCH', null, CONFIG) }, - { icon: 'fas fa-folder', name: locale.COMMON.CATEGORY, to: '/category', show: siteConfig('HEXO_MENU_CATEGORY', null, CONFIG) }, - { icon: 'fas fa-tag', name: locale.COMMON.TAGS, to: '/tag', show: siteConfig('HEXO_MENU_TAG', null, CONFIG) } + { + icon: 'fas fa-archive', + name: locale.NAV.ARCHIVE, + to: '/archive', + show: siteConfig('HEXO_MENU_ARCHIVE', null, CONFIG) + }, + { + icon: 'fas fa-search', + name: locale.NAV.SEARCH, + to: '/search', + show: siteConfig('HEXO_MENU_SEARCH', null, CONFIG) + }, + { + icon: 'fas fa-folder', + name: locale.COMMON.CATEGORY, + to: '/category', + show: siteConfig('HEXO_MENU_CATEGORY', null, CONFIG) + }, + { + icon: 'fas fa-tag', + name: locale.COMMON.TAGS, + to: '/tag', + show: siteConfig('HEXO_MENU_TAG', null, CONFIG) + } ] if (customNav) { @@ -34,8 +58,10 @@ export const MenuListSide = (props) => { } return ( - + ) } diff --git a/themes/hexo/components/SideBar.js b/themes/hexo/components/SideBar.js index 913ce0a9..64def6ec 100644 --- a/themes/hexo/components/SideBar.js +++ b/themes/hexo/components/SideBar.js @@ -1,5 +1,5 @@ -import { siteConfig } from '@/lib/config' import LazyImage from '@/components/LazyImage' +import { siteConfig } from '@/lib/config' import { useRouter } from 'next/router' import MenuGroupCard from './MenuGroupCard' import { MenuListSide } from './MenuListSide' @@ -11,22 +11,33 @@ import { MenuListSide } from './MenuListSide' * @returns {JSX.Element} * @constructor */ -const SideBar = (props) => { +const SideBar = props => { const { siteInfo } = props const router = useRouter() return ( -
  • + className='cursor-pointer hover:bg-indigo-500 text-gray-900 hover:text-white tracking-widest transition-all duration-200 dark:border-gray-800 py-1 pr-6 pl-3'> {link?.icon &&   } diff --git a/themes/matery/components/MenuListTop.js b/themes/matery/components/MenuListTop.js index 506f9c59..04897f7b 100644 --- a/themes/matery/components/MenuListTop.js +++ b/themes/matery/components/MenuListTop.js @@ -1,17 +1,42 @@ +import { siteConfig } from '@/lib/config' import { useGlobal } from '@/lib/global' import CONFIG from '../config' import { MenuItemDrop } from './MenuItemDrop' -import { siteConfig } from '@/lib/config' - -export const MenuListTop = (props) => { +/** + * 菜单列表 + * 顶部导航栏用 + * @param {*} props + * @returns + */ +export const MenuListTop = props => { const { customNav, customMenu } = props const { locale } = useGlobal() let links = [ - { icon: 'fas fa-archive', name: locale.NAV.ARCHIVE, to: '/archive', show: siteConfig('MATERY_MENU_ARCHIVE', null, CONFIG) }, - { icon: 'fas fa-search', name: locale.NAV.SEARCH, to: '/search', show: siteConfig('MATERY_MENU_SEARCH', null, CONFIG) }, - { icon: 'fas fa-folder', name: locale.COMMON.CATEGORY, to: '/category', show: siteConfig('MATERY_MENU_CATEGORY', null, CONFIG) }, - { icon: 'fas fa-tag', name: locale.COMMON.TAGS, to: '/tag', show: siteConfig('MATERY_MENU_TAG', null, CONFIG) } + { + icon: 'fas fa-archive', + name: locale.NAV.ARCHIVE, + to: '/archive', + show: siteConfig('MATERY_MENU_ARCHIVE', null, CONFIG) + }, + { + icon: 'fas fa-search', + name: locale.NAV.SEARCH, + to: '/search', + show: siteConfig('MATERY_MENU_SEARCH', null, CONFIG) + }, + { + icon: 'fas fa-folder', + name: locale.COMMON.CATEGORY, + to: '/category', + show: siteConfig('MATERY_MENU_CATEGORY', null, CONFIG) + }, + { + icon: 'fas fa-tag', + name: locale.COMMON.TAGS, + to: '/tag', + show: siteConfig('MATERY_MENU_TAG', null, CONFIG) + } ] if (customNav) { @@ -29,7 +54,9 @@ export const MenuListTop = (props) => { return ( ) }