封装加密

This commit is contained in:
tangly1024
2022-12-14 12:19:28 +08:00
parent afe4c679fa
commit ff24524aae
12 changed files with 28 additions and 61 deletions

View File

@@ -1,4 +1,3 @@
import { getPageTableOfContents } from 'notion-utils'
import LayoutBase from './LayoutBase'
import { ArticleLock } from './components/ArticleLock'
import NotionPage from '@/components/NotionPage'
@@ -12,15 +11,10 @@ export const LayoutSlug = props => {
return <LayoutBase {...props} />
}
if (!lock && post?.blockMap?.block) {
post.content = Object.keys(post.blockMap.block)
post.toc = getPageTableOfContents(post, post.blockMap)
}
return (
<LayoutBase {...props}>
{lock && <ArticleLock password={post.password} validPassword={validPassword} />}
{lock && <ArticleLock validPassword={validPassword} />}
{!lock && <div id="notion-article" className="px-2">

View File

@@ -8,14 +8,12 @@ import { useGlobal } from '@/lib/global'
* @returns
*/
export const ArticleLock = props => {
const { password, validPassword } = props
const { validPassword } = props
const { locale } = useGlobal()
const submitPassword = () => {
const p = document.getElementById('password')
if (p && p.value && p.value === password) {
validPassword(true)
} else {
if (!validPassword(p?.value)) {
const tips = document.getElementById('tips')
if (tips) {
tips.innerHTML = ''