+
{/* 侧边抽屉 */}
-
-
+
+
+ className='w-full'
+ enter='transition ease-in-out duration-700 transform order-first'
+ enterFrom='opacity-0 translate-y-16'
+ enterTo='opacity-100'
+ leave='transition ease-in-out duration-300 transform'
+ leaveFrom='opacity-100 translate-y-0'
+ leaveTo='opacity-0 -translate-y-16'
+ unmount={false}>
{headerSlot}
{children}
-
-
-
+
)
@@ -96,49 +103,64 @@ const LayoutBase = (props) => {
/**
* 首页
* @param {*} props notion数据
- * @returns 首页就是一个博客列表
- */
-const LayoutIndex = (props) => {
+ * @returns 首页就是一个博客列表
+ */
+const LayoutIndex = props => {
return
}
/**
* 博客列表
* @param {*} props
- */
-const LayoutPostList = (props) => {
- return <>
-
- {siteConfig('POST_LIST_STYLE') === 'page' ?
:
}
- >
+ */
+const LayoutPostList = props => {
+ return (
+ <>
+
+
+
+ {siteConfig('POST_LIST_STYLE') === 'page' ? (
+
+ ) : (
+
+ )}
+ >
+ )
}
/**
* 文章详情
* @param {*} props
- * @returns
- */
-const LayoutSlug = (props) => {
+ * @returns
+ */
+const LayoutSlug = props => {
const { post, lock, validPassword } = props
const router = useRouter()
useEffect(() => {
// 404
if (!post) {
- setTimeout(() => {
- if (isBrowser) {
- const article = document.getElementById('notion-article')
- if (!article) {
- router.push('/404').then(() => {
- console.warn('找不到页面', router.asPath)
- })
+ setTimeout(
+ () => {
+ if (isBrowser) {
+ const article = document.getElementById('notion-article')
+ if (!article) {
+ router.push('/404').then(() => {
+ console.warn('找不到页面', router.asPath)
+ })
+ }
}
- }
- }, siteConfig('POST_WAITING_TIME_FOR_404') * 1000)
+ },
+ siteConfig('POST_WAITING_TIME_FOR_404') * 1000
+ )
}
}, [post])
return (
<>
- {lock ?
:
}
+ {lock ? (
+
+ ) : (
+
+ )}
>
)
}
@@ -167,26 +189,28 @@ const LayoutSearch = props => {
/**
* 归档页面
*/
-const LayoutArchive = (props) => {
+const LayoutArchive = props => {
const { archivePosts } = props
- return <>
-
- {Object.keys(archivePosts).map(archiveTitle => (
-
- ))}
-
- >
+ return (
+ <>
+
+ {Object.keys(archivePosts).map(archiveTitle => (
+
+ ))}
+
+ >
+ )
}
/**
* 404
* @param {*} props
- * @returns
- */
+ * @returns
+ */
const Layout404 = props => {
return <>404>
}
@@ -194,16 +218,17 @@ const Layout404 = props => {
/**
* 分类列表
* @param {*} props
- * @returns
- */
-const LayoutCategoryIndex = (props) => {
+ * @returns
+ */
+const LayoutCategoryIndex = props => {
const { locale } = useGlobal()
const { categoryOptions } = props
return (
<>
- {locale.COMMON.CATEGORY}:
+
+ {locale.COMMON.CATEGORY}:
{categoryOptions?.map(category => {
@@ -214,8 +239,11 @@ const LayoutCategoryIndex = (props) => {
passHref
legacyBehavior>
- {category.name}({category.count})
+ className={
+ 'hover:text-black dark:hover:text-white dark:text-gray-300 dark:hover:bg-gray-600 px-5 cursor-pointer py-2 hover:bg-gray-100'
+ }>
+
+ {category.name}({category.count})
)
@@ -229,36 +257,41 @@ const LayoutCategoryIndex = (props) => {
/**
* 标签列表
* @param {*} props
- * @returns
- */
-const LayoutTagIndex = (props) => {
+ * @returns
+ */
+const LayoutTagIndex = props => {
const { locale } = useGlobal()
const { tagOptions } = props
- return <>
-
-
{locale.COMMON.TAGS}:
-
- >
+ >
+ )
}
export {
- CONFIG as THEME_CONFIG,
+ Layout404,
+ LayoutArchive,
LayoutBase,
+ LayoutCategoryIndex,
LayoutIndex,
+ LayoutPostList,
LayoutSearch,
- LayoutArchive,
LayoutSlug,
- Layout404,
- LayoutPostList,
- LayoutCategoryIndex,
- LayoutTagIndex
+ LayoutTagIndex,
+ CONFIG as THEME_CONFIG
}
diff --git a/themes/gitbook/components/CatalogDrawerWrapper.js b/themes/gitbook/components/CatalogDrawerWrapper.js
new file mode 100644
index 00000000000..3b6ee8daa0d
--- /dev/null
+++ b/themes/gitbook/components/CatalogDrawerWrapper.js
@@ -0,0 +1,60 @@
+import { useGlobal } from '@/lib/global'
+import { useGitBookGlobal } from '@/themes/gitbook'
+import Catalog from './Catalog'
+
+/**
+ * 悬浮抽屉目录
+ * @param toc
+ * @param post
+ * @returns {JSX.Element}
+ * @constructor
+ */
+const CatalogDrawerWrapper = ({ post, cRef }) => {
+ const { tocVisible, changeTocVisible } = useGitBookGlobal()
+ const { locale } = useGlobal()
+ const switchVisible = () => {
+ changeTocVisible(!tocVisible)
+ }
+ return (
+ <>
+
+ {/* 侧边菜单 */}
+
+ {post && (
+ <>
+
+ {locale.COMMON.TABLE_OF_CONTENTS}
+ {
+ changeTocVisible(false)
+ }}>
+
+
+
+
+ >
+ )}
+
+
+ {/* 背景蒙版 */}
+
+ >
+ )
+}
+export default CatalogDrawerWrapper
diff --git a/themes/gitbook/components/FloatTocButton.js b/themes/gitbook/components/FloatTocButton.js
deleted file mode 100644
index 4215f44743b..00000000000
--- a/themes/gitbook/components/FloatTocButton.js
+++ /dev/null
@@ -1,25 +0,0 @@
-import { useGitBookGlobal } from '@/themes/gitbook'
-
-/**
- * 移动端悬浮目录按钮
- */
-export default function FloatTocButton () {
- const { tocVisible, changeTocVisible } = useGitBookGlobal()
-
- const toggleToc = () => {
- changeTocVisible(!tocVisible)
- }
-
- return (
-
- )
-}
diff --git a/themes/gitbook/components/Footer.js b/themes/gitbook/components/Footer.js
index 78a91cd59aa..d0e2a1504d3 100644
--- a/themes/gitbook/components/Footer.js
+++ b/themes/gitbook/components/Footer.js
@@ -4,30 +4,56 @@ const Footer = ({ siteInfo }) => {
const d = new Date()
const currentYear = d.getFullYear()
const since = siteConfig('SINCE')
- const copyrightDate = parseInt(since) < currentYear ? since + '-' + currentYear : currentYear
+ const copyrightDate =
+ parseInt(since) < currentYear ? since + '-' + currentYear : currentYear
return (
-
+
)
}
diff --git a/themes/gitbook/components/Header.js b/themes/gitbook/components/Header.js
index 8dfb3735820..8d5387403ee 100644
--- a/themes/gitbook/components/Header.js
+++ b/themes/gitbook/components/Header.js
@@ -90,7 +90,7 @@ export default function Header(props) {
{isOpen ? (
) : (
-
+
)}
diff --git a/themes/gitbook/components/JumpToTopButton.js b/themes/gitbook/components/JumpToTopButton.js
index 0afdbb6c8ba..21b53733e9a 100644
--- a/themes/gitbook/components/JumpToTopButton.js
+++ b/themes/gitbook/components/JumpToTopButton.js
@@ -1,4 +1,3 @@
-
/**
* 跳转到网页顶部
* 当屏幕下滑500像素后会出现该控件
@@ -9,15 +8,20 @@
*/
const JumpToTopButton = ({ showPercent = false, percent, className }) => {
return (
-
- { window.scrollTo({ top: 0, behavior: 'smooth' }) }} />
-
+
+ {
+ window.scrollTo({ top: 0, behavior: 'smooth' })
+ }}
+ />
+
)
}
diff --git a/themes/gitbook/components/LogoBar.js b/themes/gitbook/components/LogoBar.js
index c2d1c453e86..dfe3caddcae 100644
--- a/themes/gitbook/components/LogoBar.js
+++ b/themes/gitbook/components/LogoBar.js
@@ -1,6 +1,5 @@
import LazyImage from '@/components/LazyImage'
import { siteConfig } from '@/lib/config'
-import { useGitBookGlobal } from '@/themes/gitbook'
import Link from 'next/link'
import CONFIG from '../config'
@@ -11,19 +10,8 @@ import CONFIG from '../config'
*/
export default function LogoBar(props) {
const { siteInfo } = props
- const { pageNavVisible, changePageNavVisible } = useGitBookGlobal()
-
- const togglePageNavVisible = () => {
- changePageNavVisible(!pageNavVisible)
- }
return (
-
-
-
diff --git a/themes/gitbook/components/MobileButtonCatalog.js b/themes/gitbook/components/MobileButtonCatalog.js
new file mode 100644
index 00000000000..2c61289493c
--- /dev/null
+++ b/themes/gitbook/components/MobileButtonCatalog.js
@@ -0,0 +1,27 @@
+import { useGitBookGlobal } from '@/themes/gitbook'
+
+/**
+ * 移动端目录按钮
+ */
+export default function MobileButtonCatalog() {
+ const { tocVisible, changeTocVisible } = useGitBookGlobal()
+
+ const toggleToc = () => {
+ changeTocVisible(!tocVisible)
+ }
+
+ return (
+
+ )
+}
diff --git a/themes/gitbook/components/MobileButtonPageNav.js b/themes/gitbook/components/MobileButtonPageNav.js
new file mode 100644
index 00000000000..65a3c39ad2a
--- /dev/null
+++ b/themes/gitbook/components/MobileButtonPageNav.js
@@ -0,0 +1,27 @@
+import { useGitBookGlobal } from '@/themes/gitbook'
+
+/**
+ * 移动端文章导航按钮
+ */
+export default function MobileButtonPageNav() {
+ const { pageNavVisible, changePageNavVisible } = useGitBookGlobal()
+
+ const togglePageNavVisible = () => {
+ changePageNavVisible(!pageNavVisible)
+ }
+
+ return (
+
+ )
+}
diff --git a/themes/gitbook/components/PageNavDrawer.js b/themes/gitbook/components/PageNavDrawer.js
index b5657d18ff6..eb927762789 100644
--- a/themes/gitbook/components/PageNavDrawer.js
+++ b/themes/gitbook/components/PageNavDrawer.js
@@ -1,3 +1,4 @@
+import { useGlobal } from '@/lib/global'
import { useGitBookGlobal } from '@/themes/gitbook'
import NavPostList from './NavPostList'
@@ -11,6 +12,7 @@ import NavPostList from './NavPostList'
const PageNavDrawer = props => {
const { pageNavVisible, changePageNavVisible } = useGitBookGlobal()
const { filteredNavPages } = props
+ const { locale } = useGlobal()
const switchVisible = () => {
changePageNavVisible(!pageNavVisible)
@@ -24,7 +26,15 @@ const PageNavDrawer = props => {
{/* 侧边菜单 */}
+ overflow-y-hidden shadow-card w-72 duration-200 fixed left-1 bottom-16 rounded py-2 bg-white dark:bg-hexo-black-gray`}>
+
+ {locale.COMMON.ARTICLE}
+ {
+ changePageNavVisible(false)
+ }}>
+
{/* 所有文章列表 */}
diff --git a/themes/gitbook/components/TocDrawer.js b/themes/gitbook/components/TocDrawer.js
deleted file mode 100644
index 7b07044ad09..00000000000
--- a/themes/gitbook/components/TocDrawer.js
+++ /dev/null
@@ -1,34 +0,0 @@
-import { useGitBookGlobal } from '@/themes/gitbook'
-import Catalog from './Catalog'
-
-/**
- * 悬浮抽屉目录
- * @param toc
- * @param post
- * @returns {JSX.Element}
- * @constructor
- */
-const TocDrawer = ({ post, cRef }) => {
- const { tocVisible, changeTocVisible } = useGitBookGlobal()
- const switchVisible = () => {
- changeTocVisible(!tocVisible)
- }
- return <>
-
- {/* 侧边菜单 */}
-
- {post && <>
-
-
-
- >}
-
-
- {/* 背景蒙版 */}
-
- >
-}
-export default TocDrawer
diff --git a/themes/gitbook/index.js b/themes/gitbook/index.js
index 34c4f05d021..89240a633a9 100644
--- a/themes/gitbook/index.js
+++ b/themes/gitbook/index.js
@@ -20,18 +20,19 @@ import ArticleInfo from './components/ArticleInfo'
import { ArticleLock } from './components/ArticleLock'
import BlogArchiveItem from './components/BlogArchiveItem'
import Catalog from './components/Catalog'
+import CatalogDrawerWrapper from './components/CatalogDrawerWrapper'
import CategoryItem from './components/CategoryItem'
-import FloatTocButton from './components/FloatTocButton'
import Footer from './components/Footer'
import Header from './components/Header'
import InfoCard from './components/InfoCard'
import JumpToTopButton from './components/JumpToTopButton'
+import MobileButtonCatalog from './components/MobileButtonCatalog'
+import MobileButtonPageNav from './components/MobileButtonPageNav'
import NavPostList from './components/NavPostList'
import PageNavDrawer from './components/PageNavDrawer'
import RevolverMaps from './components/RevolverMaps'
import SearchInput from './components/SearchInput'
import TagItemMini from './components/TagItemMini'
-import TocDrawer from './components/TocDrawer'
import CONFIG from './config'
import { Style } from './style'
@@ -139,9 +140,8 @@ const LayoutBase = props => {
{/* 左侧推拉抽屉 */}
{fullWidth ? null : (
@@ -149,16 +149,19 @@ const LayoutBase = props => {
className={
'hidden md:block border-r dark:border-transparent relative z-10 dark:bg-hexo-black-gray'
}>
-
- {slotLeft}
-
-
+
+ {/* 导航 */}
+
+ {/* 嵌入 */}
+ {slotLeft}
+ {/* 搜索框 */}
+
+
+ {/* 文章列表 */}
{/* 所有文章列表 */}
-
-
-
+ {/* 页脚 */}
@@ -211,6 +214,7 @@ const LayoutBase = props => {
+ {/* 桌面端目录 */}
{slotRight}
{router.route === '/' && (
@@ -235,12 +239,17 @@ const LayoutBase = props => {
)}
- {/* 移动端悬浮目录按钮 */}
- {showTocButton && !tocVisible && (
-
-
+ {/* 移动端底部按钮 */}
+
+
+
- )}
+ {showTocButton && (
+
+
+
+ )}
+
{/* 移动端导航抽屉 */}
@@ -366,7 +375,8 @@ const LayoutSlug = props => {
)}
-
+ {/* 文章目录 */}
+
)}
>
diff --git a/themes/gitbook/style.js b/themes/gitbook/style.js
index 5e8eaa5a2a3..904da2a7560 100644
--- a/themes/gitbook/style.js
+++ b/themes/gitbook/style.js
@@ -5,14 +5,18 @@
* @returns
*/
const Style = () => {
- return
+ .bottom-button-group {
+ box-shadow: 0px -3px 10px 0px rgba(0, 0, 0, 0.1);
+ }
+ `}
+ )
}
export { Style }
diff --git a/themes/nav/components/FloatButtonCatalog.js b/themes/nav/components/FloatButtonCatalog.js
new file mode 100644
index 00000000000..753451da002
--- /dev/null
+++ b/themes/nav/components/FloatButtonCatalog.js
@@ -0,0 +1,27 @@
+import { useNavGlobal } from '@/themes/nav'
+
+/**
+ * 移动端悬浮目录按钮
+ */
+export default function FloatButtonCatalog() {
+ const { tocVisible, changeTocVisible } = useNavGlobal()
+
+ const toggleToc = () => {
+ changeTocVisible(!tocVisible)
+ }
+
+ return (
+
+ )
+}
diff --git a/themes/nav/components/FloatTocButton.js b/themes/nav/components/FloatTocButton.js
deleted file mode 100755
index d4ff317d186..00000000000
--- a/themes/nav/components/FloatTocButton.js
+++ /dev/null
@@ -1,25 +0,0 @@
-import { useNavGlobal } from '@/themes/nav'
-
-/**
- * 移动端悬浮目录按钮
- */
-export default function FloatTocButton () {
- const { tocVisible, changeTocVisible } = useNavGlobal()
-
- const toggleToc = () => {
- changeTocVisible(!tocVisible)
- }
-
- return (
-
- )
-}
diff --git a/themes/nav/index.js b/themes/nav/index.js
index 54cea4b8acb..4a9bd72415e 100755
--- a/themes/nav/index.js
+++ b/themes/nav/index.js
@@ -25,7 +25,7 @@ import BlogArchiveItem from './components/BlogArchiveItem'
import BlogPostCard from './components/BlogPostCard'
import BlogPostListAll from './components/BlogPostListAll'
import CategoryItem from './components/CategoryItem'
-import FloatTocButton from './components/FloatTocButton'
+import FloatButtonCatalog from './components/FloatButtonCatalog'
import Footer from './components/Footer'
import JumpToTopButton from './components/JumpToTopButton'
import LogoBar from './components/LogoBar'
@@ -187,7 +187,7 @@ const LayoutBase = props => {
{/* 移动端悬浮目录按钮 */}
{showTocButton && !tocVisible && (
-
+
)}