mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-02 15:10:16 +00:00
Merge branch 'main' into release/4.0.0
This commit is contained in:
@@ -10,13 +10,12 @@ import NavPostItem from './NavPostItem'
|
|||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
const NavPostList = (props) => {
|
const NavPostList = (props) => {
|
||||||
const { filteredPosts } = props
|
const { filteredPostGroups } = props
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
let selectedSth = false
|
let selectedSth = false
|
||||||
|
|
||||||
// 处理是否选中
|
// 处理是否选中
|
||||||
filteredPosts?.map((group) => {
|
filteredPostGroups.map((group) => {
|
||||||
let groupSelected = false
|
let groupSelected = false
|
||||||
for (const post of group?.items) {
|
for (const post of group?.items) {
|
||||||
if (router.asPath.split('?')[0] === '/' + post.slug) {
|
if (router.asPath.split('?')[0] === '/' + post.slug) {
|
||||||
@@ -29,16 +28,16 @@ const NavPostList = (props) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// 如果都没有选中默认打开第一个
|
// 如果都没有选中默认打开第一个
|
||||||
if (!selectedSth && filteredPosts && filteredPosts.length > 0) {
|
if (!selectedSth && filteredPostGroups && filteredPostGroups.length > 0) {
|
||||||
filteredPosts[0].selected = true
|
filteredPostGroups[0].selected = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!filteredPosts || filteredPosts.length === 0) {
|
if (!filteredPostGroups || filteredPostGroups.length === 0) {
|
||||||
return <NavPostListEmpty />
|
return <NavPostListEmpty />
|
||||||
} else {
|
} else {
|
||||||
return <div id='posts-wrapper' className='w-full flex-grow'>
|
return <div id='posts-wrapper' className='w-full flex-grow'>
|
||||||
{/* 文章列表 */}
|
{/* 文章列表 */}
|
||||||
{filteredPosts?.map((group, index) => <NavPostItem key={index} group={group} onHeightChange={props.onHeightChange}/>)}
|
{filteredPostGroups?.map((group, index) => <NavPostItem key={index} group={group} onHeightChange={props.onHeightChange}/>)}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,16 +47,16 @@ const LayoutBase = (props) => {
|
|||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const [tocVisible, changeTocVisible] = useState(false)
|
const [tocVisible, changeTocVisible] = useState(false)
|
||||||
const [pageNavVisible, changePageNavVisible] = useState(false)
|
const [pageNavVisible, changePageNavVisible] = useState(false)
|
||||||
const [filteredPosts, setFilteredPosts] = useState(allNavPages)
|
const [filteredPostGroups, setFilteredPostGroups] = useState(allNavPages)
|
||||||
|
|
||||||
const showTocButton = post?.toc?.length > 1
|
const showTocButton = post?.toc?.length > 1
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setFilteredPosts(allNavPages)
|
setFilteredPostGroups(allNavPages)
|
||||||
}, [post])
|
}, [post])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ThemeGlobalGitbook.Provider value={{ tocVisible, changeTocVisible, filteredPosts, setFilteredPosts, allNavPages, pageNavVisible, changePageNavVisible }}>
|
<ThemeGlobalGitbook.Provider value={{ tocVisible, changeTocVisible, filteredPostGroups, setFilteredPostGroups, allNavPages, pageNavVisible, changePageNavVisible }}>
|
||||||
<CommonHead meta={meta} />
|
<CommonHead meta={meta} />
|
||||||
|
|
||||||
<div id='theme-gitbook' className='bg-white dark:bg-hexo-black-gray w-full h-full min-h-screen justify-center dark:text-gray-300'>
|
<div id='theme-gitbook' className='bg-white dark:bg-hexo-black-gray w-full h-full min-h-screen justify-center dark:text-gray-300'>
|
||||||
@@ -71,7 +71,7 @@ const LayoutBase = (props) => {
|
|||||||
{slotLeft}
|
{slotLeft}
|
||||||
<SearchInput className='my-3 rounded-md' />
|
<SearchInput className='my-3 rounded-md' />
|
||||||
{/* 所有文章列表 */}
|
{/* 所有文章列表 */}
|
||||||
<NavPostList filteredPosts={filteredPosts} />
|
<NavPostList filteredPostGroups={filteredPostGroups} />
|
||||||
|
|
||||||
<div className='mt-2'>
|
<div className='mt-2'>
|
||||||
<Footer {...props}/>
|
<Footer {...props}/>
|
||||||
@@ -143,7 +143,7 @@ const LayoutBase = (props) => {
|
|||||||
</div>}
|
</div>}
|
||||||
|
|
||||||
{/* 移动端导航抽屉 */}
|
{/* 移动端导航抽屉 */}
|
||||||
<PageNavDrawer {...props} filteredPosts={filteredPosts} />
|
<PageNavDrawer {...props} filteredPostGroups={filteredPostGroups} />
|
||||||
|
|
||||||
{/* 移动端底部导航栏 */}
|
{/* 移动端底部导航栏 */}
|
||||||
{/* <BottomMenuBar {...props} className='block md:hidden' /> */}
|
{/* <BottomMenuBar {...props} className='block md:hidden' /> */}
|
||||||
|
|||||||
Reference in New Issue
Block a user