fix: 修复 eslint 报错

This commit is contained in:
LooseLi
2025-05-26 18:11:45 +08:00
parent 1f691818f8
commit 3366dd4a6c
7 changed files with 108 additions and 103 deletions

View File

@@ -7,10 +7,12 @@ import Link from 'next/link'
* @returns
*/
export default function ArticleAround({ prev, next }) {
const { locale } = useGlobal()
if (!prev || !next) {
return <></>
}
const { locale } = useGlobal()
return (
<section className='text-gray-800 dark:text-gray-400 flex items-center justify-between gap-x-3 my-4'>
<Link

View File

@@ -256,26 +256,24 @@ const LayoutIndex = props => {
setHasRedirected(true) // 更新状态,防止多次执行
// 重定向到指定文章
router.push(index).then(() => {
setTimeout(() => {
const article = document.querySelector(
'#article-wrapper #notion-article'
)
if (!article) {
console.log(
'请检查您的Notion数据库中是否包含此slug页面 ',
index
)
await router.push(index)
// 显示错误信息
const containerInner = document.querySelector(
'#theme-gitbook #container-inner'
)
const newHTML = `<h1 class="text-3xl pt-12 dark:text-gray-300">配置有误</h1><blockquote class="notion-quote notion-block-ce76391f3f2842d386468ff1eb705b92"><div>请在您的notion中添加一个slug为${index}的文章</div></blockquote>`
containerInner?.insertAdjacentHTML('afterbegin', newHTML)
}
}, 2000)
})
// 使用setTimeout检查页面加载情况
setTimeout(() => {
const article = document.querySelector(
'#article-wrapper #notion-article'
)
if (!article) {
console.log('请检查您的Notion数据库中是否包含此slug页面 ', index)
// 显示错误信息
const containerInner = document.querySelector(
'#theme-gitbook #container-inner'
)
const newHTML = `<h1 class="text-3xl pt-12 dark:text-gray-300">配置有误</h1><blockquote class="notion-quote notion-block-ce76391f3f2842d386468ff1eb705b92"><div>请在您的notion中添加一个slug为${index}的文章</div></blockquote>`
containerInner?.insertAdjacentHTML('afterbegin', newHTML)
}
}, 2000)
}
}
@@ -320,21 +318,18 @@ const LayoutSlug = props => {
useEffect(() => {
// 404
if (!post) {
setTimeout(
() => {
if (isBrowser) {
const article = document.querySelector(
'#article-wrapper #notion-article'
)
if (!article) {
router.push('/404').then(() => {
console.warn('找不到页面', router.asPath)
})
}
setTimeout(() => {
if (isBrowser) {
const article = document.querySelector(
'#article-wrapper #notion-article'
)
if (!article) {
router.push('/404').then(() => {
console.warn('找不到页面', router.asPath)
})
}
},
waiting404
)
}
}, waiting404)
}
}, [post])
return (
@@ -451,16 +446,21 @@ const Layout404 = props => {
}, 3000)
}, [])
return <>
<div className='md:-mt-20 text-black w-full h-screen text-center justify-center content-center items-center flex flex-col'>
<div className='dark:text-gray-200'>
<h2 className='inline-block border-r-2 border-gray-600 mr-2 px-3 py-2 align-top'><i className='mr-2 fas fa-spinner animate-spin' />404</h2>
<div className='inline-block text-left h-32 leading-10 items-center'>
<h2 className='m-0 p-0'>{locale.NAV.PAGE_NOT_FOUND_REDIRECT}</h2>
</div>
</div>
return (
<>
<div className='md:-mt-20 text-black w-full h-screen text-center justify-center content-center items-center flex flex-col'>
<div className='dark:text-gray-200'>
<h2 className='inline-block border-r-2 border-gray-600 mr-2 px-3 py-2 align-top'>
<i className='mr-2 fas fa-spinner animate-spin' />
404
</h2>
<div className='inline-block text-left h-32 leading-10 items-center'>
<h2 className='m-0 p-0'>{locale.NAV.PAGE_NOT_FOUND_REDIRECT}</h2>
</div>
</div>
</div>
</>
)
}
/**
@@ -609,18 +609,17 @@ const LayoutDashboard = props => {
}
export {
Layout404,
LayoutArchive,
LayoutBase,
LayoutCategoryIndex,
LayoutDashboard,
LayoutIndex,
LayoutPostList,
LayoutSearch,
LayoutSignIn,
LayoutSignUp,
LayoutSlug,
LayoutTagIndex,
CONFIG as THEME_CONFIG
Layout404,
LayoutArchive,
LayoutBase,
LayoutCategoryIndex,
LayoutDashboard,
LayoutIndex,
LayoutPostList,
LayoutSearch,
LayoutSignIn,
LayoutSignUp,
LayoutSlug,
LayoutTagIndex,
CONFIG as THEME_CONFIG
}

View File

@@ -12,22 +12,24 @@ export const ArticleFooter = props => {
const router = useRouter()
const { locale } = useGlobal()
return <div className="flex justify-between font-medium text-gray-500 dark:text-gray-400">
<a>
<button
onClick={() => router.push('/')}
className="mt-2 cursor-pointer hover:text-black dark:hover:text-gray-100"
>
{locale.POST.BACK}
</button>
</a>
<a>
<button
onClick={() => window.scrollTo({ top: 0, behavior: 'smooth' })}
className="mt-2 cursor-pointer hover:text-black dark:hover:text-gray-100"
>
{locale.POST.TOP}
</button>
</a>
</div>
return (
<div className='flex justify-between font-medium text-gray-500 dark:text-gray-400'>
<a>
<button
onClick={() => {
void router.push('/')
}}
className='mt-2 cursor-pointer hover:text-black dark:hover:text-gray-100'>
{locale.POST.BACK}
</button>
</a>
<a>
<button
onClick={() => window.scrollTo({ top: 0, behavior: 'smooth' })}
className='mt-2 cursor-pointer hover:text-black dark:hover:text-gray-100'>
{locale.POST.TOP}
</button>
</a>
</div>
)
}

View File

@@ -13,22 +13,24 @@ export const ArticleFooter = props => {
const router = useRouter()
const { locale } = useGlobal()
return <div className="flex justify-between font-medium text-gray-500 dark:text-gray-400">
<a>
<button
onClick={() => router.push(siteConfig('path') || '/')}
className="mt-2 cursor-pointer hover:text-black dark:hover:text-gray-100"
>
{locale.POST.BACK}
</button>
</a>
<a>
<button
onClick={() => window.scrollTo({ top: 0, behavior: 'smooth' })}
className="mt-2 cursor-pointer hover:text-black dark:hover:text-gray-100"
>
{locale.POST.TOP}
</button>
</a>
</div>
return (
<div className='flex justify-between font-medium text-gray-500 dark:text-gray-400'>
<a>
<button
onClick={() => {
void router.push(siteConfig('path') || '/')
}}
className='mt-2 cursor-pointer hover:text-black dark:hover:text-gray-100'>
{locale.POST.BACK}
</button>
</a>
<a>
<button
onClick={() => window.scrollTo({ top: 0, behavior: 'smooth' })}
className='mt-2 cursor-pointer hover:text-black dark:hover:text-gray-100'>
{locale.POST.TOP}
</button>
</a>
</div>
)
}

View File

@@ -51,10 +51,6 @@ export const MenuList = props => {
links = customMenu
}
if (!links || links.length === 0) {
return null
}
const toggleMenu = () => {
setShowMenu(!showMenu) // 切换菜单状态
}
@@ -63,6 +59,10 @@ export const MenuList = props => {
setShowMenu(false)
}, [router])
if (!links || links.length === 0) {
return null
}
return (
<div>
{/* 移动端菜单切换按钮 */}

View File

@@ -51,10 +51,6 @@ export const MenuList = props => {
links = customMenu
}
if (!links || links.length === 0) {
return null
}
const toggleMenu = () => {
setShowMenu(!showMenu) // 切换菜单状态
}
@@ -63,6 +59,10 @@ export const MenuList = props => {
setShowMenu(false)
}, [router])
if (!links || links.length === 0) {
return null
}
return (
<div>
{/* 移动端菜单切换按钮 */}

View File

@@ -79,17 +79,17 @@ export const getBaseLayoutByTheme = theme => {
*/
export const DynamicLayout = props => {
const { theme, layoutName } = props
const SelectedLayout = getLayoutByTheme({ layoutName, theme })
const SelectedLayout = useLayoutByTheme({ layoutName, theme })
return <SelectedLayout {...props} />
}
/**
* 加载主题文件
* @param {*} router
* @param {*} layoutName
* @param {*} theme
* @returns
*/
export const getLayoutByTheme = ({ layoutName, theme }) => {
export const useLayoutByTheme = ({ layoutName, theme }) => {
// const layoutName = getLayoutNameByPath(router.pathname, router.asPath)
const LayoutComponents =
ThemeComponents[layoutName] || ThemeComponents.LayoutSlug