From 8ce32b422eb38cf528f30f18f5eca990f3778065 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 10 Apr 2024 17:36:17 +0800 Subject: [PATCH] refactor --- lib/db/getSiteData.js | 2 +- themes/commerce/components/MenuGroupCard.js | 77 ++++++++++------ .../commerce/components/MenuItemCollapse.js | 75 ++++++++++------ themes/commerce/components/MenuItemDrop.js | 70 +++++++++------ themes/example/components/MenuItemDrop.js | 68 ++++++++------ .../fukasawa/components/MenuItemCollapse.js | 85 ++++++++++++------ themes/fukasawa/components/MenuItemDrop.js | 82 +++++++++++------ themes/game/components/MenuItemCollapse.js | 79 +++++++++++------ themes/game/components/MenuItemDrop.js | 8 +- themes/gitbook/components/MenuItemCollapse.js | 84 +++++++++++++----- themes/gitbook/components/MenuItemDrop.js | 88 ++++++++++++------- themes/heo/components/MenuGroupCard.js | 79 ++++++++++------- themes/heo/components/MenuItemCollapse.js | 73 ++++++++++----- themes/heo/components/MenuItemDrop.js | 70 +++++++++------ themes/hexo/components/MenuGroupCard.js | 81 ++++++++++------- themes/hexo/components/MenuItemCollapse.js | 75 ++++++++++------ themes/hexo/components/MenuItemDrop.js | 70 +++++++++------ themes/matery/components/MenuGroupCard.js | 73 +++++++++------ themes/matery/components/MenuItemCollapse.js | 82 +++++++++++------ themes/matery/components/MenuItemDrop.js | 70 +++++++++------ themes/medium/components/MenuItemCollapse.js | 85 ++++++++++++------ themes/medium/components/MenuItemDrop.js | 88 ++++++++++++------- themes/movie/components/MenuItemCollapse.js | 16 ++-- themes/movie/components/MenuItemDrop.js | 28 +++--- themes/nav/components/MenuItemCollapse.js | 85 ++++++++++++------ themes/nav/components/MenuItemDrop.js | 88 ++++++++++++------- themes/next/components/MenuItemCollapse.js | 80 ++++++++++++----- themes/next/components/MenuItemDrop.js | 82 +++++++++++------ .../nobelium/components/MenuItemCollapse.js | 79 +++++++++++------ themes/nobelium/components/MenuItemDrop.js | 72 +++++++++------ themes/plog/components/MenuItemCollapse.js | 79 +++++++++++------ themes/plog/components/MenuItemDrop.js | 67 ++++++++------ themes/simple/components/MenuItemCollapse.js | 87 ++++++++++++------ themes/simple/components/MenuItemDrop.js | 79 +++++++++++------ themes/starter/components/Logo.js | 56 +++++++----- themes/starter/components/MenuItem.js | 87 ++++++++++-------- 36 files changed, 1657 insertions(+), 892 deletions(-) diff --git a/lib/db/getSiteData.js b/lib/db/getSiteData.js index bc166494..4a8ab7eb 100755 --- a/lib/db/getSiteData.js +++ b/lib/db/getSiteData.js @@ -192,7 +192,7 @@ function getCustomMenu({ collectionData }) { if (menuPages && menuPages.length > 0) { menuPages.forEach(e => { e.show = true - if (e?.slug?.indexOf('http') === 0) { + if (e?.slug?.indexOf('http') === 0 && e?.slug?.indexOf(BLOG.LINK) < 0) { e.target = '_blank' e.to = e.slug } else { diff --git a/themes/commerce/components/MenuGroupCard.js b/themes/commerce/components/MenuGroupCard.js index 5e4d84a4..99c94626 100644 --- a/themes/commerce/components/MenuGroupCard.js +++ b/themes/commerce/components/MenuGroupCard.js @@ -1,18 +1,35 @@ -import Link from 'next/link' import { useGlobal } from '@/lib/global' +import Link from 'next/link' import CONFIG from '../config' -const MenuGroupCard = (props) => { +const MenuGroupCard = props => { const { postCount, categoryOptions, tagOptions } = props const { locale } = useGlobal() const archiveSlot =
{postCount}
- const categorySlot =
{categoryOptions?.length}
+ const categorySlot = ( +
{categoryOptions?.length}
+ ) const tagSlot =
{tagOptions?.length}
const links = [ - { name: locale.COMMON.ARTICLE, to: '/archive', slot: archiveSlot, show: CONFIG.MENU_ARCHIVE }, - { name: locale.COMMON.CATEGORY, to: '/category', slot: categorySlot, show: CONFIG.MENU_CATEGORY }, - { name: locale.COMMON.TAGS, to: '/tag', slot: tagSlot, show: CONFIG.MENU_TAG } + { + name: locale.COMMON.ARTICLE, + to: '/archive', + slot: archiveSlot, + show: CONFIG.MENU_ARCHIVE + }, + { + name: locale.COMMON.CATEGORY, + to: '/category', + slot: categorySlot, + show: CONFIG.MENU_CATEGORY + }, + { + name: locale.COMMON.TAGS, + to: '/tag', + slot: tagSlot, + show: CONFIG.MENU_TAG + } ] for (let i = 0; i < links.length; i++) { @@ -22,29 +39,31 @@ const MenuGroupCard = (props) => { } return ( - + ) } export default MenuGroupCard diff --git a/themes/commerce/components/MenuItemCollapse.js b/themes/commerce/components/MenuItemCollapse.js index 1ce6d59d..3251b9fb 100644 --- a/themes/commerce/components/MenuItemCollapse.js +++ b/themes/commerce/components/MenuItemCollapse.js @@ -7,7 +7,7 @@ import { useState } from 'react' * @param {*} param0 * @returns */ -export const MenuItemCollapse = (props) => { +export const MenuItemCollapse = props => { const { link } = props const [show, changeShow] = useState(false) const hasSubMenu = link?.subMenus?.length > 0 @@ -26,30 +26,55 @@ export const MenuItemCollapse = (props) => { return null } - return <> -
- {!hasSubMenu && - {link?.icon && }{link?.name} - } - {hasSubMenu &&
- {link?.icon && }{link?.name} - -
} -
+ return ( + <> +
+ {!hasSubMenu && ( + + + {link?.icon && } + {link?.name} + + + )} + {hasSubMenu && ( +
+ + {link?.icon && } + {link?.name} + + +
+ )} +
- {/* 折叠子菜单 */} - {hasSubMenu && - {link.subMenus.map((sLink, index) => { - return
- - {link?.icon && } {sLink.title} - -
- })} -
} + {/* 折叠子菜单 */} + {hasSubMenu && ( + + {link.subMenus.map((sLink, index) => { + return ( +
+ + + {link?.icon && }{' '} + {sLink.title} + + +
+ ) + })} +
+ )} + ) } diff --git a/themes/commerce/components/MenuItemDrop.js b/themes/commerce/components/MenuItemDrop.js index e83f46f7..fabd6c10 100644 --- a/themes/commerce/components/MenuItemDrop.js +++ b/themes/commerce/components/MenuItemDrop.js @@ -11,33 +11,51 @@ export const MenuItemDrop = ({ link }) => { return null } - return
changeShow(true)} onMouseOut={() => changeShow(false)} className='h-full'> + return ( +
changeShow(true)} + onMouseOut={() => changeShow(false)} + className='h-full'> + {!hasSubMenu && ( + + {link?.icon && }
{link?.name}
+ {/* {hasSubMenu && } */} + + )} - {!hasSubMenu && - - {link?.icon && }
{link?.name}
- {/* {hasSubMenu && } */} - } - - {hasSubMenu && <> -
- {link?.icon && }
{link?.name}
- {/* */} -
- } - - {/* 子菜单 */} - {hasSubMenu &&
    - {link.subMenus.map((sLink, index) => { - return
  • - - {link?.icon &&   }{sLink.title} - -
  • - })} -
} + {hasSubMenu && ( + <> +
+ {link?.icon && }
{link?.name}
+ {/* */} +
+ + )} + {/* 子菜单 */} + {hasSubMenu && ( +
    + {link.subMenus.map((sLink, index) => { + return ( +
  • + + + {link?.icon &&   } + {sLink.title} + + +
  • + ) + })} +
+ )}
+ ) } diff --git a/themes/example/components/MenuItemDrop.js b/themes/example/components/MenuItemDrop.js index 73e63ac7..94d70605 100644 --- a/themes/example/components/MenuItemDrop.js +++ b/themes/example/components/MenuItemDrop.js @@ -5,34 +5,48 @@ export const MenuItemDrop = ({ link }) => { const [show, changeShow] = useState(false) const hasSubMenu = link?.subMenus?.length > 0 - return
  • changeShow(true)} onMouseOut={() => changeShow(false)} > + return ( +
  • changeShow(true)} + onMouseOut={() => changeShow(false)}> + {!hasSubMenu && ( +
    + + {link?.icon && } {link?.name} + {hasSubMenu && } + +
    + )} - {!hasSubMenu && -
    - - {link?.icon && } {link?.name} - {hasSubMenu && } + {hasSubMenu && ( +
    + {link?.icon && } {link?.name} + +
    + )} + + {/* 子菜单 */} + {hasSubMenu && ( +
      + {link.subMenus.map((sLink, index) => { + return ( +
    • + + + {link?.icon &&   } + {sLink.title} + -
    - } - - {hasSubMenu && -
    - {link?.icon && } {link?.name} - -
    - } - - {/* 子菜单 */} - {hasSubMenu &&
      - {link.subMenus.map((sLink, index) => { - return
    • - - {link?.icon &&   }{sLink.title} - -
    • - })} -
    } - +
  • + ) + })} + + )} + ) } diff --git a/themes/fukasawa/components/MenuItemCollapse.js b/themes/fukasawa/components/MenuItemCollapse.js index f854c16f..2d36242c 100644 --- a/themes/fukasawa/components/MenuItemCollapse.js +++ b/themes/fukasawa/components/MenuItemCollapse.js @@ -8,7 +8,7 @@ import { useState } from 'react' * @param {*} param0 * @returns */ -export const MenuItemCollapse = (props) => { +export const MenuItemCollapse = props => { const { link } = props const [show, changeShow] = useState(false) const hasSubMenu = link?.subMenus?.length > 0 @@ -21,7 +21,7 @@ export const MenuItemCollapse = (props) => { return null } - const selected = (router.pathname === link.to) || (router.asPath === link.to) + const selected = router.pathname === link.to || router.asPath === link.to const toggleShow = () => { changeShow(!show) @@ -31,32 +31,67 @@ export const MenuItemCollapse = (props) => { changeIsOpen(!isOpen) } - return <> -
    + return ( + <> +
    + {!hasSubMenu && ( + +
    +
    + {link.name} +
    + + )} - {!hasSubMenu && -
    {link.name}
    - } + {hasSubMenu && ( +
    +
    +
    + {link.name} +
    +
    + +
    +
    + )} +
    - {hasSubMenu &&
    -
    {link.name}
    -
    -
    } -
    - - {/* 折叠子菜单 */} - {hasSubMenu && - {link.subMenus.map((sLink, index) => { - return
    - -
    {sLink.title}
    - -
    - })} - } + +
    +
    + {sLink.title} +
    + +
    + ) + })} + + )} + ) } diff --git a/themes/fukasawa/components/MenuItemDrop.js b/themes/fukasawa/components/MenuItemDrop.js index 7a79c5c3..b6224347 100644 --- a/themes/fukasawa/components/MenuItemDrop.js +++ b/themes/fukasawa/components/MenuItemDrop.js @@ -5,34 +5,62 @@ export const MenuItemDrop = ({ link }) => { const [show, changeShow] = useState(false) const hasSubMenu = link?.subMenus?.length > 0 - return
  • changeShow(true)} onMouseOut={() => changeShow(false)} - className='relative py-1 duration-500 justify-between text-gray-500 dark:text-gray-300 hover:text-black hover:underline cursor-pointer flex flex-nowrap items-center '> + return ( +
  • changeShow(true)} + onMouseOut={() => changeShow(false)} + className='relative py-1 duration-500 justify-between text-gray-500 dark:text-gray-300 hover:text-black hover:underline cursor-pointer flex flex-nowrap items-center '> + {!hasSubMenu && ( + +
    +
    + {link.name} +
    + {link.slot} + + )} - {!hasSubMenu && - -
    {link.name}
    - {link.slot} - } - - {hasSubMenu && -
    -
    {link.name}
    - {link.slot} - {hasSubMenu &&
    } -
    } - - {/* 子菜单 */} - {hasSubMenu &&
      - {link?.subMenus?.map((sLink, index) => { - return
    • - - {sLink.icon && } -
      {sLink.name}
      - {sLink.slot} - -
    • - })} -
    } + {hasSubMenu && ( +
    +
    +
    + {link.name} +
    + {link.slot} + {hasSubMenu && ( +
    + +
    + )} +
    + )} + {/* 子菜单 */} + {hasSubMenu && ( +
      + {link?.subMenus?.map((sLink, index) => { + return ( +
    • + + {sLink.icon && ( + + )} +
      {sLink.name}
      + {sLink.slot} + +
    • + ) + })} +
    + )}
  • + ) } diff --git a/themes/game/components/MenuItemCollapse.js b/themes/game/components/MenuItemCollapse.js index 8f53f622..c8a18d78 100644 --- a/themes/game/components/MenuItemCollapse.js +++ b/themes/game/components/MenuItemCollapse.js @@ -7,7 +7,7 @@ import { useState } from 'react' * @param {*} param0 * @returns */ -export const MenuItemCollapse = (props) => { +export const MenuItemCollapse = props => { const { link } = props const [show, changeShow] = useState(false) const hasSubMenu = link?.subMenus?.length > 0 @@ -26,30 +26,59 @@ export const MenuItemCollapse = (props) => { return null } - return <> -
    - {!hasSubMenu && - {link?.icon && }{link?.name} - } - {hasSubMenu &&
    - {link?.icon && }{link?.name} - -
    } -
    + return ( + <> +
    + {!hasSubMenu && ( + + + {link?.icon && ( + + + + )} + {link?.name} + + + )} + {hasSubMenu && ( +
    + + {link?.icon && ( + + + + )} + {link?.name} + + +
    + )} +
    - {/* 折叠子菜单 */} - {hasSubMenu && - {link.subMenus.map((sLink, index) => { - return
    - - {sLink.title} - -
    - })} -
    } + {/* 折叠子菜单 */} + {hasSubMenu && ( + + {link.subMenus.map((sLink, index) => { + return ( +
    + + {sLink.title} + +
    + ) + })} +
    + )} + ) } diff --git a/themes/game/components/MenuItemDrop.js b/themes/game/components/MenuItemDrop.js index 2289f3bc..41b124b6 100644 --- a/themes/game/components/MenuItemDrop.js +++ b/themes/game/components/MenuItemDrop.js @@ -20,7 +20,7 @@ export const MenuItemDrop = ({ link }) => { + target={link?.target}>
    {link?.icon && }
    @@ -47,11 +47,7 @@ export const MenuItemDrop = ({ link }) => {
    - + {link?.icon &&   } {sLink.title} diff --git a/themes/gitbook/components/MenuItemCollapse.js b/themes/gitbook/components/MenuItemCollapse.js index 3755efda..87453498 100644 --- a/themes/gitbook/components/MenuItemCollapse.js +++ b/themes/gitbook/components/MenuItemCollapse.js @@ -8,7 +8,7 @@ import { useState } from 'react' * @param {*} param0 * @returns */ -export const MenuItemCollapse = (props) => { +export const MenuItemCollapse = props => { const { link } = props const [show, changeShow] = useState(false) const hasSubMenu = link?.subMenus?.length > 0 @@ -21,7 +21,7 @@ export const MenuItemCollapse = (props) => { return null } - const selected = (router.pathname === link.to) || (router.asPath === link.to) + const selected = router.pathname === link.to || router.asPath === link.to const toggleShow = () => { changeShow(!show) @@ -31,31 +31,67 @@ export const MenuItemCollapse = (props) => { changeIsOpen(!isOpen) } - return <> -
    + return ( + <> +
    + {!hasSubMenu && ( + +
    +
    + {link.name} +
    + + )} - {!hasSubMenu && -
    {link.name}
    - } + {hasSubMenu && ( +
    +
    +
    + {link.name} +
    +
    + +
    +
    + )} +
    - {hasSubMenu &&
    -
    {link.name}
    -
    -
    } -
    - - {/* 折叠子菜单 */} - {hasSubMenu && - {link?.subMenus?.map((sLink, index) => { - return
    - -
    {sLink.title}
    - -
    - })} - } + +
    +
    + {sLink.title} +
    + +
    + ) + })} + + )} + ) } diff --git a/themes/gitbook/components/MenuItemDrop.js b/themes/gitbook/components/MenuItemDrop.js index 572c9b22..6f16ddcb 100644 --- a/themes/gitbook/components/MenuItemDrop.js +++ b/themes/gitbook/components/MenuItemDrop.js @@ -1,6 +1,6 @@ import Link from 'next/link' -import { useState } from 'react' import { useRouter } from 'next/router' +import { useState } from 'react' export const MenuItemDrop = ({ link }) => { const [show, changeShow] = useState(false) @@ -10,38 +10,64 @@ export const MenuItemDrop = ({ link }) => { return null } const hasSubMenu = link?.subMenus?.length > 0 - const selected = (router.pathname === link.to) || (router.asPath === link.to) - return
  • changeShow(true)} onMouseOut={() => changeShow(false)} > + const selected = router.pathname === link.to || router.asPath === link.to + return ( +
  • changeShow(true)} + onMouseOut={() => changeShow(false)}> + {hasSubMenu && ( +
    +
    + {link?.icon && } {link?.name} + {hasSubMenu && ( + + )} +
    +
    + )} - {hasSubMenu && -
    -
    - {link?.icon && } {link?.name} - {hasSubMenu && } -
    -
    - } + {!hasSubMenu && ( +
    + + {link?.icon && } {link?.name} + +
    + )} - {!hasSubMenu && -
    - - {link?.icon && } {link?.name} + {/* 子菜单 */} + {hasSubMenu && ( +
      + {link?.subMenus?.map((sLink, index) => { + return ( +
    • + + + {link?.icon &&   } + {sLink.title} + -
    - } - - {/* 子菜单 */} - {hasSubMenu &&
      - {link?.subMenus?.map((sLink, index) => { - return
    • - - {link?.icon &&   }{sLink.title} - -
    • - })} -
    } - +
  • + ) + })} + + )} + ) } diff --git a/themes/heo/components/MenuGroupCard.js b/themes/heo/components/MenuGroupCard.js index e1de4792..8f5f37a4 100644 --- a/themes/heo/components/MenuGroupCard.js +++ b/themes/heo/components/MenuGroupCard.js @@ -1,44 +1,63 @@ -import Link from 'next/link' -import { useGlobal } from '@/lib/global' -import CONFIG from '../config' import { siteConfig } from '@/lib/config' +import { useGlobal } from '@/lib/global' +import Link from 'next/link' +import CONFIG from '../config' -const MenuGroupCard = (props) => { +const MenuGroupCard = props => { const { postCount, categoryOptions, tagOptions } = props const { locale } = useGlobal() const archiveSlot =
    {postCount}
    - const categorySlot =
    {categoryOptions?.length}
    + const categorySlot = ( +
    {categoryOptions?.length}
    + ) const tagSlot =
    {tagOptions?.length}
    const links = [ - { name: locale.COMMON.ARTICLE, to: '/archive', slot: archiveSlot, show: siteConfig('HEO_MENU_ARCHIVE', null, CONFIG) }, - { name: locale.COMMON.CATEGORY, to: '/category', slot: categorySlot, show: siteConfig('HEO_MENU_CATEGORY', null, CONFIG) }, - { name: locale.COMMON.TAGS, to: '/tag', slot: tagSlot, show: siteConfig('HEO_MENU_TAG', null, CONFIG) } + { + name: locale.COMMON.ARTICLE, + to: '/archive', + slot: archiveSlot, + show: siteConfig('HEO_MENU_ARCHIVE', null, CONFIG) + }, + { + name: locale.COMMON.CATEGORY, + to: '/category', + slot: categorySlot, + show: siteConfig('HEO_MENU_CATEGORY', null, CONFIG) + }, + { + name: locale.COMMON.TAGS, + to: '/tag', + slot: tagSlot, + show: siteConfig('HEO_MENU_TAG', null, CONFIG) + } ] return ( - + ) } export default MenuGroupCard diff --git a/themes/heo/components/MenuItemCollapse.js b/themes/heo/components/MenuItemCollapse.js index ab1472c1..3de68ec6 100644 --- a/themes/heo/components/MenuItemCollapse.js +++ b/themes/heo/components/MenuItemCollapse.js @@ -25,30 +25,55 @@ export const MenuItemCollapse = ({ link }) => { return null } - return <> -
    - {!hasSubMenu && - {link?.icon && }{link?.name} - } - {hasSubMenu &&
    - {link?.icon && }{link?.name} - -
    } -
    + return ( + <> +
    + {!hasSubMenu && ( + + + {link?.icon && } + {link?.name} + + + )} + {hasSubMenu && ( +
    + + {link?.icon && } + {link?.name} + + +
    + )} +
    - {/* 折叠子菜单 */} - {hasSubMenu && - {link.subMenus.map((sLink, index) => { - return
    - - {link?.icon && } {sLink.title} - -
    - })} -
    } + {/* 折叠子菜单 */} + {hasSubMenu && ( + + {link.subMenus.map((sLink, index) => { + return ( +
    + + + {link?.icon && }{' '} + {sLink.title} + + +
    + ) + })} +
    + )} + ) } diff --git a/themes/heo/components/MenuItemDrop.js b/themes/heo/components/MenuItemDrop.js index 97128d5f..076c22a2 100644 --- a/themes/heo/components/MenuItemDrop.js +++ b/themes/heo/components/MenuItemDrop.js @@ -9,34 +9,50 @@ export const MenuItemDrop = ({ link }) => { return null } - return
    changeShow(true)} onMouseOut={() => changeShow(false)} > + return ( +
    changeShow(true)} + onMouseOut={() => changeShow(false)}> + {/* 不含子菜单 */} + {!hasSubMenu && ( + + {link?.icon && } {link?.name} + + )} - {/* 不含子菜单 */} - {!hasSubMenu && - - {link?.icon && } {link?.name} - } - - {/* 含子菜单的按钮 */} - {hasSubMenu && <> -
    - {link?.icon && } {link?.name} -
    - } - - {/* 子菜单 */} - {hasSubMenu &&
      - {link.subMenus.map((sLink, index) => { - return
    • - - {link?.icon &&   }{sLink.title} - -
    • - })} -
    } + {/* 含子菜单的按钮 */} + {hasSubMenu && ( + <> +
    + {link?.icon && } {link?.name} +
    + + )} + {/* 子菜单 */} + {hasSubMenu && ( +
      + {link.subMenus.map((sLink, index) => { + return ( +
    • + + + {link?.icon &&   } + {sLink.title} + + +
    • + ) + })} +
    + )}
    + ) } diff --git a/themes/hexo/components/MenuGroupCard.js b/themes/hexo/components/MenuGroupCard.js index 2e7a44d1..3753d31b 100644 --- a/themes/hexo/components/MenuGroupCard.js +++ b/themes/hexo/components/MenuGroupCard.js @@ -1,19 +1,36 @@ -import Link from 'next/link' -import { useGlobal } from '@/lib/global' -import CONFIG from '../config' import { siteConfig } from '@/lib/config' +import { useGlobal } from '@/lib/global' +import Link from 'next/link' +import CONFIG from '../config' -const MenuGroupCard = (props) => { +const MenuGroupCard = props => { const { postCount, categoryOptions, tagOptions } = props const { locale } = useGlobal() const archiveSlot =
    {postCount}
    - const categorySlot =
    {categoryOptions?.length}
    + const categorySlot = ( +
    {categoryOptions?.length}
    + ) const tagSlot =
    {tagOptions?.length}
    const links = [ - { name: locale.COMMON.ARTICLE, to: '/archive', slot: archiveSlot, show: siteConfig('HEXO_MENU_ARCHIVE', null, CONFIG) }, - { name: locale.COMMON.CATEGORY, to: '/category', slot: categorySlot, show: siteConfig('HEXO_MENU_CATEGORY', null, CONFIG) }, - { name: locale.COMMON.TAGS, to: '/tag', slot: tagSlot, show: siteConfig('HEXO_MENU_TAG', null, CONFIG) } + { + name: locale.COMMON.ARTICLE, + to: '/archive', + slot: archiveSlot, + show: siteConfig('HEXO_MENU_ARCHIVE', null, CONFIG) + }, + { + name: locale.COMMON.CATEGORY, + to: '/category', + slot: categorySlot, + show: siteConfig('HEXO_MENU_CATEGORY', null, CONFIG) + }, + { + name: locale.COMMON.TAGS, + to: '/tag', + slot: tagSlot, + show: siteConfig('HEXO_MENU_TAG', null, CONFIG) + } ] for (let i = 0; i < links.length; i++) { @@ -23,29 +40,31 @@ const MenuGroupCard = (props) => { } return ( - + ) } export default MenuGroupCard diff --git a/themes/hexo/components/MenuItemCollapse.js b/themes/hexo/components/MenuItemCollapse.js index e8a030c2..828079c7 100644 --- a/themes/hexo/components/MenuItemCollapse.js +++ b/themes/hexo/components/MenuItemCollapse.js @@ -7,7 +7,7 @@ import { useState } from 'react' * @param {*} param0 * @returns */ -export const MenuItemCollapse = (props) => { +export const MenuItemCollapse = props => { const { link } = props const [show, changeShow] = useState(false) const hasSubMenu = link?.subMenus?.length > 0 @@ -26,30 +26,55 @@ export const MenuItemCollapse = (props) => { return null } - return <> -
    - {!hasSubMenu && - {link?.icon && }{link?.name} - } - {hasSubMenu &&
    - {link?.icon && }{link?.name} - -
    } -
    + return ( + <> +
    + {!hasSubMenu && ( + + + {link?.icon && } + {link?.name} + + + )} + {hasSubMenu && ( +
    + + {link?.icon && } + {link?.name} + + +
    + )} +
    - {/* 折叠子菜单 */} - {hasSubMenu && - {link.subMenus.map((sLink, index) => { - return
    - - {link?.icon && } {sLink.title} - -
    - })} -
    } + {/* 折叠子菜单 */} + {hasSubMenu && ( + + {link.subMenus.map((sLink, index) => { + return ( +
    + + + {link?.icon && }{' '} + {sLink.title} + + +
    + ) + })} +
    + )} + ) } diff --git a/themes/hexo/components/MenuItemDrop.js b/themes/hexo/components/MenuItemDrop.js index 68567382..b74d7a8f 100644 --- a/themes/hexo/components/MenuItemDrop.js +++ b/themes/hexo/components/MenuItemDrop.js @@ -9,33 +9,51 @@ export const MenuItemDrop = ({ link }) => { return null } - return
    changeShow(true)} onMouseOut={() => changeShow(false)} > + return ( +
    changeShow(true)} + onMouseOut={() => changeShow(false)}> + {!hasSubMenu && ( + + {link?.icon && } {link?.name} + {hasSubMenu && } + + )} - {!hasSubMenu && - - {link?.icon && } {link?.name} - {hasSubMenu && } - } - - {hasSubMenu && <> -
    - {link?.icon && } {link?.name} - -
    - } - - {/* 子菜单 */} - {hasSubMenu &&
      - {link.subMenus.map((sLink, index) => { - return
    • - - {link?.icon &&   }{sLink.title} - -
    • - })} -
    } + {hasSubMenu && ( + <> +
    + {link?.icon && } {link?.name} + +
    + + )} + {/* 子菜单 */} + {hasSubMenu && ( +
      + {link.subMenus.map((sLink, index) => { + return ( +
    • + + + {link?.icon &&   } + {sLink.title} + + +
    • + ) + })} +
    + )}
    + ) } diff --git a/themes/matery/components/MenuGroupCard.js b/themes/matery/components/MenuGroupCard.js index acd0c3b2..8c6c43a2 100644 --- a/themes/matery/components/MenuGroupCard.js +++ b/themes/matery/components/MenuGroupCard.js @@ -1,9 +1,9 @@ -import Link from 'next/link' -import { useGlobal } from '@/lib/global' -import CONFIG from '../config' import { siteConfig } from '@/lib/config' +import { useGlobal } from '@/lib/global' +import Link from 'next/link' +import CONFIG from '../config' -const MenuGroupCard = (props) => { +const MenuGroupCard = props => { const { postCount, categories, tags } = props const { locale } = useGlobal() const archiveSlot =
    {postCount}
    @@ -11,35 +11,50 @@ const MenuGroupCard = (props) => { const tagSlot =
    {tags?.length}
    const links = [ - { name: locale.COMMON.ARTICLE, to: '/archive', slot: archiveSlot, show: siteConfig('MATERY_MENU_ARCHIVE', null, CONFIG) }, - { name: locale.COMMON.CATEGORY, to: '/category', slot: categorySlot, show: siteConfig('MATERY_MENU_CATEGORY', null, CONFIG) }, - { name: locale.COMMON.TAGS, to: '/tag', slot: tagSlot, show: siteConfig('MATERY_MENU_TAG', null, CONFIG) } + { + name: locale.COMMON.ARTICLE, + to: '/archive', + slot: archiveSlot, + show: siteConfig('MATERY_MENU_ARCHIVE', null, CONFIG) + }, + { + name: locale.COMMON.CATEGORY, + to: '/category', + slot: categorySlot, + show: siteConfig('MATERY_MENU_CATEGORY', null, CONFIG) + }, + { + name: locale.COMMON.TAGS, + to: '/tag', + slot: tagSlot, + show: siteConfig('MATERY_MENU_TAG', null, CONFIG) + } ] return ( + {links.map(link => { + if (link.show) { + return ( + +
    +
    {link.name}
    +
    {link.slot}
    +
    + + ) + } else { + return null + } + })} + ) } export default MenuGroupCard diff --git a/themes/matery/components/MenuItemCollapse.js b/themes/matery/components/MenuItemCollapse.js index dbd9aca1..6cd373f6 100644 --- a/themes/matery/components/MenuItemCollapse.js +++ b/themes/matery/components/MenuItemCollapse.js @@ -27,35 +27,63 @@ export const MenuItemCollapse = ({ link }) => { return null } - const selected = (router.pathname === link.to) || (router.asPath === link.to) + const selected = router.pathname === link.to || router.asPath === link.to - return <> -
    + return ( + <> +
    + {!hasSubMenu && ( + +
    + {link.icon && ( + + )} +
    {link.name}
    +
    + {link.slot} + + )} - {!hasSubMenu && -
    - {link.icon && } -
    {link.name}
    -
    - {link.slot} - } + {hasSubMenu && ( +
    +
    + + {link?.name} +
    + +
    + )} +
    - {hasSubMenu &&
    -
    {link?.name}
    - -
    } -
    - - {/* 折叠子菜单 */} - {hasSubMenu && - {link.subMenus.map((sLink, index) => { - return
    - - {sLink.title} - -
    - })} -
    } + {/* 折叠子菜单 */} + {hasSubMenu && ( + + {link.subMenus.map((sLink, index) => { + return ( +
    + + + + {sLink.title} + + +
    + ) + })} +
    + )} + ) } diff --git a/themes/matery/components/MenuItemDrop.js b/themes/matery/components/MenuItemDrop.js index d123cfe8..f7373f7c 100644 --- a/themes/matery/components/MenuItemDrop.js +++ b/themes/matery/components/MenuItemDrop.js @@ -9,33 +9,51 @@ export const MenuItemDrop = ({ link }) => { return null } - return
    changeShow(true)} onMouseOut={() => changeShow(false)} > + return ( +
    changeShow(true)} + onMouseOut={() => changeShow(false)}> + {!hasSubMenu && ( + + {link?.icon && } {link?.name} + {hasSubMenu && } + + )} - {!hasSubMenu && - - {link?.icon && } {link?.name} - {hasSubMenu && } - } - - {hasSubMenu && <> -
    - {link?.icon && } {link?.name} - -
    - } - - {/* 子菜单 */} - {hasSubMenu &&
      - {link.subMenus.map((sLink, index) => { - return
    • - - {link?.icon &&   }{sLink.title} - -
    • - })} -
    } + {hasSubMenu && ( + <> +
    + {link?.icon && } {link?.name} + +
    + + )} + {/* 子菜单 */} + {hasSubMenu && ( +
      + {link.subMenus.map((sLink, index) => { + return ( +
    • + + + {link?.icon &&   } + {sLink.title} + + +
    • + ) + })} +
    + )}
    + ) } diff --git a/themes/medium/components/MenuItemCollapse.js b/themes/medium/components/MenuItemCollapse.js index ef1f19c5..3887b889 100644 --- a/themes/medium/components/MenuItemCollapse.js +++ b/themes/medium/components/MenuItemCollapse.js @@ -8,7 +8,7 @@ import { useState } from 'react' * @param {*} param0 * @returns */ -export const MenuItemCollapse = (props) => { +export const MenuItemCollapse = props => { const { link } = props const [show, changeShow] = useState(false) const hasSubMenu = link?.subMenus?.length > 0 @@ -21,7 +21,7 @@ export const MenuItemCollapse = (props) => { return null } - const selected = (router.pathname === link.to) || (router.asPath === link.to) + const selected = router.pathname === link.to || router.asPath === link.to const toggleShow = () => { changeShow(!show) @@ -31,32 +31,67 @@ export const MenuItemCollapse = (props) => { changeIsOpen(!isOpen) } - return <> -
    + return ( + <> +
    + {!hasSubMenu && ( + +
    +
    + {link.name} +
    + + )} - {!hasSubMenu && -
    {link.name}
    - } + {hasSubMenu && ( +
    +
    +
    + {link.name} +
    +
    + +
    +
    + )} +
    - {hasSubMenu &&
    -
    {link.name}
    -
    -
    } -
    - - {/* 折叠子菜单 */} - {hasSubMenu && - {link?.subMenus?.map(sLink => { - return
    - -
    {sLink.title}
    - -
    - })} - } + +
    +
    + {sLink.title} +
    + +
    + ) + })} + + )} + ) } diff --git a/themes/medium/components/MenuItemDrop.js b/themes/medium/components/MenuItemDrop.js index 361db69f..4916a34e 100644 --- a/themes/medium/components/MenuItemDrop.js +++ b/themes/medium/components/MenuItemDrop.js @@ -1,6 +1,6 @@ import Link from 'next/link' -import { useState } from 'react' import { useRouter } from 'next/router' +import { useState } from 'react' export const MenuItemDrop = ({ link }) => { const [show, changeShow] = useState(false) @@ -12,39 +12,65 @@ export const MenuItemDrop = ({ link }) => { return null } const hasSubMenu = link?.subMenus?.length > 0 - const selected = (router.pathname === link.to) || (router.asPath === link.to) + const selected = router.pathname === link.to || router.asPath === link.to - return
  • changeShow(true)} onMouseOut={() => changeShow(false)} > + return ( +
  • changeShow(true)} + onMouseOut={() => changeShow(false)}> + {hasSubMenu && ( +
    +
    + {link?.icon && } {link?.name} + {hasSubMenu && ( + + )} +
    +
    + )} - {hasSubMenu && -
    -
    - {link?.icon && } {link?.name} - {hasSubMenu && } -
    -
    - } + {!hasSubMenu && ( +
    + + {link?.icon && } {link?.name} + +
    + )} - {!hasSubMenu && -
    - - {link?.icon && } {link?.name} + {/* 子菜单 */} + {hasSubMenu && ( +
      + {link?.subMenus?.map(sLink => { + return ( +
    • + + + {link?.icon &&   } + {sLink.title} + -
    - } - - {/* 子菜单 */} - {hasSubMenu &&
      - {link?.subMenus?.map(sLink => { - return
    • - - {link?.icon &&   }{sLink.title} - -
    • - })} -
    } - +
  • + ) + })} + + )} + ) } diff --git a/themes/movie/components/MenuItemCollapse.js b/themes/movie/components/MenuItemCollapse.js index 0f91f1d4..9f2fbd86 100644 --- a/themes/movie/components/MenuItemCollapse.js +++ b/themes/movie/components/MenuItemCollapse.js @@ -28,11 +28,13 @@ export const MenuItemCollapse = props => { return ( <> -
    +
    {!hasSubMenu && ( {link?.icon && } @@ -56,15 +58,19 @@ export const MenuItemCollapse = props => { {/* 折叠子菜单 */} {hasSubMenu && ( - + {link.subMenus.map((sLink, index) => { return (
    - + - {link?.icon && } {sLink.title} + {link?.icon && }{' '} + {sLink.title}
    diff --git a/themes/movie/components/MenuItemDrop.js b/themes/movie/components/MenuItemDrop.js index 93f27f44..cef4d53d 100644 --- a/themes/movie/components/MenuItemDrop.js +++ b/themes/movie/components/MenuItemDrop.js @@ -12,26 +12,23 @@ export const MenuItemDrop = ({ link }) => { return (
    changeShow(true)} - onMouseOut={() => changeShow(false)} - > + onMouseOut={() => changeShow(false)}> {!hasSubMenu && ( + target={link?.target} + className='select-none menu-link pl-2 pr-4 no-underline tracking-widest pb-1'> {link?.icon && } {link?.name} - {hasSubMenu && } + {hasSubMenu && } )} {hasSubMenu && ( <> -
    +
    {link?.icon && } {link?.name} + className={`px-2 fa fa-angle-down duration-300 ${show ? 'rotate-180' : 'rotate-0'}`}>
    )} @@ -40,19 +37,14 @@ export const MenuItemDrop = ({ link }) => { {hasSubMenu && (
      + className={`${show ? 'visible opacity-100 top-14' : 'invisible opacity-0 top-20'} drop-shadow-md overflow-hidden rounded-md text-black dark:text-white bg-white dark:bg-black transition-all duration-300 z-30 absolute block `}> {link.subMenus.map((sLink, index) => { return (
    • - - + className='cursor-pointer text-start dark:bg-hexo-black-gray dark:hover:bg-gray-300 hover:bg-gray-300 hover:text-black tracking-widest transition-all duration-200 dark:border-gray-800 py-1 pr-6 pl-3'> + + {link?.icon &&   } {sLink.title} diff --git a/themes/nav/components/MenuItemCollapse.js b/themes/nav/components/MenuItemCollapse.js index 4bbf09e4..18ab3918 100755 --- a/themes/nav/components/MenuItemCollapse.js +++ b/themes/nav/components/MenuItemCollapse.js @@ -8,7 +8,7 @@ import { useState } from 'react' * @param {*} param0 * @returns */ -export const MenuItemCollapse = (props) => { +export const MenuItemCollapse = props => { const { link } = props const [show, changeShow] = useState(false) const hasSubMenu = link?.subMenus?.length > 0 @@ -21,7 +21,7 @@ export const MenuItemCollapse = (props) => { return null } - const selected = (router.pathname === link.to) || (router.asPath === link.to) + const selected = router.pathname === link.to || router.asPath === link.to const toggleShow = () => { changeShow(!show) @@ -31,32 +31,67 @@ export const MenuItemCollapse = (props) => { changeIsOpen(!isOpen) } - return <> -
      + return ( + <> +
      + {!hasSubMenu && ( + +
      +
      + {link.name} +
      + + )} - {!hasSubMenu && -
      {link.name}
      - } + {hasSubMenu && ( +
      +
      +
      + {link.name} +
      +
      + +
      +
      + )} +
      - {hasSubMenu &&
      -
      {link.name}
      -
      -
      } -
      - - {/* 折叠子菜单 */} - {hasSubMenu && - {link?.subMenus?.map((sLink, index) => { - return
      - {/* */} - - - })} - } + {/* */} + + + ) + })} + + )} + ) } diff --git a/themes/nav/components/MenuItemDrop.js b/themes/nav/components/MenuItemDrop.js index c3636ba0..d6226480 100755 --- a/themes/nav/components/MenuItemDrop.js +++ b/themes/nav/components/MenuItemDrop.js @@ -1,6 +1,6 @@ import Link from 'next/link' -import { useState } from 'react' import { useRouter } from 'next/router' +import { useState } from 'react' export const MenuItemDrop = ({ link }) => { const [show, changeShow] = useState(false) @@ -12,39 +12,65 @@ export const MenuItemDrop = ({ link }) => { return null } const hasSubMenu = link?.subMenus?.length > 0 - const selected = (router.pathname === link.to) || (router.asPath === link.to) + const selected = router.pathname === link.to || router.asPath === link.to - return
    • changeShow(true)} onMouseOut={() => changeShow(false)} > + return ( +
    • changeShow(true)} + onMouseOut={() => changeShow(false)}> + {hasSubMenu && ( +
      +
      + {link?.icon && } {link?.name} + {hasSubMenu && ( + + )} +
      +
      + )} - {hasSubMenu && -
      -
      - {link?.icon && } {link?.name} - {hasSubMenu && } -
      -
      - } + {!hasSubMenu && ( +
      + + {link?.icon && } {link?.name} + +
      + )} - {!hasSubMenu && -
      - - {link?.icon && } {link?.name} + {/* 子菜单 */} + {hasSubMenu && ( +
        + {link?.subMenus?.map((sLink, index) => { + return ( +
      • + + + {link?.icon &&   } + {sLink.title} + -
      - } - - {/* 子菜单 */} - {hasSubMenu &&
        - {link?.subMenus?.map((sLink, index) => { - return
      • - - {link?.icon &&   }{sLink.title} - -
      • - })} -
      } - +
    • + ) + })} +
    + )} + ) } diff --git a/themes/next/components/MenuItemCollapse.js b/themes/next/components/MenuItemCollapse.js index 77fd4282..162c0184 100644 --- a/themes/next/components/MenuItemCollapse.js +++ b/themes/next/components/MenuItemCollapse.js @@ -7,7 +7,7 @@ import { useState } from 'react' * @param {*} param0 * @returns */ -export const MenuItemCollapse = (props) => { +export const MenuItemCollapse = props => { const { link } = props const [show, changeShow] = useState(false) const hasSubMenu = link?.subMenus?.length > 0 @@ -22,32 +22,64 @@ export const MenuItemCollapse = (props) => { changeIsOpen(!isOpen) } - return <> -
    - {!hasSubMenu && -
    {link.name}
    - } + return ( + <> +
    + {!hasSubMenu && ( + +
    +
    + {link.name} +
    + + )} - {hasSubMenu &&
    -
    {link.name}
    -
    -
    } -
    + {hasSubMenu && ( +
    +
    +
    + {link.name} +
    +
    + +
    +
    + )} +
    - {/* 折叠子菜单 */} - {hasSubMenu && - {link.subMenus.map((sLink, index) => { - return
    - -
    {sLink.icon &&
    }{sLink.title}
    - -
    - })} - } + +
    + {sLink.icon && ( +
    + )} + {sLink.title} +
    + +
    + ) + })} + + )} + ) } diff --git a/themes/next/components/MenuItemDrop.js b/themes/next/components/MenuItemDrop.js index 37ae949f..580d5dc1 100644 --- a/themes/next/components/MenuItemDrop.js +++ b/themes/next/components/MenuItemDrop.js @@ -5,34 +5,62 @@ export const MenuItemDrop = ({ link }) => { const [show, changeShow] = useState(false) const hasSubMenu = link?.subMenus?.length > 0 - return
  • changeShow(true)} onMouseOut={() => changeShow(false)} - className='relative py-1.5 px-5 duration-300 text-base justify-between hover:bg-gray-700 hover:text-white hover:shadow-lg cursor-pointer font-light flex flex-nowrap items-center '> + return ( +
  • changeShow(true)} + onMouseOut={() => changeShow(false)} + className='relative py-1.5 px-5 duration-300 text-base justify-between hover:bg-gray-700 hover:text-white hover:shadow-lg cursor-pointer font-light flex flex-nowrap items-center '> + {!hasSubMenu && ( + +
    +
    + {link.name} +
    + {link.slot} + + )} - {!hasSubMenu && - -
    {link.name}
    - {link.slot} - } - - {hasSubMenu && -
    -
    {link.name}
    - {link.slot} - {hasSubMenu &&
    } -
    } - - {/* 子菜单 */} - {hasSubMenu &&
      - {link?.subMenus?.map(sLink => { - return
    • - - {sLink.icon && } -
      {sLink.name}
      - {sLink.slot} - -
    • - })} -
    } + {hasSubMenu && ( +
    +
    +
    + {link.name} +
    + {link.slot} + {hasSubMenu && ( +
    + +
    + )} +
    + )} + {/* 子菜单 */} + {hasSubMenu && ( +
      + {link?.subMenus?.map(sLink => { + return ( +
    • + + {sLink.icon && ( + + )} +
      {sLink.name}
      + {sLink.slot} + +
    • + ) + })} +
    + )}
  • + ) } diff --git a/themes/nobelium/components/MenuItemCollapse.js b/themes/nobelium/components/MenuItemCollapse.js index 8f53f622..c8a18d78 100644 --- a/themes/nobelium/components/MenuItemCollapse.js +++ b/themes/nobelium/components/MenuItemCollapse.js @@ -7,7 +7,7 @@ import { useState } from 'react' * @param {*} param0 * @returns */ -export const MenuItemCollapse = (props) => { +export const MenuItemCollapse = props => { const { link } = props const [show, changeShow] = useState(false) const hasSubMenu = link?.subMenus?.length > 0 @@ -26,30 +26,59 @@ export const MenuItemCollapse = (props) => { return null } - return <> -
    - {!hasSubMenu && - {link?.icon && }{link?.name} - } - {hasSubMenu &&
    - {link?.icon && }{link?.name} - -
    } -
    + return ( + <> +
    + {!hasSubMenu && ( + + + {link?.icon && ( + + + + )} + {link?.name} + + + )} + {hasSubMenu && ( +
    + + {link?.icon && ( + + + + )} + {link?.name} + + +
    + )} +
    - {/* 折叠子菜单 */} - {hasSubMenu && - {link.subMenus.map((sLink, index) => { - return
    - - {sLink.title} - -
    - })} -
    } + {/* 折叠子菜单 */} + {hasSubMenu && ( + + {link.subMenus.map((sLink, index) => { + return ( +
    + + {sLink.title} + +
    + ) + })} +
    + )} + ) } diff --git a/themes/nobelium/components/MenuItemDrop.js b/themes/nobelium/components/MenuItemDrop.js index 0386910c..bd2b3ae7 100644 --- a/themes/nobelium/components/MenuItemDrop.js +++ b/themes/nobelium/components/MenuItemDrop.js @@ -11,35 +11,49 @@ export const MenuItemDrop = ({ link }) => { const hasSubMenu = link?.subMenus?.length > 0 - return
  • -
    changeShow(true)} onMouseOut={() => changeShow(false)}> - {!hasSubMenu && -
    - - {link?.icon && } {link?.name} - + return ( +
  • +
    changeShow(true)} + onMouseOut={() => changeShow(false)}> + {!hasSubMenu && ( +
    + + {link?.icon && } {link?.name} + +
    + )} + + {hasSubMenu && ( +
    + {link?.icon && } {link?.name} + +
    + )} + + {/* 子菜单 */} + {hasSubMenu && ( +
      + {link.subMenus.map((sLink, index) => { + return ( +
      + + + {link?.icon &&   } + {sLink.title} + +
      - } - - {hasSubMenu && -
      - {link?.icon && } {link?.name} - -
      - } - - {/* 子菜单 */} - {hasSubMenu &&
        - {link.subMenus.map((sLink, index) => { - return
        - - {link?.icon &&   }{sLink.title} - -
        - })} -
      } - -
    - + ) + })} + + )} +
  • + ) } diff --git a/themes/plog/components/MenuItemCollapse.js b/themes/plog/components/MenuItemCollapse.js index 8f53f622..c8a18d78 100644 --- a/themes/plog/components/MenuItemCollapse.js +++ b/themes/plog/components/MenuItemCollapse.js @@ -7,7 +7,7 @@ import { useState } from 'react' * @param {*} param0 * @returns */ -export const MenuItemCollapse = (props) => { +export const MenuItemCollapse = props => { const { link } = props const [show, changeShow] = useState(false) const hasSubMenu = link?.subMenus?.length > 0 @@ -26,30 +26,59 @@ export const MenuItemCollapse = (props) => { return null } - return <> -
    - {!hasSubMenu && - {link?.icon && }{link?.name} - } - {hasSubMenu &&
    - {link?.icon && }{link?.name} - -
    } -
    + return ( + <> +
    + {!hasSubMenu && ( + + + {link?.icon && ( + + + + )} + {link?.name} + + + )} + {hasSubMenu && ( +
    + + {link?.icon && ( + + + + )} + {link?.name} + + +
    + )} +
    - {/* 折叠子菜单 */} - {hasSubMenu && - {link.subMenus.map((sLink, index) => { - return
    - - {sLink.title} - -
    - })} -
    } + {/* 折叠子菜单 */} + {hasSubMenu && ( + + {link.subMenus.map((sLink, index) => { + return ( +
    + + {sLink.title} + +
    + ) + })} +
    + )} + ) } diff --git a/themes/plog/components/MenuItemDrop.js b/themes/plog/components/MenuItemDrop.js index 02ef483d..5d4fce15 100644 --- a/themes/plog/components/MenuItemDrop.js +++ b/themes/plog/components/MenuItemDrop.js @@ -9,32 +9,47 @@ export const MenuItemDrop = ({ link }) => { const hasSubMenu = link?.subMenus?.length > 0 - return
  • changeShow(true)} onMouseLeave={() => changeShow(false)}> - {!hasSubMenu && -
    - - {link?.icon && } {link?.name} - -
    - } + return ( +
  • changeShow(true)} + onMouseLeave={() => changeShow(false)}> + {!hasSubMenu && ( +
    + + {link?.icon && } {link?.name} + +
    + )} - {hasSubMenu && -
    - {link?.icon && } {link?.name} - -
    - } + {hasSubMenu && ( +
    + {link?.icon && } {link?.name} + +
    + )} - {/* 子菜单 */} - {hasSubMenu &&
      - {link.subMenus.map((sLink, index) => { - return
    • - - {link?.icon &&   }{sLink.title} - -
    • - })} -
    } - -
  • + {/* 子菜单 */} + {hasSubMenu && ( +
      + {link.subMenus.map((sLink, index) => { + return ( +
    • + + + {link?.icon &&   } + {sLink.title} + + +
    • + ) + })} +
    + )} + + ) } diff --git a/themes/simple/components/MenuItemCollapse.js b/themes/simple/components/MenuItemCollapse.js index 35371cc8..7bd2cc13 100644 --- a/themes/simple/components/MenuItemCollapse.js +++ b/themes/simple/components/MenuItemCollapse.js @@ -7,7 +7,7 @@ import { useState } from 'react' * @param {*} param0 * @returns */ -export const MenuItemCollapse = (props) => { +export const MenuItemCollapse = props => { const { link } = props const [show, changeShow] = useState(false) const hasSubMenu = link?.subMenus?.length > 0 @@ -26,30 +26,67 @@ export const MenuItemCollapse = (props) => { return null } - return <> -
    - {!hasSubMenu && - {link?.icon && }{link?.name} - } - {hasSubMenu &&
    - {link?.icon && }{link?.name} - -
    } -
    + return ( + <> +
    + {!hasSubMenu && ( + + + {link?.icon && ( + + + + )} + {link?.name} + + + )} + {hasSubMenu && ( +
    + + {link?.icon && ( + + + + )} + {link?.name} + + +
    + )} +
    - {/* 折叠子菜单 */} - {hasSubMenu && - {link.subMenus.map((sLink, index) => { - return
    - - {sLink?.icon && }{sLink.title} - -
    - })} -
    } + {/* 折叠子菜单 */} + {hasSubMenu && ( + + {link.subMenus.map((sLink, index) => { + return ( +
    + + + {sLink?.icon && ( + + + + )} + {sLink.title} + + +
    + ) + })} +
    + )} + ) } diff --git a/themes/simple/components/MenuItemDrop.js b/themes/simple/components/MenuItemDrop.js index 66a27b27..316dc0da 100644 --- a/themes/simple/components/MenuItemDrop.js +++ b/themes/simple/components/MenuItemDrop.js @@ -9,33 +9,60 @@ export const MenuItemDrop = ({ link }) => { return null } - return
    changeShow(true)} onMouseOut={() => changeShow(false)} > + return ( +
    changeShow(true)} + onMouseOut={() => changeShow(false)}> + {!hasSubMenu && ( + + {link?.icon && ( + + + + )} + {link?.name} + {hasSubMenu && } + + )} - {!hasSubMenu && - - {link?.icon && }{link?.name} - {hasSubMenu && } - } - - {hasSubMenu && <> -
    - {link?.icon && } {link?.name} - -
    - } - - {/* 子菜单 */} - {hasSubMenu &&
      - {link.subMenus.map((sLink, index) => { - return
    • - - {sLink?.icon &&   }{sLink.title} - -
    • - })} -
    } + {hasSubMenu && ( + <> +
    + {link?.icon && ( + + + + )}{' '} + {link?.name} + +
    + + )} + {/* 子菜单 */} + {hasSubMenu && ( +
      + {link.subMenus.map((sLink, index) => { + return ( +
    • + + + {sLink?.icon &&   } + {sLink.title} + + +
    • + ) + })} +
    + )}
    + ) } diff --git a/themes/starter/components/Logo.js b/themes/starter/components/Logo.js index b6afeae1..5027b01f 100644 --- a/themes/starter/components/Logo.js +++ b/themes/starter/components/Logo.js @@ -1,10 +1,11 @@ +/* eslint-disable @next/next/no-img-element */ /* eslint-disable @next/next/no-html-link-for-pages */ -import { siteConfig } from '@/lib/config'; -import { useGlobal } from '@/lib/global'; -import throttle from 'lodash.throttle'; -import { useRouter } from 'next/router'; -import { useEffect, useState } from 'react'; -import CONFIG from '../config'; +import { siteConfig } from '@/lib/config' +import { useGlobal } from '@/lib/global' +import throttle from 'lodash.throttle' +import { useRouter } from 'next/router' +import { useEffect, useState } from 'react' +import CONFIG from '../config' /** * 站点图标 @@ -21,10 +22,9 @@ export const Logo = ({ white }) => { // 滚动监听 const throttleMs = 200 const navBarScrollListener = throttle(() => { - const scrollY = window.scrollY; + const scrollY = window.scrollY // 何时显示浅色或白底的logo const homePageNavBar = router.route === '/' && scrollY < 10 // 在首页并且视窗在页面顶部 - console.log('白色', homePageNavBar, router.route, scrollY < 10) if (white || isDarkMode || homePageNavBar) { setLogo(siteConfig('STARTER_LOGO_WHITE', null, CONFIG)) setLogoTextColor('text-white') @@ -41,21 +41,29 @@ export const Logo = ({ white }) => { } }, [isDarkMode, router]) - return
    -
    - {/* eslint-disable-next-line @next/next/no-img-element */} - {logo && { - router.push('/') - }} - src={logo} - alt="logo" - className="header-logo w-full" - />} - {/* logo文字 */} - { router.push('/') }} className={`${logoTextColor} dark:text-white py-1.5 header-logo-text whitespace-nowrap text-2xl font-semibold`}> - {siteConfig('TITLE')} - -
    + return ( +
    +
    + {/* eslint-disable-next-line @next/next/no-img-element */} + {logo && ( + { + router.push('/') + }} + src={logo} + alt='logo' + className='header-logo w-full' + /> + )} + {/* logo文字 */} + { + router.push('/') + }} + className={`${logoTextColor} dark:text-white py-1.5 header-logo-text whitespace-nowrap text-2xl font-semibold`}> + {siteConfig('TITLE')} + +
    + ) } diff --git a/themes/starter/components/MenuItem.js b/themes/starter/components/MenuItem.js index d5ce70a2..49b71b0d 100644 --- a/themes/starter/components/MenuItem.js +++ b/themes/starter/components/MenuItem.js @@ -4,44 +4,61 @@ import { useRouter } from 'next/router' export const MenuItem = ({ link }) => { const hasSubMenu = link?.subMenus?.length > 0 const router = useRouter() - return <> - {/* MenuItem */} - {!hasSubMenu &&
  • - - {link?.icon && }{link?.name} - -
  • } + return ( + <> + {/* MenuItem */} + {!hasSubMenu && ( +
  • + + {link?.icon && } + {link?.name} + +
  • + )} - {hasSubMenu &&
  • + {hasSubMenu && ( +
  • + {/* 有子菜单的MenuItem */} + + {link?.icon && } + {link?.name} - {/* 有子菜单的MenuItem */} - - {link?.icon && }{link?.name} + + + + - - - - - -
    - {link.subMenus.map((sLink, index) => { - return - {/* 子菜单SubMenuItem */} - {link?.icon && } {sLink.title} +
    + {link.subMenus.map((sLink, index) => { + return ( + + {/* 子菜单SubMenuItem */} + + {link?.icon && ( + + )}{' '} + {sLink.title} + - })} -
    -
  • } + ) + })} +
    + + )} + ) }