mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
article-slug滚动至顶
This commit is contained in:
@@ -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 (
|
||||
<ThemeComponents.LayoutSlug {...props} showArticleInfo={true} meta={meta} />
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user