diff --git a/themes/empty/LayoutSlug.js b/themes/empty/LayoutSlug.js
index d2808e51..7ff9b624 100644
--- a/themes/empty/LayoutSlug.js
+++ b/themes/empty/LayoutSlug.js
@@ -14,7 +14,7 @@ import {
NotionRenderer
} from 'react-notion-x'
import LayoutBase from './LayoutBase'
-import { useState, useRef, useEffect } from 'react'
+import { useRef, useEffect } from 'react'
import { ArticleLock } from './components/ArticleLock'
import mediumZoom from 'medium-zoom'
@@ -23,21 +23,13 @@ const mapPageUrl = id => {
}
export const LayoutSlug = props => {
- const { post } = props
+ const { post, lock, validPassword } = props
const meta = {
title: `${post.title} | ${BLOG.TITLE}`,
description: post.summary,
type: 'article',
tags: post.tags
}
- // 文章加锁
- const articleLock = post.password && post.password !== ''
- const [lock, setLock] = useState(articleLock)
- const validPassword = result => {
- if (result) {
- setLock(false)
- }
- }
if (!lock && post?.blockMap?.block) {
post.content = Object.keys(post.blockMap.block)
diff --git a/themes/fukasawa/LayoutSlug.js b/themes/fukasawa/LayoutSlug.js
index 90e53ecf..214f71c1 100644
--- a/themes/fukasawa/LayoutSlug.js
+++ b/themes/fukasawa/LayoutSlug.js
@@ -8,11 +8,10 @@ import 'prismjs/components/prism-python'
import 'prismjs/components/prism-typescript'
import ArticleDetail from './components/ArticleDetail'
import LayoutBase from './LayoutBase'
-import { useState } from 'react'
import { ArticleLock } from './components/ArticleLock'
export const LayoutSlug = (props) => {
- const { post } = props
+ const { post, lock, validPassword } = props
const meta = {
title: `${post.title} | ${BLOG.TITLE}`,
description: post.summary,
@@ -20,16 +19,7 @@ export const LayoutSlug = (props) => {
tags: post.tags
}
- // 文章加锁
- const articleLock = post.password && post.password !== ''
- const [lock, setLock] = useState(articleLock)
- const validPassword = result => {
- if (result) {
- setLock(false)
- }
- }
-
- if (post?.blockMap?.block) {
+ if (!lock && post?.blockMap?.block) {
post.content = Object.keys(post.blockMap.block)
post.toc = getPageTableOfContents(post, post.blockMap)
}
diff --git a/themes/hexo/LayoutSlug.js b/themes/hexo/LayoutSlug.js
index 8628e521..2103a3d3 100644
--- a/themes/hexo/LayoutSlug.js
+++ b/themes/hexo/LayoutSlug.js
@@ -7,7 +7,7 @@ import 'prismjs/components/prism-javascript'
import 'prismjs/components/prism-markup'
import 'prismjs/components/prism-python'
import 'prismjs/components/prism-typescript'
-import { useRef, useState } from 'react'
+import { useRef } from 'react'
import ArticleDetail from './components/ArticleDetail'
import { ArticleLock } from './components/ArticleLock'
import HeaderArticle from './components/HeaderArticle'
@@ -17,7 +17,7 @@ import TocDrawerButton from './components/TocDrawerButton'
import LayoutBase from './LayoutBase'
export const LayoutSlug = props => {
- const { post } = props
+ const { post, lock, validPassword } = props
const meta = {
title: `${post.title} | ${BLOG.TITLE}`,
description: post.summary,
@@ -25,15 +25,6 @@ export const LayoutSlug = props => {
tags: post.tags
}
- // 文章加锁
- const articleLock = post.password && post.password !== ''
- const [lock, setLock] = useState(articleLock)
- const validPassword = result => {
- if (result) {
- setLock(false)
- }
- }
-
if (!lock && post?.blockMap?.block) {
post.content = Object.keys(post.blockMap.block)
post.toc = getPageTableOfContents(post, post.blockMap)
diff --git a/themes/hexo/components/InfoCard.js b/themes/hexo/components/InfoCard.js
index 7154814b..be02013e 100644
--- a/themes/hexo/components/InfoCard.js
+++ b/themes/hexo/components/InfoCard.js
@@ -23,7 +23,8 @@ export function InfoCard (props) {
className='rounded-full'
/>
diff --git a/themes/hexo/components/SideRight.js b/themes/hexo/components/SideRight.js
index 5114c1aa..a9c4a4ed 100644
--- a/themes/hexo/components/SideRight.js
+++ b/themes/hexo/components/SideRight.js
@@ -33,7 +33,7 @@ export default function SideRight (props) {