diff --git a/pages/article/[slug].js b/pages/article/[slug].js index e654ee64..a0f2bb55 100644 --- a/pages/article/[slug].js +++ b/pages/article/[slug].js @@ -5,7 +5,7 @@ import { useGlobal } from '@/lib/global' import * as ThemeMap from '@/themes' import React from 'react' import { idToUuid } from 'notion-utils' -import { useRouter } from 'next/router' +import Router from 'next/router' import { isBrowser } from '@/lib/utils' /** @@ -17,10 +17,10 @@ const Slug = props => { const { theme, changeLoadingState } = useGlobal() const ThemeComponents = ThemeMap[theme] const { post, siteInfo } = props + const router = Router.useRouter() if (!post) { changeLoadingState(true) - const router = useRouter() setTimeout(() => { if (isBrowser()) { const article = document.getElementById('container') @@ -48,9 +48,9 @@ const Slug = props => { }, [post]) /** - * 验证文章密码 - * @param {*} result - */ + * 验证文章密码 + * @param {*} result + */ const validPassword = result => { if (result) { setLock(false) @@ -69,6 +69,10 @@ const Slug = props => { tags: post?.tags } + Router.events.on('routeChangeComplete', () => { + window.scrollTo({ top: 0, behavior: 'smooth' }) + }) + return ( ) diff --git a/themes/hexo/components/MenuList.js b/themes/hexo/components/MenuList.js index 3f16a2ff..ea1f9c23 100644 --- a/themes/hexo/components/MenuList.js +++ b/themes/hexo/components/MenuList.js @@ -26,7 +26,7 @@ const MenuList = (props) => { if (link && link.show) { const selected = (router.pathname === link.to) || (router.asPath === link.to) return -