主题,加密

This commit is contained in:
tangly1024
2022-12-24 19:08:10 +08:00
parent e9fc7b9ea3
commit ef4daf4cf6
8 changed files with 16 additions and 10 deletions

View File

@@ -3,7 +3,7 @@ import { NotionAPI } from 'notion-client'
import BLOG from '@/blog.config'
import formatDate from '../formatDate'
import { defaultMapImageUrl } from 'react-notion-x'
import md5 from 'js-md5'
import { createHash } from 'crypto'
export default async function getPageProperties(id, block, schema, authToken, tagOptions, siteInfo) {
const rawProperties = Object.entries(block?.[id]?.value?.properties || [])
@@ -90,7 +90,11 @@ export default async function getPageProperties(id, block, schema, authToken, ta
properties.pageIcon = getImageUrl(block[id].value?.format?.page_icon, block[id].value) ?? ''
properties.page_cover = getImageUrl(block[id].value?.format?.page_cover, block[id].value) ?? siteInfo?.pageCover
properties.content = value.content ?? []
properties.password = properties.password ? md5(properties.slug + properties.password) : ''
properties.password = properties.password
? createHash('md5')
.update(properties.slug + properties.password)
.digest('hex').trim().toLowerCase()
: ''
properties.tagItems = properties?.tags?.map(tag => {
return { name: tag, color: tagOptions?.find(t => t.value === tag)?.color || 'gray' }
}) || []

View File

@@ -30,7 +30,6 @@
"eslint-plugin-react-hooks": "^4.6.0",
"feed": "^4.2.2",
"gitalk": "^1.7.2",
"js-md5": "^0.7.3",
"localStorage": "^1.0.4",
"lodash.throttle": "^4.1.1",
"mark.js": "^8.11.1",

View File

@@ -8,8 +8,8 @@ import { idToUuid } from 'notion-utils'
import Router from 'next/router'
import { isBrowser } from '@/lib/utils'
import { getNotion } from '@/lib/notion/getNotion'
import md5 from 'js-md5'
import { getPageTableOfContents } from '@/lib/notion/getPageTableOfContents'
import { createHash } from 'crypto'
/**
* 根据notion的slug访问页面
@@ -59,7 +59,10 @@ const Slug = props => {
* @param {*} result
*/
const validPassword = passInput => {
if (passInput && md5(post.slug + passInput) === post.password) {
const encrypt = createHash('md5')
.update(post.slug + passInput)
.digest('hex').trim().toLowerCase()
if (passInput && encrypt === post.password) {
setLock(false)
return true
}

View File

@@ -25,7 +25,7 @@ export const ArticleLock = props => {
return <div id='container' className='w-full flex justify-center items-center h-96 font-sans'>
<div className='text-center space-y-3'>
<div className='font-bold'>{locale.COMMON.ARTICLE_LOCK_TIPS}</div>
<div className='flex'>
<div className='flex mx-4'>
<input id="password" type='password' className='w-full text-sm pl-5 rounded-l transition font-light leading-10 text-black dark:bg-gray-500 bg-gray-50'></input>
<div onClick={submitPassword} className="px-3 whitespace-nowrap cursor-pointer items-center justify-center py-2 rounded-r duration-300 bg-gray-300" >
<i className={'duration-200 cursor-pointer fas fa-key dark:text-black'} >&nbsp;{locale.COMMON.SUBMIT}</i>

View File

@@ -27,7 +27,7 @@ export const ArticleLock = props => {
<div className="w-full flex justify-center items-center h-96 font-sans">
<div className="text-center space-y-3">
<div className='font-bold'>{locale.COMMON.ARTICLE_LOCK_TIPS}</div>
<div className="flex">
<div className="flex mx-4">
<input
id="password" type='password'
className="w-full text-sm pl-5 rounded-l transition focus:shadow-lg dark:text-gray-300 font-light leading-10 text-black bg-gray-100 dark:bg-gray-500"

View File

@@ -24,7 +24,7 @@ export const ArticleLock = props => {
return <div id='container' className='w-full flex justify-center items-center h-96 '>
<div className='text-center space-y-3'>
<div className='font-bold'>{locale.COMMON.ARTICLE_LOCK_TIPS}</div>
<div className='flex'>
<div className='flex mx-4'>
<input id="password" type='password' className='w-full text-sm pl-5 rounded-l transition focus:shadow-lg dark:text-gray-300 font-light leading-10 text-black bg-gray-100 dark:bg-gray-500'></input>
<div onClick={submitPassword} className="px-3 whitespace-nowrap cursor-pointer items-center justify-center py-2 bg-indigo-500 hover:bg-indigo-400 text-white rounded-r duration-300" >
<i className={'duration-200 cursor-pointer fas fa-key'} >&nbsp;{locale.COMMON.SUBMIT}</i>

View File

@@ -25,7 +25,7 @@ export const ArticleLock = props => {
return <div id='container' className='w-full flex justify-center items-center h-96 font-sans'>
<div className='text-center space-y-3'>
<div className='font-bold'>{locale.COMMON.ARTICLE_LOCK_TIPS}</div>
<div className='flex'>
<div className='flex mx-4'>
<input id="password" type='password' className='w-full text-sm pl-5 rounded-l transition focus:shadow-lg dark:text-gray-300 font-light leading-10 text-black bg-gray-100 dark:bg-gray-500'></input>
<div onClick={submitPassword} className="px-3 whitespace-nowrap cursor-pointer items-center justify-center py-2 bg-green-500 hover:bg-green-400 text-white rounded-r duration-300" >
<i className={'duration-200 cursor-pointer fas fa-key'} >&nbsp;{locale.COMMON.SUBMIT}</i>

View File

@@ -27,7 +27,7 @@ export const ArticleLock = props => {
<div className="w-full flex justify-center items-center h-96 font-sans">
<div className="text-center space-y-3">
<div className='font-bold'>{locale.COMMON.ARTICLE_LOCK_TIPS}</div>
<div className="flex">
<div className="flex mx-4">
<input
id="password" type='password'
className="w-full text-sm pl-5 transition focus:shadow-lg dark:text-gray-300 font-light leading-10 text-black bg-gray-100 dark:bg-gray-500"