diff --git a/themes/commerce/components/Footer.js b/themes/commerce/components/Footer.js index 5aab31e4..27a558df 100644 --- a/themes/commerce/components/Footer.js +++ b/themes/commerce/components/Footer.js @@ -62,7 +62,7 @@ const Footer = props => { {menu.name} diff --git a/themes/commerce/components/Header.js b/themes/commerce/components/Header.js index af963564..39f77627 100644 --- a/themes/commerce/components/Header.js +++ b/themes/commerce/components/Header.js @@ -1,12 +1,12 @@ -import LogoBar from './LogoBar' -import { useEffect, useRef, useState } from 'react' import Collapse from '@/components/Collapse' -import { MenuBarMobile } from './MenuBarMobile' -import { useGlobal } from '@/lib/global' -import CONFIG from '../config' -import { MenuItemDrop } from './MenuItemDrop' import { siteConfig } from '@/lib/config' +import { useGlobal } from '@/lib/global' import throttle from 'lodash.throttle' +import { useEffect, useRef, useState } from 'react' +import CONFIG from '../config' +import LogoBar from './LogoBar' +import { MenuBarMobile } from './MenuBarMobile' +import { MenuItemDrop } from './MenuItemDrop' /** * 顶部导航栏 + 菜单 @@ -21,10 +21,30 @@ export default function Header(props) { const { locale } = useGlobal() const defaultLinks = [ - { icon: 'fas fa-th', name: locale.COMMON.CATEGORY, to: '/category', show: CONFIG.MENU_CATEGORY }, - { icon: 'fas fa-tag', name: locale.COMMON.TAGS, to: '/tag', show: CONFIG.MENU_TAG }, - { icon: 'fas fa-archive', name: locale.NAV.ARCHIVE, to: '/archive', show: CONFIG.MENU_ARCHIVE }, - { icon: 'fas fa-search', name: locale.NAV.SEARCH, to: '/search', show: CONFIG.MENU_SEARCH } + { + icon: 'fas fa-th', + name: locale.COMMON.CATEGORY, + href: '/category', + show: CONFIG.MENU_CATEGORY + }, + { + icon: 'fas fa-tag', + name: locale.COMMON.TAGS, + href: '/tag', + show: CONFIG.MENU_TAG + }, + { + icon: 'fas fa-archive', + name: locale.NAV.ARCHIVE, + href: '/archive', + show: CONFIG.MENU_ARCHIVE + }, + { + icon: 'fas fa-search', + name: locale.NAV.SEARCH, + href: '/search', + show: CONFIG.MENU_SEARCH + } ] let links = defaultLinks.concat(customNav) @@ -65,32 +85,52 @@ export default function Header(props) { return null } - return
+ return ( +
+ {/* 导航栏菜单内容 */} +
+ {/* 左侧图标Logo */} + - {/* 导航栏菜单内容 */} -
- - {/* 左侧图标Logo */} - - - {/* 移动端折叠按钮 */} -
-
- {isOpen ? : } -
-
- - {/* 桌面端顶部菜单 */} -
- {links && links?.map(link => )} -
+ {/* 移动端折叠按钮 */} +
+
+ {isOpen ? ( + + ) : ( + + )} +
- {/* 移动端折叠菜单 */} - -
- collapseRef.current?.updateCollapseHeight(param)} /> -
-
+ {/* 桌面端顶部菜单 */} +
+ {links && + links?.map(link => )} +
+
+ + {/* 移动端折叠菜单 */} + +
+ + collapseRef.current?.updateCollapseHeight(param) + } + /> +
+
+ ) } diff --git a/themes/commerce/components/MenuBarMobile.js b/themes/commerce/components/MenuBarMobile.js index a8ba0f12..829c44c6 100644 --- a/themes/commerce/components/MenuBarMobile.js +++ b/themes/commerce/components/MenuBarMobile.js @@ -1,18 +1,22 @@ +import { siteConfig } from '@/lib/config' import { useGlobal } from '@/lib/global' import CONFIG from '../config' import { MenuItemCollapse } from './MenuItemCollapse' -import { siteConfig } from '@/lib/config' -export const MenuBarMobile = (props) => { +export const MenuBarMobile = props => { const { customMenu, customNav } = props const { locale } = useGlobal() let links = [ - // { name: locale.NAV.INDEX, to: '/' || '/', show: true }, - { name: locale.COMMON.CATEGORY, to: '/category', show: CONFIG.MENU_CATEGORY }, - { name: locale.COMMON.TAGS, to: '/tag', show: CONFIG.MENU_TAG }, - { name: locale.NAV.ARCHIVE, to: '/archive', show: CONFIG.MENU_ARCHIVE } - // { name: locale.NAV.SEARCH, to: '/search', show: CONFIG.MENU_SEARCH } + // { name: locale.NAV.INDEX, href: '/' || '/', show: true }, + { + name: locale.COMMON.CATEGORY, + href: '/category', + show: CONFIG.MENU_CATEGORY + }, + { name: locale.COMMON.TAGS, href: '/tag', show: CONFIG.MENU_TAG }, + { name: locale.NAV.ARCHIVE, href: '/archive', show: CONFIG.MENU_ARCHIVE } + // { name: locale.NAV.SEARCH, href: '/search', show: CONFIG.MENU_SEARCH } ] if (customNav) { @@ -30,7 +34,13 @@ export const MenuBarMobile = (props) => { return ( ) } diff --git a/themes/commerce/components/MenuGroupCard.js b/themes/commerce/components/MenuGroupCard.js index 99c94626..63f0f48e 100644 --- a/themes/commerce/components/MenuGroupCard.js +++ b/themes/commerce/components/MenuGroupCard.js @@ -14,19 +14,19 @@ const MenuGroupCard = props => { const links = [ { name: locale.COMMON.ARTICLE, - to: '/archive', + href: '/archive', slot: archiveSlot, show: CONFIG.MENU_ARCHIVE }, { name: locale.COMMON.CATEGORY, - to: '/category', + href: '/category', slot: categorySlot, show: CONFIG.MENU_CATEGORY }, { name: locale.COMMON.TAGS, - to: '/tag', + href: '/tag', slot: tagSlot, show: CONFIG.MENU_TAG } @@ -46,9 +46,9 @@ const MenuGroupCard = props => { if (link.show) { return ( { onClick={toggleShow}> {!hasSubMenu && ( @@ -64,7 +64,7 @@ export const MenuItemCollapse = props => {
- + {link?.icon && }{' '} {sLink.title} diff --git a/themes/commerce/components/MenuItemDrop.js b/themes/commerce/components/MenuItemDrop.js index fabd6c10..d5b80449 100644 --- a/themes/commerce/components/MenuItemDrop.js +++ b/themes/commerce/components/MenuItemDrop.js @@ -2,10 +2,15 @@ import Link from 'next/link' import { useRouter } from 'next/router' import { useState } from 'react' +/** + * 下拉菜单 + * @param {*} param0 + * @returns + */ export const MenuItemDrop = ({ link }) => { const [show, changeShow] = useState(false) const hasSubMenu = link?.subMenus?.length > 0 - const selected = useRouter().asPath === link?.to + const selected = useRouter().asPath === link?.href if (!link || !link.show) { return null @@ -18,7 +23,7 @@ export const MenuItemDrop = ({ link }) => { className='h-full'> {!hasSubMenu && ( {link?.icon && }
{link?.name}
@@ -45,7 +50,7 @@ export const MenuItemDrop = ({ link }) => {
  • - + {link?.icon &&   } {sLink.title} diff --git a/themes/commerce/components/MenuListSide.js b/themes/commerce/components/MenuListSide.js index 89133256..0cd2c4a9 100644 --- a/themes/commerce/components/MenuListSide.js +++ b/themes/commerce/components/MenuListSide.js @@ -1,17 +1,37 @@ -import { useGlobal } from '@/lib/global' import { siteConfig } from '@/lib/config' -import { MenuItemCollapse } from './MenuItemCollapse' +import { useGlobal } from '@/lib/global' import CONFIG from '../config' +import { MenuItemCollapse } from './MenuItemCollapse' -export const MenuListSide = (props) => { +export const MenuListSide = props => { const { customNav, customMenu } = props const { locale } = useGlobal() let links = [ - { icon: 'fas fa-archive', name: locale.NAV.ARCHIVE, to: '/archive', show: CONFIG.MENU_ARCHIVE }, - { icon: 'fas fa-search', name: locale.NAV.SEARCH, to: '/search', show: CONFIG.MENU_SEARCH }, - { icon: 'fas fa-folder', name: locale.COMMON.CATEGORY, to: '/category', show: CONFIG.MENU_CATEGORY }, - { icon: 'fas fa-tag', name: locale.COMMON.TAGS, to: '/tag', show: CONFIG.MENU_TAG } + { + icon: 'fas fa-archive', + name: locale.NAV.ARCHIVE, + href: '/archive', + show: CONFIG.MENU_ARCHIVE + }, + { + icon: 'fas fa-search', + name: locale.NAV.SEARCH, + href: '/search', + show: CONFIG.MENU_SEARCH + }, + { + icon: 'fas fa-folder', + name: locale.COMMON.CATEGORY, + href: '/category', + show: CONFIG.MENU_CATEGORY + }, + { + icon: 'fas fa-tag', + name: locale.COMMON.TAGS, + href: '/tag', + show: CONFIG.MENU_TAG + } ] if (customNav) { @@ -34,9 +54,11 @@ export const MenuListSide = (props) => { } return ( - + ) } diff --git a/themes/commerce/components/MenuListTop.js b/themes/commerce/components/MenuListTop.js index c4a10085..054ef5bf 100644 --- a/themes/commerce/components/MenuListTop.js +++ b/themes/commerce/components/MenuListTop.js @@ -1,18 +1,36 @@ +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) => { +export const MenuListTop = props => { const { customNav, customMenu } = props const { locale } = useGlobal() let links = [ - { id: 1, icon: 'fa-solid fa-house', name: locale.NAV.INDEX, to: '/', show: CONFIG.MENU_INDEX }, - { id: 2, icon: 'fas fa-search', name: locale.NAV.SEARCH, to: '/search', show: CONFIG.MENU_SEARCH }, - { id: 3, icon: 'fas fa-archive', name: locale.NAV.ARCHIVE, to: '/archive', show: CONFIG.MENU_ARCHIVE } - // { icon: 'fas fa-folder', name: locale.COMMON.CATEGORY, to: '/category', show: CONFIG.MENU_CATEGORY }, - // { icon: 'fas fa-tag', name: locale.COMMON.TAGS, to: '/tag', show: CONFIG.MENU_TAG } + { + id: 1, + icon: 'fa-solid fa-house', + name: locale.NAV.INDEX, + href: '/', + show: CONFIG.MENU_INDEX + }, + { + id: 2, + icon: 'fas fa-search', + name: locale.NAV.SEARCH, + href: '/search', + show: CONFIG.MENU_SEARCH + }, + { + id: 3, + icon: 'fas fa-archive', + name: locale.NAV.ARCHIVE, + href: '/archive', + show: CONFIG.MENU_ARCHIVE + } + // { icon: 'fas fa-folder', name: locale.COMMON.CATEGORY, href: '/category', show: CONFIG.MENU_CATEGORY }, + // { icon: 'fas fa-tag', name: locale.COMMON.TAGS, href: '/tag', show: CONFIG.MENU_TAG } ] if (customNav) { @@ -34,9 +52,16 @@ export const MenuListTop = (props) => { return null } - return (<> - - ) + return ( + <> + + + ) }