From ed947d866ee257a5d44efcb190a700900bded0c1 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Tue, 19 Nov 2024 14:44:32 +0800 Subject: [PATCH] =?UTF-8?q?Gitbook=20=E4=B8=BB=E9=A2=98=EF=BC=9B=E5=BA=95?= =?UTF-8?q?=E9=83=A8=E8=8F=9C=E5=8D=95=E6=A0=B7=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/gitbook/components/BottomMenuBar.js | 47 ++++++++++++++----- .../gitbook/components/MobileButtonCatalog.js | 31 ------------ .../gitbook/components/MobileButtonPageNav.js | 30 ------------ 3 files changed, 35 insertions(+), 73 deletions(-) delete mode 100644 themes/gitbook/components/MobileButtonCatalog.js delete mode 100644 themes/gitbook/components/MobileButtonPageNav.js diff --git a/themes/gitbook/components/BottomMenuBar.js b/themes/gitbook/components/BottomMenuBar.js index 478a52eb..c872941b 100644 --- a/themes/gitbook/components/BottomMenuBar.js +++ b/themes/gitbook/components/BottomMenuBar.js @@ -1,5 +1,5 @@ -import MobileButtonCatalog from './MobileButtonCatalog' -import MobileButtonPageNav from './MobileButtonPageNav' +import { useGlobal } from '@/lib/global' +import { useGitBookGlobal } from '..' /** * 移动端底部导航 @@ -8,20 +8,43 @@ import MobileButtonPageNav from './MobileButtonPageNav' */ export default function BottomMenuBar({ post, className }) { const showTocButton = post?.toc?.length > 1 + const { locale } = useGlobal() + const { pageNavVisible, changePageNavVisible, tocVisible, changeTocVisible } = + useGitBookGlobal() + const togglePageNavVisible = () => { + changePageNavVisible(!pageNavVisible) + } + + const toggleToc = () => { + changeTocVisible(!tocVisible) + } return ( - <> - {/* 移动端底部导航按钮 */} -
-
- -
+
+
+ + {showTocButton && ( -
- -
+ )}
- +
) } diff --git a/themes/gitbook/components/MobileButtonCatalog.js b/themes/gitbook/components/MobileButtonCatalog.js deleted file mode 100644 index e9e8b4e0..00000000 --- a/themes/gitbook/components/MobileButtonCatalog.js +++ /dev/null @@ -1,31 +0,0 @@ -import { useGlobal } from '@/lib/global' -import { useGitBookGlobal } from '@/themes/gitbook' - -/** - * 移动端目录按钮 - */ -export default function MobileButtonCatalog() { - const { tocVisible, changeTocVisible } = useGitBookGlobal() - const { locale } = useGlobal() - - const toggleToc = () => { - changeTocVisible(!tocVisible) - } - - return ( -
- - - {locale.COMMON.TABLE_OF_CONTENTS} - -
- ) -} diff --git a/themes/gitbook/components/MobileButtonPageNav.js b/themes/gitbook/components/MobileButtonPageNav.js deleted file mode 100644 index 78f038f1..00000000 --- a/themes/gitbook/components/MobileButtonPageNav.js +++ /dev/null @@ -1,30 +0,0 @@ -import { useGlobal } from '@/lib/global' -import { useGitBookGlobal } from '@/themes/gitbook' - -/** - * 移动端文章导航按钮 - */ -export default function MobileButtonPageNav() { - const { pageNavVisible, changePageNavVisible } = useGitBookGlobal() - const { locale } = useGlobal() - const togglePageNavVisible = () => { - changePageNavVisible(!pageNavVisible) - } - - return ( - - ) -}