diff --git a/themes/hexo/Layout404.js b/themes/hexo/Layout404.js index 6140c8fb..2bc61804 100644 --- a/themes/hexo/Layout404.js +++ b/themes/hexo/Layout404.js @@ -1,6 +1,22 @@ import LayoutBase from './LayoutBase' +import { useRouter } from 'next/router' +import { useEffect } from 'react' export const Layout404 = props => { + const router = useRouter() + useEffect(() => { + // 延时3秒如果加载失败就返回首页 + setTimeout(() => { + if (window) { + const article = document.getElementById('container') + if (!article) { + router.push('/').then(() => { + console.log('找不到页面', router.asPath) + }) + } + } + }, 3000) + }) return (