From dedbb0f811882e8f7b48a16a678a1de65993e3df Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Fri, 22 Mar 2024 17:08:40 +0800 Subject: [PATCH] =?UTF-8?q?theme-game=20=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/game/components/BlogListPage.js | 16 +++- themes/game/components/BlogPostBar.js | 29 ++++++++ themes/game/components/DarkModeButton.js | 4 +- themes/game/components/MenuItemDrop.js | 85 ++++++++++++++-------- themes/game/components/MenuList.js | 16 ++-- themes/game/components/PaginationSimple.js | 54 ++++++++++++++ themes/game/components/PostInfo.js | 2 +- themes/game/components/SearchNavBar.js | 17 ----- themes/game/components/SideBarDrawer.js | 6 +- themes/game/index.js | 41 +++++------ 10 files changed, 188 insertions(+), 82 deletions(-) create mode 100644 themes/game/components/BlogPostBar.js create mode 100644 themes/game/components/PaginationSimple.js delete mode 100644 themes/game/components/SearchNavBar.js diff --git a/themes/game/components/BlogListPage.js b/themes/game/components/BlogListPage.js index cf53e13c..8d821bd1 100644 --- a/themes/game/components/BlogListPage.js +++ b/themes/game/components/BlogListPage.js @@ -1,13 +1,25 @@ +import { siteConfig } from '@/lib/config' import { GameListIndexCombine } from './GameListIndexCombine' - +import PaginationSimple from './PaginationSimple' +/** + * 分页博客列表 + * @param {*} props + * @returns + */ export const BlogListPage = props => { + const { page = 1, postCount } = props + const totalPage = Math.ceil( + postCount / parseInt(siteConfig('POSTS_PER_PAGE')) + ) + const showNext = page < totalPage + return ( <>
- {/* 这里不显示分页组件,首页只展示部分即可 */} + ) } diff --git a/themes/game/components/BlogPostBar.js b/themes/game/components/BlogPostBar.js new file mode 100644 index 00000000..bf761253 --- /dev/null +++ b/themes/game/components/BlogPostBar.js @@ -0,0 +1,29 @@ +import { useGlobal } from '@/lib/global' + +/** + * 文章列表上方嵌入 + * @param {*} props + * @returns + */ +export default function BlogPostBar(props) { + const { tag, category } = props + const { locale } = useGlobal() + + if (tag) { + return ( +
+ + {locale.COMMON.TAGS}:{tag} +
+ ) + } else if (category) { + return ( +
+ + {locale.COMMON.CATEGORY}:{category} +
+ ) + } else { + return <> + } +} diff --git a/themes/game/components/DarkModeButton.js b/themes/game/components/DarkModeButton.js index 57361452..b0edaf72 100644 --- a/themes/game/components/DarkModeButton.js +++ b/themes/game/components/DarkModeButton.js @@ -23,7 +23,9 @@ const DarkModeButton = props => {
- + {isDarkMode ? 'Dark Mode' : 'Light Mode'}{' '}
) diff --git a/themes/game/components/MenuItemDrop.js b/themes/game/components/MenuItemDrop.js index 0386910c..2289f3bc 100644 --- a/themes/game/components/MenuItemDrop.js +++ b/themes/game/components/MenuItemDrop.js @@ -3,43 +3,66 @@ import { useState } from 'react' export const MenuItemDrop = ({ link }) => { const [show, changeShow] = useState(false) - // const show = true - // const changeShow = () => {} if (!link || !link.show) { return null } 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/game/components/MenuList.js b/themes/game/components/MenuList.js index 16b2443f..b036bb86 100644 --- a/themes/game/components/MenuList.js +++ b/themes/game/components/MenuList.js @@ -47,21 +47,25 @@ export const MenuList = props => { } return ( -
      -
    • +
        +
      • -
      • +
      • +
      • + {links?.length > 0 &&
        } {links?.map( (link, index) => diff --git a/themes/game/components/PaginationSimple.js b/themes/game/components/PaginationSimple.js new file mode 100644 index 00000000..3f5a2760 --- /dev/null +++ b/themes/game/components/PaginationSimple.js @@ -0,0 +1,54 @@ +import { useGlobal } from '@/lib/global' +import Link from 'next/link' +import { useRouter } from 'next/router' + +/** + * 简易翻页插件 + * @param page 当前页码 + * @param showNext 是否有下一页 + * @returns {JSX.Element} + * @constructor + */ +const PaginationSimple = ({ page, showNext }) => { + const { locale } = useGlobal() + const router = useRouter() + const currentPage = +page + const pagePrefix = router.asPath + .split('?')[0] + .replace(/\/page\/[1-9]\d*/, '') + .replace(/\/$/, '') + + return ( +
        + + ←{locale.PAGINATION.PREV} + + + {locale.PAGINATION.NEXT}→ + +
        + ) +} + +export default PaginationSimple diff --git a/themes/game/components/PostInfo.js b/themes/game/components/PostInfo.js index 8b9b4983..8471d9db 100644 --- a/themes/game/components/PostInfo.js +++ b/themes/game/components/PostInfo.js @@ -33,7 +33,7 @@ export default function PostInfo(props) { <>