mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-15 15:09:25 +00:00
移动段适配,加入深夜模式按钮
This commit is contained in:
@@ -6,18 +6,10 @@ import { useEffect } from 'react'
|
||||
* @returns {JSX.Element}
|
||||
* @constructor
|
||||
*/
|
||||
const BlogPostListEmpty = () => {
|
||||
const router = useRouter()
|
||||
useEffect(() => {
|
||||
setTimeout(() => {
|
||||
router.push('/').then(() => {
|
||||
console.log('空博客列表跳回首页')
|
||||
})
|
||||
}, 3000)
|
||||
})
|
||||
return <div className='w-full h-full min-h-screen flex justify-center mx-auto'>
|
||||
<div className='align-middle text-center my-auto'>
|
||||
<p className='text-gray-500 dark:text-gray-300'>没有文章了,3秒后返回首页</p>
|
||||
const BlogPostListEmpty = ({ currentSearch }) => {
|
||||
return <div className='min-h-screen flex justify-center mx-auto'>
|
||||
<div className='align-middle text-center my-auto'>
|
||||
<p className='text-gray-500 dark:text-gray-300'>没有找到文章 {(currentSearch && <div>{currentSearch}</div>)}</p>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -49,9 +49,9 @@ const BlogPostListScroll = ({ posts = [], tags, currentSearch, currentCategory,
|
||||
const targetRef = useRef(null)
|
||||
|
||||
if (!postsToShow || postsToShow.length === 0) {
|
||||
return <BlogPostListEmpty />
|
||||
return <BlogPostListEmpty currentSearch={currentSearch}/>
|
||||
} else {
|
||||
return <div id='post-list-wrapper' className='mt-28 md:mt-32 mx-2 md:mx-20' ref={targetRef}>
|
||||
return <div id='post-list-wrapper' className='mt-20 mx-2 md:mx-20' ref={targetRef}>
|
||||
|
||||
{currentCategory && (
|
||||
<div className='w-full p-1 bg-gray-100 dark:bg-gray-700'>
|
||||
|
||||
@@ -9,7 +9,7 @@ const DarkModeButton = () => {
|
||||
saveTheme(newTheme)
|
||||
changeTheme(newTheme)
|
||||
}
|
||||
return <div className='z-10 p-1 duration-200 mr-2 h-12 text-xl cursor-pointer dark:text-gray-300 '>
|
||||
return <div className='z-10 p-1 duration-200 h-12 text-xl cursor-pointer dark:text-gray-300 '>
|
||||
<i id='darkModeButton' className={'fa p-2.5 hover:scale-125 transform duration-200 ' + (userTheme === 'dark' ? 'fa-sun-o' : 'fa-moon-o')}
|
||||
onClick={handleChangeDarkMode} />
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import React, { useCallback, useEffect, useState } from 'react'
|
||||
import throttle from 'lodash.throttle'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
|
||||
/**
|
||||
@@ -33,15 +32,15 @@ const JumpToTopButton = ({ targetRef, showPercent = true }) => {
|
||||
}, [show])
|
||||
|
||||
return (
|
||||
<div id='jump-to-top' className='right-0 fixed flex bottom-24 mr-2.5 py-1 duration-500 z-20 opacity-75'>
|
||||
<div className='transform hover:scale-105 duration-200 '>
|
||||
<div id='jump-to-top' className='right-0 fixed flex bottom-24 mr-4 duration-500 z-20'>
|
||||
<div >
|
||||
<div
|
||||
onClick={() => window.scrollTo({ top: 0, behavior: 'smooth' })}
|
||||
style={{ boxShadow: 'rgba(41, 50, 60, 0.5) 0px 2px 16px', borderRadius: '28px' }}
|
||||
className={(show ? 'animate__fadeInUp' : 'animate__fadeOutUp') + ' bg-gray-700 px-2.5 py-2 cursor-pointer animate__animated animate__faster shadow-2xl'}>
|
||||
className={(show ? 'animate__fadeInUp' : 'animate__fadeOutUp') + ' bg-gray-700 px-1 py-1 cursor-pointer animate__animated animate__faster shadow-2xl'}>
|
||||
<div className='text-center'>
|
||||
<div className='w-10 text-xl text-gray-100' title={locale.POST.TOP} ><i className='fa fa-arrow-up'/> </div>
|
||||
{showPercent && (<div className='w-10 text-xs text-gray-100 dark:text-gray-200 text-center'> {percent}%</div>)}
|
||||
<div className='w-10 text-xl text-gray-100 transform hover:scale-125 duration-200' title={locale.POST.TOP} ><i className='fa fa-arrow-up'/> </div>
|
||||
{showPercent && (<div className='w-10 text-xs text-gray-100 dark:text-gray-200'>{percent} </div>)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -6,6 +6,7 @@ import LatestPosts from '@/components/LatestPosts'
|
||||
import PostsCategories from '@/components/PostsCategories'
|
||||
import Toc from '@/components/Toc'
|
||||
import SearchInput from '@/components/SearchInput'
|
||||
import DarkModeButton from '@/components/DarkModeButton'
|
||||
|
||||
/**
|
||||
* 侧边栏
|
||||
@@ -28,7 +29,7 @@ const SideBar = ({ tags, currentTag, post, posts, categories, currentCategory })
|
||||
}).slice(0, 5)
|
||||
}
|
||||
|
||||
return <aside id='sidebar' className='bg-white dark:bg-gray-800 w-72 z-10 dark:border-gray-500 border-gray-200 scroll-hidden h-full'>
|
||||
return <aside id='sidebar' className='pt-10 bg-white dark:bg-gray-800 w-72 z-10 dark:border-gray-500 border-gray-200 scroll-hidden h-full'>
|
||||
<section>
|
||||
<InfoCard />
|
||||
</section>
|
||||
|
||||
@@ -10,7 +10,7 @@ import Link from 'next/link'
|
||||
const TagsBar = ({ tags, currentTag }) => {
|
||||
if (!tags) return <></>
|
||||
return (
|
||||
<div id='tags-bar' className='fixed block xl:hidden top-16 duration-500 z-10 w-full border-b dark:border-gray-600'>
|
||||
<div id='tags-bar' className='fixed block lg:hidden top-16 duration-500 z-10 w-full border-b dark:border-gray-600'>
|
||||
<div className='bg-white dark:bg-gray-800 flex overflow-x-auto'>
|
||||
<div className='z-30 sticky left-0 flex'>
|
||||
<div className='px-2 bg-white dark:bg-gray-800'/>
|
||||
|
||||
@@ -10,13 +10,13 @@ import React from 'react'
|
||||
*/
|
||||
const TocDrawerButton = (props) => {
|
||||
return (
|
||||
<div id='jump-to-top' className='right-0 fixed flex bottom-40 mr-2.5 py-1 duration-500 z-20 opacity-70' onClick={props.onClick}>
|
||||
<div id='jump-to-top' className='right-0 fixed flex bottom-40 mr-4 duration-500 z-30' onClick={props.onClick}>
|
||||
<div className='transform hover:scale-105 duration-200 '>
|
||||
<div style={{ boxShadow: 'rgba(41, 50, 60, 0.5) 0px 2px 16px', borderRadius: '28px' }}
|
||||
className={'animate__fadeInUp bg-gray-700 px-2.5 py-2 cursor-pointer animate__animated animate__faster shadow-2xl'}>
|
||||
className={'animate__fadeInUp bg-gray-700 px-1 py-1 cursor-pointer animate__animated animate__faster shadow-2xl'}>
|
||||
<div className='text-center text-gray-100'>
|
||||
<div className='w-10 text-xl ' title='目录' ><i className='fa fa-book'/> </div>
|
||||
<div className='text-sm'>目录</div>
|
||||
<div className='w-10 text-xl' title='目录' ><i className='fa fa-book'/> </div>
|
||||
<div className='text-xs'>目录</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -28,7 +28,7 @@ const TopNav = ({ tags, currentTag, post, posts, currentSearch, categories, curr
|
||||
</div>
|
||||
|
||||
{/* 右侧功能 */}
|
||||
<div className='flex flex-nowrap space-x-1'>
|
||||
<div className='flex flex-nowrap space-x-1 ml-2'>
|
||||
<DarkModeButton />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -8,7 +8,24 @@ import Footer from '@/components/Footer'
|
||||
import SideBar from '@/components/SideBar'
|
||||
import JumpToTopButton from '@/components/JumpToTopButton'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import DarkModeButton from '@/components/DarkModeButton'
|
||||
|
||||
/**
|
||||
* 基础布局 采用左右两侧布局,移动端使用顶部导航栏
|
||||
* @param children
|
||||
* @param layout
|
||||
* @param fullWidth
|
||||
* @param tags
|
||||
* @param meta
|
||||
* @param post
|
||||
* @param totalPosts
|
||||
* @param currentSearch
|
||||
* @param currentCategory
|
||||
* @param categories
|
||||
* @param customMeta
|
||||
* @returns {JSX.Element}
|
||||
* @constructor
|
||||
*/
|
||||
const BaseLayout = ({
|
||||
children,
|
||||
layout,
|
||||
@@ -49,6 +66,7 @@ const BaseLayout = ({
|
||||
<div id='wrapper' className={[BLOG.font, theme].join(' ')}>
|
||||
<CommonHead meta={meta} />
|
||||
|
||||
{/* 顶部导航栏 */}
|
||||
<div className='block lg:hidden'>
|
||||
<TopNav tags={tags} post={post} posts={totalPosts} currentSearch={currentSearch} categories={categories}
|
||||
currentCategory={currentCategory} />
|
||||
@@ -56,13 +74,16 @@ const BaseLayout = ({
|
||||
|
||||
{/* Middle Wrapper */}
|
||||
<main className='flex dark:bg-black'>
|
||||
<div className='hidden lg:block z-10 pt-10'>
|
||||
<div className='hidden lg:block z-10'>
|
||||
<SideBar tags={tags} post={post} posts={totalPosts} categories={categories} currentCategory={currentCategory} />
|
||||
</div>
|
||||
<div className='flex flex-grow' ref={targetRef}>
|
||||
{children}
|
||||
</div>
|
||||
<JumpToTopButton targetRef={targetRef} showPercent={true} />
|
||||
<div className='fixed right-2 top-2 p-0.5 shadow-2xl bg-white border dark:border-gray-500 dark:bg-gray-700 rounded-full'>
|
||||
<DarkModeButton/>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<Footer />
|
||||
@@ -77,10 +98,10 @@ const hiddenNav = () => {
|
||||
if (document) {
|
||||
const nav = document.querySelector('#sticky-nav')
|
||||
// const sidebar = document.querySelector('#sidebar')
|
||||
// const tagsBar = document.querySelector('#tags-bar')
|
||||
const tagsBar = document.querySelector('#tags-bar')
|
||||
// const rightToc = document.querySelector('#right-toc')
|
||||
nav && nav.classList.replace('top-0', '-top-16')
|
||||
// tagsBar && tagsBar.classList.replace('top-16', 'top-0')
|
||||
tagsBar && tagsBar.classList.replace('top-16', 'top-0')
|
||||
// sidebar && sidebar.classList.replace('top-20', 'top-2')
|
||||
// rightToc && rightToc.classList.replace('top-16', 'top-0')
|
||||
}
|
||||
@@ -93,10 +114,10 @@ const showNav = () => {
|
||||
if (document) {
|
||||
const nav = document.querySelector('#sticky-nav')
|
||||
// const sidebar = document.querySelector('#sidebar')
|
||||
// const tagsBar = document.querySelector('#tags-bar')
|
||||
const tagsBar = document.querySelector('#tags-bar')
|
||||
// const rightToc = document.querySelector('#right-toc')
|
||||
nav && nav.classList.replace('-top-16', 'top-0')
|
||||
// tagsBar && tagsBar.classList.replace('top-0', 'top-16')
|
||||
tagsBar && tagsBar.classList.replace('top-0', 'top-16')
|
||||
// sidebar && sidebar.classList.replace('top-2', 'top-20')
|
||||
// rightToc && rightToc.classList.replace('top-0', 'top-16')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user