mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-27 15:10:00 +00:00
移除Preact框架、引入react-hook检查
This commit is contained in:
@@ -20,6 +20,17 @@ const Slug = props => {
|
||||
const { post, siteInfo } = props
|
||||
const router = Router.useRouter()
|
||||
|
||||
// 文章锁🔐
|
||||
const [lock, setLock] = React.useState(true)
|
||||
|
||||
React.useEffect(() => {
|
||||
if (post?.password && post?.password !== '') {
|
||||
setLock(true)
|
||||
} else {
|
||||
setLock(false)
|
||||
}
|
||||
}, [post])
|
||||
|
||||
if (!post) {
|
||||
changeLoadingState(true)
|
||||
setTimeout(() => {
|
||||
@@ -38,16 +49,6 @@ const Slug = props => {
|
||||
|
||||
changeLoadingState(false)
|
||||
|
||||
// 文章锁🔐
|
||||
const [lock, setLock] = React.useState(post?.password && post?.password !== '')
|
||||
React.useEffect(() => {
|
||||
if (post?.password && post?.password !== '') {
|
||||
setLock(true)
|
||||
} else {
|
||||
setLock(false)
|
||||
}
|
||||
}, [post])
|
||||
|
||||
/**
|
||||
* 验证文章密码
|
||||
* @param {*} result
|
||||
|
||||
@@ -5,8 +5,9 @@ import * as ThemeMap from '@/themes'
|
||||
|
||||
const Search = props => {
|
||||
const { posts, siteInfo } = props
|
||||
const router = useRouter()
|
||||
let filteredPosts
|
||||
const searchKey = getSearchKey()
|
||||
const searchKey = getSearchKey(router)
|
||||
// 静态过滤
|
||||
if (searchKey) {
|
||||
filteredPosts = posts.filter(post => {
|
||||
@@ -61,8 +62,7 @@ export async function getStaticProps() {
|
||||
}
|
||||
}
|
||||
|
||||
function getSearchKey() {
|
||||
const router = useRouter()
|
||||
function getSearchKey(router) {
|
||||
if (router.query && router.query.s) {
|
||||
return router.query.s
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user