From 04d380966cf8a6fb55e54f80f0df544678791768 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Tue, 13 Jun 2023 17:22:28 +0800 Subject: [PATCH 1/2] password auto focus --- components/NotionPage.js | 8 +++++++- themes/example/components/ArticleLock.js | 9 ++++++++- themes/fukasawa/components/ArticleLock.js | 8 ++++++++ themes/hexo/components/ArticleLock.js | 7 +++++++ themes/matery/components/ArticleLock.js | 9 ++++++++- themes/medium/components/ArticleLock.js | 8 ++++++++ themes/next/components/ArticleLock.js | 8 ++++++++ themes/nobelium/components/ArticleLock.js | 10 +++++++++- themes/simple/components/ArticleLock.js | 9 ++++++++- 9 files changed, 71 insertions(+), 5 deletions(-) diff --git a/components/NotionPage.js b/components/NotionPage.js index 63d57861..862af760 100644 --- a/components/NotionPage.js +++ b/components/NotionPage.js @@ -2,12 +2,18 @@ import { NotionRenderer } from 'react-notion-x' import dynamic from 'next/dynamic' // import mediumZoom from '@fisch0920/medium-zoom' import React, { useEffect } from 'react' -import { Code } from 'react-notion-x/build/third-party/code' +// import { Code } from 'react-notion-x/build/third-party/code' import TweetEmbed from 'react-tweet-embed' import 'katex/dist/katex.min.css' import { mapImgUrl } from '@/lib/notion/mapImage' +const Code = dynamic(() => + import('react-notion-x/build/third-party/code').then(async (m) => { + return m.Code + }), { ssr: false } +) + const Equation = dynamic(() => import('@/components/Equation').then(async (m) => { // 化学方程式 diff --git a/themes/example/components/ArticleLock.js b/themes/example/components/ArticleLock.js index de3569b0..4957946d 100644 --- a/themes/example/components/ArticleLock.js +++ b/themes/example/components/ArticleLock.js @@ -1,4 +1,5 @@ import { useGlobal } from '@/lib/global' +import { useEffect, useRef } from 'react' /** * 加密文章校验组件 @@ -21,6 +22,11 @@ export const ArticleLock = props => { } } } + const passwordInputRef = useRef(null) + useEffect(() => { + // 选中密码输入框并将其聚焦 + passwordInputRef.current.focus() + }, []) return
@@ -32,7 +38,8 @@ export const ArticleLock = props => { submitPassword() } }} - className='outline-none w-full text-sm pl-5 rounded-l transition font-light leading-10 text-black dark:bg-gray-500 bg-gray-50' + ref={passwordInputRef} // 绑定ref到passwordInputRef变量 + className='outline-none w-full text-sm pl-5 rounded-l transition focus:shadow-lg font-light leading-10 text-black dark:bg-gray-500 bg-gray-50' >
 {locale.COMMON.SUBMIT} diff --git a/themes/fukasawa/components/ArticleLock.js b/themes/fukasawa/components/ArticleLock.js index 45f50dfe..293c308d 100644 --- a/themes/fukasawa/components/ArticleLock.js +++ b/themes/fukasawa/components/ArticleLock.js @@ -1,4 +1,5 @@ import { useGlobal } from '@/lib/global' +import { useEffect, useRef } from 'react' /** * 加密文章校验组件 @@ -22,6 +23,12 @@ export const ArticleLock = props => { } } + const passwordInputRef = useRef(null) + useEffect(() => { + // 选中密码输入框并将其聚焦 + passwordInputRef.current.focus() + }, []) + return (
@@ -35,6 +42,7 @@ export const ArticleLock = props => { submitPassword() } }} + ref={passwordInputRef} // 绑定ref到passwordInputRef变量 className="outline-none w-full text-sm pl-5 rounded-l transition focus:shadow-lg font-light leading-10 bg-gray-100 dark:bg-gray-500" >
{ } } } + const passwordInputRef = useRef(null) + useEffect(() => { + // 选中密码输入框并将其聚焦 + passwordInputRef.current.focus() + }, []) return
@@ -31,6 +37,7 @@ export const ArticleLock = props => { submitPassword() } }} + ref={passwordInputRef} // 绑定ref到passwordInputRef变量 className='outline-none w-full text-sm pl-5 rounded-l transition focus:shadow-lg font-light leading-10 bg-gray-100 dark:bg-gray-500'>
diff --git a/themes/matery/components/ArticleLock.js b/themes/matery/components/ArticleLock.js index 6834eb72..88de8ba6 100644 --- a/themes/matery/components/ArticleLock.js +++ b/themes/matery/components/ArticleLock.js @@ -1,4 +1,5 @@ import { useGlobal } from '@/lib/global' +import { useEffect, useRef } from 'react' /** * 加密文章校验组件 @@ -21,6 +22,12 @@ export const ArticleLock = props => { } } + const passwordInputRef = useRef(null) + useEffect(() => { + // 选中密码输入框并将其聚焦 + passwordInputRef.current.focus() + }, []) + return
{locale.COMMON.ARTICLE_LOCK_TIPS}
@@ -31,8 +38,8 @@ export const ArticleLock = props => { submitPassword() } }} + ref={passwordInputRef} // 绑定ref到passwordInputRef变量 className='outline-none w-full text-sm pl-5 rounded-l transition focus:shadow-lg font-light leading-10 bg-gray-100 dark:bg-gray-500'> -
 {locale.COMMON.SUBMIT} diff --git a/themes/medium/components/ArticleLock.js b/themes/medium/components/ArticleLock.js index 2798f97a..4ba5a3b9 100644 --- a/themes/medium/components/ArticleLock.js +++ b/themes/medium/components/ArticleLock.js @@ -1,4 +1,5 @@ import { useGlobal } from '@/lib/global' +import { useEffect, useRef } from 'react' /** * 加密文章校验组件 @@ -22,6 +23,12 @@ export const ArticleLock = props => { } } + const passwordInputRef = useRef(null) + useEffect(() => { + // 选中密码输入框并将其聚焦 + passwordInputRef.current.focus() + }, []) + return
{locale.COMMON.ARTICLE_LOCK_TIPS}
@@ -32,6 +39,7 @@ export const ArticleLock = props => { submitPassword() } }} + ref={passwordInputRef} // 绑定ref到passwordInputRef变量 className='outline-none 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'>
diff --git a/themes/next/components/ArticleLock.js b/themes/next/components/ArticleLock.js index ec6aae36..d49f1e50 100644 --- a/themes/next/components/ArticleLock.js +++ b/themes/next/components/ArticleLock.js @@ -1,4 +1,5 @@ import { useGlobal } from '@/lib/global' +import { useEffect, useRef } from 'react' /** * 加密文章校验组件 @@ -22,6 +23,12 @@ export const ArticleLock = props => { } } + const passwordInputRef = useRef(null) + useEffect(() => { + // 选中密码输入框并将其聚焦 + passwordInputRef.current.focus() + }, []) + return (
@@ -35,6 +42,7 @@ export const ArticleLock = props => { submitPassword() } }} + ref={passwordInputRef} // 绑定ref到passwordInputRef变量 className="outline-none w-full text-sm pl-5 transition focus:shadow-lg font-light leading-10 bg-gray-100 dark:bg-gray-500" >
{ } } + const passwordInputRef = useRef(null) + useEffect(() => { + // 选中密码输入框并将其聚焦 + passwordInputRef.current.focus() + }, []) + return
{locale.COMMON.ARTICLE_LOCK_TIPS}
@@ -32,7 +39,8 @@ export const ArticleLock = props => { submitPassword() } }} - className='outline-none w-full text-sm pl-5 rounded-l transition font-light leading-10 text-black dark:bg-gray-500 bg-gray-50' + ref={passwordInputRef} // 绑定ref到passwordInputRef变量 + className='outline-none w-full text-sm pl-5 rounded-l transition focus:shadow-lg font-light leading-10 text-black dark:bg-gray-500 bg-gray-50' >
 {locale.COMMON.SUBMIT} diff --git a/themes/simple/components/ArticleLock.js b/themes/simple/components/ArticleLock.js index de3569b0..4957946d 100644 --- a/themes/simple/components/ArticleLock.js +++ b/themes/simple/components/ArticleLock.js @@ -1,4 +1,5 @@ import { useGlobal } from '@/lib/global' +import { useEffect, useRef } from 'react' /** * 加密文章校验组件 @@ -21,6 +22,11 @@ export const ArticleLock = props => { } } } + const passwordInputRef = useRef(null) + useEffect(() => { + // 选中密码输入框并将其聚焦 + passwordInputRef.current.focus() + }, []) return
@@ -32,7 +38,8 @@ export const ArticleLock = props => { submitPassword() } }} - className='outline-none w-full text-sm pl-5 rounded-l transition font-light leading-10 text-black dark:bg-gray-500 bg-gray-50' + ref={passwordInputRef} // 绑定ref到passwordInputRef变量 + className='outline-none w-full text-sm pl-5 rounded-l transition focus:shadow-lg font-light leading-10 text-black dark:bg-gray-500 bg-gray-50' >
 {locale.COMMON.SUBMIT} From 2a3fcf471d5676b89ecf926ceaaa56aa76613d2e Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Tue, 13 Jun 2023 17:24:14 +0800 Subject: [PATCH 2/2] v3.15.1 --- .env.local | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.env.local b/.env.local index 11f8351f..ac4adac6 100644 --- a/.env.local +++ b/.env.local @@ -1,2 +1,2 @@ # 环境变量 @see https://www.nextjs.cn/docs/basic-features/environment-variables -NEXT_PUBLIC_VERSION=3.15.0 \ No newline at end of file +NEXT_PUBLIC_VERSION=3.15.1 \ No newline at end of file diff --git a/package.json b/package.json index 67dbcd6c..557e7107 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "notion-next", - "version": "3.15.0", + "version": "3.15.1", "homepage": "https://github.com/tangly1024/NotionNext.git", "license": "MIT", "repository": {