From fa4abada585915a4a9c78212ab73723b2cd65f45 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 26 Apr 2022 10:43:06 +0800 Subject: [PATCH 1/5] =?UTF-8?q?firefox=20=E9=9A=90=E8=97=8F=E6=BB=9A?= =?UTF-8?q?=E5=8A=A8=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- styles/globals.css | 1 + 1 file changed, 1 insertion(+) diff --git a/styles/globals.css b/styles/globals.css index dd5d8d73..04cd6aad 100644 --- a/styles/globals.css +++ b/styles/globals.css @@ -113,6 +113,7 @@ nav { .scroll-hidden{ -ms-overflow-style: none; overflow: -moz-scrollbars-none; + scrollbar-width: none; /* firefox */ } .scroll-hidden::-webkit-scrollbar { width: 0 !important } From 17c34d78f54e16ba45dfb4125054af4dfd7516cf Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 26 Apr 2022 10:43:35 +0800 Subject: [PATCH 2/5] =?UTF-8?q?404=E9=A1=B5=E9=9D=A2=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/hexo/Layout404.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 (
From 2fb0c679d164ba95b7d289a78922e3826a53456a Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 26 Apr 2022 10:44:01 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=BB=9A=E5=8A=A8=E6=9D=A1=E9=9A=90?= =?UTF-8?q?=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/next/components/StickyBar.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/themes/next/components/StickyBar.js b/themes/next/components/StickyBar.js index 281d7477..fdcba64d 100644 --- a/themes/next/components/StickyBar.js +++ b/themes/next/components/StickyBar.js @@ -39,10 +39,10 @@ const StickyBar = ({ children }) => { return ( diff --git a/themes/next/components/Header.js b/themes/next/components/Header.js index 2b63ee72..37eb5e50 100644 --- a/themes/next/components/Header.js +++ b/themes/next/components/Header.js @@ -27,7 +27,7 @@ export default function Header(props) { }) ) } - }) + }, []) const { isDarkMode } = useGlobal() const autoScrollEnd = () => { @@ -90,7 +90,7 @@ export default function Header(props) { window.removeEventListener('scroll', scrollTrigger) window.removeEventListener('resize', updateHeaderHeight) } - }) + }, []) return (
{ if (window) { initLive2DWife() } - }) + }, []) return <> - + } -function initLive2DWife () { +function initLive2DWife() { // 注意:live2d_path 参数应使用绝对路径 const live2dPath = 'https://cdn.jsdelivr.net/gh/stevenjoezhang/live2d-widget@latest/' // const live2d_path = "/live2d-widget/"; diff --git a/themes/next/components/SideBarDrawer.js b/themes/next/components/SideBarDrawer.js index 9bc04d48..8a22505d 100644 --- a/themes/next/components/SideBarDrawer.js +++ b/themes/next/components/SideBarDrawer.js @@ -18,7 +18,7 @@ const SideBarDrawer = ({ post, cRef, tags, slot, categories, currentCategory }) useEffect(() => { const sideBarWrapperElement = document.getElementById('sidebar-wrapper') sideBarWrapperElement?.classList?.remove('hidden') - }) + }, []) const router = useRouter() useEffect(() => { @@ -52,7 +52,7 @@ const SideBarDrawer = ({ post, cRef, tags, slot, categories, currentCategory })
{/* 背景蒙版 */} - } /** * 更新字数统计和阅读时间 */ -function countWords () { +function countWords() { if (window) { const articleElement = document.getElementById('notion-article') if (articleElement) { @@ -33,13 +33,13 @@ function countWords () { } // 去除html标签 -function deleteHtmlTag (str) { +function deleteHtmlTag(str) { str = str.replace(/<[^>]+>|&[^>]+;/g, '').trim()// 去掉所有的html标签和 之类的特殊符合 return str } // 用word方式计算正文字数 -function fnGetCpmisWords (str) { +function fnGetCpmisWords(str) { let sLen = 0 try { // eslint-disable-next-line no-irregular-whitespace From 61682d437dceeeb50fa5041782c29760535a6233 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 26 Apr 2022 10:53:47 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E5=88=B7=E6=96=B0=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=AF=BC=E8=87=B4Code=E9=87=8D=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/NotionPage.js | 30 ++++++++---------------------- themes/fukasawa/LayoutSlug.js | 12 +++--------- 2 files changed, 11 insertions(+), 31 deletions(-) diff --git a/components/NotionPage.js b/components/NotionPage.js index 0930eef4..94e33e3f 100644 --- a/components/NotionPage.js +++ b/components/NotionPage.js @@ -1,12 +1,3 @@ - -import 'prismjs' -import 'prismjs/components/prism-bash' -import 'prismjs/components/prism-javascript' -import 'prismjs/components/prism-markup' -import 'prismjs/components/prism-python' -import 'prismjs/components/prism-typescript' -import 'prismjs/components/prism-java' - import { NotionRenderer } from 'react-notion-x' import mediumZoom from 'medium-zoom' import { useEffect, useRef } from 'react' @@ -14,27 +5,22 @@ import dynamic from 'next/dynamic' import { useRouter } from 'next/router' const Code = dynamic(() => - import('react-notion-x/build/third-party/code').then((m) => m.Code) + import('react-notion-x/build/third-party/code').then((m) => m.Code), { ssr: false } ) const Collection = dynamic(() => - import('react-notion-x/build/third-party/collection').then( - (m) => m.Collection - ) + import('react-notion-x/build/third-party/collection').then((m) => m.Collection), { ssr: false } ) + const Equation = dynamic(() => - import('react-notion-x/build/third-party/equation').then((m) => m.Equation) + import('react-notion-x/build/third-party/equation').then((m) => m.Equation), { ssr: false } ) + const Pdf = dynamic( - () => import('react-notion-x/build/third-party/pdf').then((m) => m.Pdf), - { - ssr: false - } + () => import('react-notion-x/build/third-party/pdf').then((m) => m.Pdf), { ssr: false } ) + const Modal = dynamic( - () => import('react-notion-x/build/third-party/modal').then((m) => m.Modal), - { - ssr: false - } + () => import('react-notion-x/build/third-party/modal').then((m) => m.Modal), { ssr: false } ) const NotionPage = ({ post }) => { if (!post || !post.blockMap) { diff --git a/themes/fukasawa/LayoutSlug.js b/themes/fukasawa/LayoutSlug.js index 08c128b4..30265a6c 100644 --- a/themes/fukasawa/LayoutSlug.js +++ b/themes/fukasawa/LayoutSlug.js @@ -1,10 +1,4 @@ import { getPageTableOfContents } from 'notion-utils' -import 'prismjs' -import 'prismjs/components/prism-bash' -import 'prismjs/components/prism-javascript' -import 'prismjs/components/prism-markup' -import 'prismjs/components/prism-python' -import 'prismjs/components/prism-typescript' import ArticleDetail from './components/ArticleDetail' import LayoutBase from './LayoutBase' import { ArticleLock } from './components/ArticleLock' @@ -18,8 +12,8 @@ export const LayoutSlug = (props) => { return ( - {!lock && } - {lock && } - + {!lock && } + {lock && } +
) }