diff --git a/themes/commerce/components/BlogPostArchive.js b/themes/commerce/components/BlogPostArchive.js
index 85fe02d1..7de25e1a 100644
--- a/themes/commerce/components/BlogPostArchive.js
+++ b/themes/commerce/components/BlogPostArchive.js
@@ -1,4 +1,3 @@
-import React from 'react'
import Link from 'next/link'
import BLOG from '@/blog.config'
/**
diff --git a/themes/commerce/components/BlogPostListScroll.js b/themes/commerce/components/BlogPostListScroll.js
index 3f0729e9..7af8c302 100644
--- a/themes/commerce/components/BlogPostListScroll.js
+++ b/themes/commerce/components/BlogPostListScroll.js
@@ -2,9 +2,9 @@ import BLOG from '@/blog.config'
import ProductCard from './ProductCard'
import BlogPostListEmpty from './BlogPostListEmpty'
import { useGlobal } from '@/lib/global'
-import React from 'react'
import CONFIG from '../config'
import { getListByPage } from '@/lib/utils'
+import { useEffect, useRef, useState } from 'react'
/**
* 博客列表滚动分页
@@ -15,7 +15,7 @@ import { getListByPage } from '@/lib/utils'
*/
const BlogPostListScroll = ({ posts = [], currentSearch, showSummary = CONFIG.POST_LIST_SUMMARY, siteInfo }) => {
const postsPerPage = BLOG.POSTS_PER_PAGE
- const [page, updatePage] = React.useState(1)
+ const [page, updatePage] = useState(1)
const postsToShow = getListByPage(posts, page, postsPerPage)
let hasMore = false
@@ -41,14 +41,14 @@ const BlogPostListScroll = ({ posts = [], currentSearch, showSummary = CONFIG.PO
}
// 监听滚动
- React.useEffect(() => {
+ useEffect(() => {
window.addEventListener('scroll', scrollTrigger)
return () => {
window.removeEventListener('scroll', scrollTrigger)
}
})
- const targetRef = React.useRef(null)
+ const targetRef = useRef(null)
const { locale } = useGlobal()
if (!postsToShow || postsToShow.length === 0) {
diff --git a/themes/commerce/components/CategoryGroup.js b/themes/commerce/components/CategoryGroup.js
index 3e8ff7d0..0b313088 100644
--- a/themes/commerce/components/CategoryGroup.js
+++ b/themes/commerce/components/CategoryGroup.js
@@ -1,5 +1,4 @@
import Link from 'next/link'
-import React from 'react'
const CategoryGroup = ({ currentCategory, categories }) => {
if (!categories) {
diff --git a/themes/commerce/components/Footer.js b/themes/commerce/components/Footer.js
index 180f1005..7a0f59b8 100644
--- a/themes/commerce/components/Footer.js
+++ b/themes/commerce/components/Footer.js
@@ -1,4 +1,3 @@
-import React from 'react'
import { siteConfig } from '@/lib/config'
import Link from 'next/link'
diff --git a/themes/commerce/components/HexoRecentComments.js b/themes/commerce/components/HexoRecentComments.js
index 2ebf00c8..6ef3a870 100644
--- a/themes/commerce/components/HexoRecentComments.js
+++ b/themes/commerce/components/HexoRecentComments.js
@@ -1,4 +1,4 @@
-import React from 'react'
+import { useEffect, useState } from 'react'
import BLOG from '@/blog.config'
import Card from '@/themes/hexo/components/Card'
import { useGlobal } from '@/lib/global'
@@ -11,10 +11,10 @@ import { RecentComments } from '@waline/client'
* @returns
*/
const HexoRecentComments = (props) => {
- const [comments, updateComments] = React.useState([])
+ const [comments, updateComments] = useState([])
const { locale } = useGlobal()
- const [onLoading, changeLoading] = React.useState(true)
- React.useEffect(() => {
+ const [onLoading, changeLoading] = useState(true)
+ useEffect(() => {
RecentComments({
serverURL: BLOG.COMMENT_WALINE_SERVER_URL,
count: 5
diff --git a/themes/commerce/components/JumpToCommentButton.js b/themes/commerce/components/JumpToCommentButton.js
index fb007712..ded36c9a 100644
--- a/themes/commerce/components/JumpToCommentButton.js
+++ b/themes/commerce/components/JumpToCommentButton.js
@@ -1,4 +1,3 @@
-import React from 'react'
import CONFIG from '../config'
/**
diff --git a/themes/commerce/components/JumpToTopButton.js b/themes/commerce/components/JumpToTopButton.js
index 77313f46..a89899a9 100644
--- a/themes/commerce/components/JumpToTopButton.js
+++ b/themes/commerce/components/JumpToTopButton.js
@@ -1,5 +1,4 @@
import { useGlobal } from '@/lib/global'
-import React from 'react'
import CONFIG from '../config'
/**
diff --git a/themes/commerce/components/MenuGroupCard.js b/themes/commerce/components/MenuGroupCard.js
index 3b5ac595..5e4d84a4 100644
--- a/themes/commerce/components/MenuGroupCard.js
+++ b/themes/commerce/components/MenuGroupCard.js
@@ -1,4 +1,3 @@
-import React from 'react'
import Link from 'next/link'
import { useGlobal } from '@/lib/global'
import CONFIG from '../config'
diff --git a/themes/commerce/components/NavButtonGroup.js b/themes/commerce/components/NavButtonGroup.js
index fbac9cca..8539eb49 100644
--- a/themes/commerce/components/NavButtonGroup.js
+++ b/themes/commerce/components/NavButtonGroup.js
@@ -1,5 +1,3 @@
-
-import React from 'react'
import Link from 'next/link'
/**
diff --git a/themes/commerce/components/ProductCard.js b/themes/commerce/components/ProductCard.js
index 62bfd4b4..aa2cd0bf 100644
--- a/themes/commerce/components/ProductCard.js
+++ b/themes/commerce/components/ProductCard.js
@@ -1,5 +1,4 @@
import Link from 'next/link'
-import React from 'react'
import CONFIG from '../config'
import BLOG from '@/blog.config'
import LazyImage from '@/components/LazyImage'
diff --git a/themes/commerce/components/Progress.js b/themes/commerce/components/Progress.js
index 8cb9fe0e..585e1c21 100644
--- a/themes/commerce/components/Progress.js
+++ b/themes/commerce/components/Progress.js
@@ -1,4 +1,4 @@
-import React, { useEffect, useState } from 'react'
+import { useEffect, useState } from 'react'
import { isBrowser } from '@/lib/utils'
/**
diff --git a/themes/commerce/components/TocDrawer.js b/themes/commerce/components/TocDrawer.js
index 13fad1a9..20c1941b 100644
--- a/themes/commerce/components/TocDrawer.js
+++ b/themes/commerce/components/TocDrawer.js
@@ -1,5 +1,5 @@
import Catalog from './Catalog'
-import React, { useImperativeHandle, useState } from 'react'
+import { useImperativeHandle, useState } from 'react'
/**
* 目录抽屉栏
diff --git a/themes/commerce/components/TocDrawerButton.js b/themes/commerce/components/TocDrawerButton.js
index 8e5053b6..6d7d5294 100644
--- a/themes/commerce/components/TocDrawerButton.js
+++ b/themes/commerce/components/TocDrawerButton.js
@@ -1,5 +1,4 @@
import { useGlobal } from '@/lib/global'
-import React from 'react'
import CONFIG from '../config'
/**
diff --git a/themes/example/components/BlogListScroll.js b/themes/example/components/BlogListScroll.js
index ad6df10e..16a0b7eb 100644
--- a/themes/example/components/BlogListScroll.js
+++ b/themes/example/components/BlogListScroll.js
@@ -1,6 +1,6 @@
import BLOG from '@/blog.config'
import { useGlobal } from '@/lib/global'
-import React, { useEffect } from 'react'
+import { useCallback, useEffect, useRef, useState } from 'react'
import throttle from 'lodash.throttle'
import BlogPostCard from './BlogPostCard'
import CONFIG from '../config'
@@ -9,7 +9,7 @@ export const BlogListScroll = props => {
const { posts } = props
const { locale } = useGlobal()
- const [page, updatePage] = React.useState(1)
+ const [page, updatePage] = useState(1)
let hasMore = false
const postsToShow = posts
@@ -25,10 +25,10 @@ export const BlogListScroll = props => {
updatePage(page + 1)
}
- const targetRef = React.useRef(null)
+ const targetRef = useRef(null)
// 监听滚动自动分页加载
- const scrollTrigger = React.useCallback(throttle(() => {
+ const scrollTrigger = useCallback(throttle(() => {
const scrollS = window.scrollY + window.outerHeight
const clientHeight = targetRef ? (targetRef.current ? (targetRef.current.clientHeight) : 0) : 0
if (scrollS > clientHeight + 100) {
diff --git a/themes/example/components/ExampleRecentComments.js b/themes/example/components/ExampleRecentComments.js
index b1555c1d..7e2c3517 100644
--- a/themes/example/components/ExampleRecentComments.js
+++ b/themes/example/components/ExampleRecentComments.js
@@ -1,4 +1,4 @@
-import React from 'react'
+import { useEffect, useState } from 'react'
import BLOG from '@/blog.config'
import Link from 'next/link'
import { RecentComments } from '@waline/client'
@@ -9,9 +9,9 @@ import { RecentComments } from '@waline/client'
* @returns
*/
const ExampleRecentComments = (props) => {
- const [comments, updateComments] = React.useState([])
- const [onLoading, changeLoading] = React.useState(true)
- React.useEffect(() => {
+ const [comments, updateComments] = useState([])
+ const [onLoading, changeLoading] = useState(true)
+ useEffect(() => {
RecentComments({
serverURL: BLOG.COMMENT_WALINE_SERVER_URL,
count: 5
diff --git a/themes/example/components/JumpToTopButton.js b/themes/example/components/JumpToTopButton.js
index 30e684a8..f5e22b61 100644
--- a/themes/example/components/JumpToTopButton.js
+++ b/themes/example/components/JumpToTopButton.js
@@ -1,5 +1,4 @@
import { useGlobal } from '@/lib/global'
-import React from 'react'
/**
* 跳转到网页顶部
diff --git a/themes/fukasawa/components/BlogCard.js b/themes/fukasawa/components/BlogCard.js
index ec9070f4..d90e9b5a 100644
--- a/themes/fukasawa/components/BlogCard.js
+++ b/themes/fukasawa/components/BlogCard.js
@@ -1,7 +1,6 @@
import BLOG from '@/blog.config'
import Link from 'next/link'
import TagItemMini from './TagItemMini'
-import React from 'react'
import CONFIG_FUKA from '../config'
import LazyImage from '@/components/LazyImage'
diff --git a/themes/fukasawa/components/BlogListScroll.js b/themes/fukasawa/components/BlogListScroll.js
index b1752000..c996a4a6 100644
--- a/themes/fukasawa/components/BlogListScroll.js
+++ b/themes/fukasawa/components/BlogListScroll.js
@@ -1,5 +1,5 @@
import BLOG from '@/blog.config'
-import React from 'react'
+import { useEffect, useRef, useState } from 'react'
import BlogCard from './BlogCard'
import BlogPostListEmpty from './BlogListEmpty'
import { useGlobal } from '@/lib/global'
@@ -15,9 +15,9 @@ import { useGlobal } from '@/lib/global'
const BlogListScroll = props => {
const { posts = [], siteInfo } = props
const { locale } = useGlobal()
- const targetRef = React.useRef(null)
+ const targetRef = useRef(null)
- const [page, updatePage] = React.useState(1)
+ const [page, updatePage] = useState(1)
let hasMore = false
const postsToShow = posts
@@ -44,7 +44,7 @@ const BlogListScroll = props => {
})
}
- React.useEffect(() => {
+ useEffect(() => {
window.addEventListener('scroll', scrollTrigger)
return () => {
window.removeEventListener('scroll', scrollTrigger)
diff --git a/themes/fukasawa/components/BlogPostArchive.js b/themes/fukasawa/components/BlogPostArchive.js
index 08557ae3..c76272e0 100644
--- a/themes/fukasawa/components/BlogPostArchive.js
+++ b/themes/fukasawa/components/BlogPostArchive.js
@@ -1,4 +1,3 @@
-import React from 'react'
import Link from 'next/link'
import BLOG from '@/blog.config'
/**
diff --git a/themes/fukasawa/components/Catalog.js b/themes/fukasawa/components/Catalog.js
index 4a5414d2..9f0a054c 100644
--- a/themes/fukasawa/components/Catalog.js
+++ b/themes/fukasawa/components/Catalog.js
@@ -1,4 +1,4 @@
-import React, { useEffect, useRef, useState } from 'react'
+import { useEffect, useRef, useState } from 'react'
import throttle from 'lodash.throttle'
import { uuidToId } from 'notion-utils'
import { useGlobal } from '@/lib/global'
diff --git a/themes/fukasawa/components/GroupCategory.js b/themes/fukasawa/components/GroupCategory.js
index f9cd00cc..1753afd2 100644
--- a/themes/fukasawa/components/GroupCategory.js
+++ b/themes/fukasawa/components/GroupCategory.js
@@ -1,5 +1,4 @@
import Link from 'next/link'
-import React from 'react'
function GroupCategory ({ currentCategory, categories }) {
if (!categories) {
diff --git a/themes/fukasawa/components/TagItem.js b/themes/fukasawa/components/TagItem.js
index 18511426..179da9db 100644
--- a/themes/fukasawa/components/TagItem.js
+++ b/themes/fukasawa/components/TagItem.js
@@ -1,5 +1,4 @@
import Link from 'next/link'
-import React from 'react'
import { useGlobal } from '@/lib/global'
const TagItem = ({ tag, selected }) => {
diff --git a/themes/gitbook/components/BlogPostCard.js b/themes/gitbook/components/BlogPostCard.js
index 15ff21ef..d4285a97 100644
--- a/themes/gitbook/components/BlogPostCard.js
+++ b/themes/gitbook/components/BlogPostCard.js
@@ -1,7 +1,6 @@
import BLOG from '@/blog.config'
import Link from 'next/link'
import { useRouter } from 'next/router'
-import React from 'react'
const BlogPostCard = ({ post, className }) => {
const router = useRouter()
diff --git a/themes/gitbook/components/BottomMenuBar.js b/themes/gitbook/components/BottomMenuBar.js
index 101fd572..234221b5 100644
--- a/themes/gitbook/components/BottomMenuBar.js
+++ b/themes/gitbook/components/BottomMenuBar.js
@@ -1,5 +1,4 @@
import { useGitBookGlobal } from '@/themes/gitbook'
-import React from 'react'
import JumpToTopButton from './JumpToTopButton'
export default function BottomMenuBar({ post, className }) {
diff --git a/themes/gitbook/components/CategoryGroup.js b/themes/gitbook/components/CategoryGroup.js
index 1516c038..71f40a0d 100644
--- a/themes/gitbook/components/CategoryGroup.js
+++ b/themes/gitbook/components/CategoryGroup.js
@@ -1,4 +1,4 @@
-import React from 'react'
+
import CategoryItem from './CategoryItem'
const CategoryGroup = ({ currentCategory, categoryOptions }) => {
diff --git a/themes/gitbook/components/Footer.js b/themes/gitbook/components/Footer.js
index 19310883..128105ec 100644
--- a/themes/gitbook/components/Footer.js
+++ b/themes/gitbook/components/Footer.js
@@ -1,4 +1,4 @@
-import React from 'react'
+
import BLOG from '@/blog.config'
import { siteConfig } from '@/lib/config'
diff --git a/themes/gitbook/components/LeftMenuBar.js b/themes/gitbook/components/LeftMenuBar.js
index e6636e19..6bde6c51 100644
--- a/themes/gitbook/components/LeftMenuBar.js
+++ b/themes/gitbook/components/LeftMenuBar.js
@@ -1,5 +1,4 @@
import Link from 'next/link'
-import React from 'react'
export default function LeftMenuBar () {
return (
diff --git a/themes/gitbook/components/NavPostItem.js b/themes/gitbook/components/NavPostItem.js
index 66ffa6dd..e83046ce 100644
--- a/themes/gitbook/components/NavPostItem.js
+++ b/themes/gitbook/components/NavPostItem.js
@@ -1,5 +1,5 @@
import BlogPostCard from './BlogPostCard'
-import React, { useState } from 'react'
+import { useState } from 'react'
import Collapse from '@/components/Collapse'
/**
diff --git a/themes/gitbook/components/Progress.js b/themes/gitbook/components/Progress.js
index 669d09a8..29feef49 100644
--- a/themes/gitbook/components/Progress.js
+++ b/themes/gitbook/components/Progress.js
@@ -1,4 +1,4 @@
-import React, { useEffect, useState } from 'react'
+import { useEffect, useState } from 'react'
import { isBrowser } from '@/lib/utils'
/**
diff --git a/themes/heo/components/BlogPostArchive.js b/themes/heo/components/BlogPostArchive.js
index 4f471444..ed494883 100644
--- a/themes/heo/components/BlogPostArchive.js
+++ b/themes/heo/components/BlogPostArchive.js
@@ -1,4 +1,3 @@
-import React from 'react'
import Link from 'next/link'
import BLOG from '@/blog.config'
import CONFIG from '../config'
diff --git a/themes/heo/components/BlogPostListScroll.js b/themes/heo/components/BlogPostListScroll.js
index 20202a9f..f45890fe 100644
--- a/themes/heo/components/BlogPostListScroll.js
+++ b/themes/heo/components/BlogPostListScroll.js
@@ -2,7 +2,7 @@ import BLOG from '@/blog.config'
import BlogPostCard from './BlogPostCard'
import BlogPostListEmpty from './BlogPostListEmpty'
import { useGlobal } from '@/lib/global'
-import React, { useEffect, useRef, useState } from 'react'
+import { useEffect, useRef, useState } from 'react'
import CONFIG from '../config'
import { getListByPage } from '@/lib/utils'
diff --git a/themes/heo/components/CategoryGroup.js b/themes/heo/components/CategoryGroup.js
index 811ad9ff..21915d72 100644
--- a/themes/heo/components/CategoryGroup.js
+++ b/themes/heo/components/CategoryGroup.js
@@ -1,5 +1,4 @@
import Link from 'next/link'
-import React from 'react'
const CategoryGroup = ({ currentCategory, categories }) => {
if (!categories) {
diff --git a/themes/heo/components/Footer.js b/themes/heo/components/Footer.js
index ead230e3..338ddd4c 100644
--- a/themes/heo/components/Footer.js
+++ b/themes/heo/components/Footer.js
@@ -1,4 +1,3 @@
-import React from 'react'
import BLOG from '@/blog.config'
import SocialButton from './SocialButton'
import { siteConfig } from '@/lib/config'
diff --git a/themes/heo/components/HexoRecentComments.js b/themes/heo/components/HexoRecentComments.js
index 2ebf00c8..9231d687 100644
--- a/themes/heo/components/HexoRecentComments.js
+++ b/themes/heo/components/HexoRecentComments.js
@@ -1,9 +1,9 @@
-import React from 'react'
import BLOG from '@/blog.config'
import Card from '@/themes/hexo/components/Card'
import { useGlobal } from '@/lib/global'
import Link from 'next/link'
import { RecentComments } from '@waline/client'
+import { useEffect, useState } from 'react'
/**
* @see https://waline.js.org/guide/get-started.html
@@ -11,10 +11,10 @@ import { RecentComments } from '@waline/client'
* @returns
*/
const HexoRecentComments = (props) => {
- const [comments, updateComments] = React.useState([])
+ const [comments, updateComments] = useState([])
const { locale } = useGlobal()
- const [onLoading, changeLoading] = React.useState(true)
- React.useEffect(() => {
+ const [onLoading, changeLoading] = useState(true)
+ useEffect(() => {
RecentComments({
serverURL: BLOG.COMMENT_WALINE_SERVER_URL,
count: 5
diff --git a/themes/heo/components/JumpToCommentButton.js b/themes/heo/components/JumpToCommentButton.js
index fb007712..ded36c9a 100644
--- a/themes/heo/components/JumpToCommentButton.js
+++ b/themes/heo/components/JumpToCommentButton.js
@@ -1,4 +1,3 @@
-import React from 'react'
import CONFIG from '../config'
/**
diff --git a/themes/heo/components/JumpToTopButton.js b/themes/heo/components/JumpToTopButton.js
index 77313f46..a89899a9 100644
--- a/themes/heo/components/JumpToTopButton.js
+++ b/themes/heo/components/JumpToTopButton.js
@@ -1,5 +1,4 @@
import { useGlobal } from '@/lib/global'
-import React from 'react'
import CONFIG from '../config'
/**
diff --git a/themes/heo/components/MenuGroupCard.js b/themes/heo/components/MenuGroupCard.js
index 39d509e4..bc41b30b 100644
--- a/themes/heo/components/MenuGroupCard.js
+++ b/themes/heo/components/MenuGroupCard.js
@@ -1,4 +1,3 @@
-import React from 'react'
import Link from 'next/link'
import { useGlobal } from '@/lib/global'
import CONFIG from '../config'
diff --git a/themes/heo/components/NavButtonGroup.js b/themes/heo/components/NavButtonGroup.js
index 7b79bf5e..82331852 100644
--- a/themes/heo/components/NavButtonGroup.js
+++ b/themes/heo/components/NavButtonGroup.js
@@ -1,5 +1,3 @@
-
-import React from 'react'
import Link from 'next/link'
/**
diff --git a/themes/heo/components/TocDrawerButton.js b/themes/heo/components/TocDrawerButton.js
index 8e5053b6..6d7d5294 100644
--- a/themes/heo/components/TocDrawerButton.js
+++ b/themes/heo/components/TocDrawerButton.js
@@ -1,5 +1,4 @@
import { useGlobal } from '@/lib/global'
-import React from 'react'
import CONFIG from '../config'
/**
diff --git a/themes/hexo/components/BlogPostArchive.js b/themes/hexo/components/BlogPostArchive.js
index ea3c6cd2..fd5b19f0 100644
--- a/themes/hexo/components/BlogPostArchive.js
+++ b/themes/hexo/components/BlogPostArchive.js
@@ -1,4 +1,3 @@
-import React from 'react'
import Link from 'next/link'
import BLOG from '@/blog.config'
/**
diff --git a/themes/hexo/components/BlogPostCard.js b/themes/hexo/components/BlogPostCard.js
index f1febbdd..0e4e0fec 100644
--- a/themes/hexo/components/BlogPostCard.js
+++ b/themes/hexo/components/BlogPostCard.js
@@ -1,5 +1,4 @@
import Link from 'next/link'
-import React from 'react'
import CONFIG from '../config'
import { BlogPostCardInfo } from './BlogPostCardInfo'
import BLOG from '@/blog.config'
diff --git a/themes/hexo/components/BlogPostListScroll.js b/themes/hexo/components/BlogPostListScroll.js
index 7646b056..5c69c96b 100644
--- a/themes/hexo/components/BlogPostListScroll.js
+++ b/themes/hexo/components/BlogPostListScroll.js
@@ -2,7 +2,7 @@ import BLOG from '@/blog.config'
import BlogPostCard from './BlogPostCard'
import BlogPostListEmpty from './BlogPostListEmpty'
import { useGlobal } from '@/lib/global'
-import React from 'react'
+import { useEffect, useRef, useState } from 'react'
import CONFIG from '../config'
import { getListByPage } from '@/lib/utils'
@@ -15,7 +15,7 @@ import { getListByPage } from '@/lib/utils'
*/
const BlogPostListScroll = ({ posts = [], currentSearch, showSummary = CONFIG.POST_LIST_SUMMARY, siteInfo }) => {
const postsPerPage = BLOG.POSTS_PER_PAGE
- const [page, updatePage] = React.useState(1)
+ const [page, updatePage] = useState(1)
const postsToShow = getListByPage(posts, page, postsPerPage)
let hasMore = false
@@ -41,14 +41,14 @@ const BlogPostListScroll = ({ posts = [], currentSearch, showSummary = CONFIG.PO
}
// 监听滚动
- React.useEffect(() => {
+ useEffect(() => {
window.addEventListener('scroll', scrollTrigger)
return () => {
window.removeEventListener('scroll', scrollTrigger)
}
})
- const targetRef = React.useRef(null)
+ const targetRef = useRef(null)
const { locale } = useGlobal()
if (!postsToShow || postsToShow.length === 0) {
diff --git a/themes/hexo/components/CategoryGroup.js b/themes/hexo/components/CategoryGroup.js
index c88df60a..69aa4c1c 100644
--- a/themes/hexo/components/CategoryGroup.js
+++ b/themes/hexo/components/CategoryGroup.js
@@ -1,5 +1,4 @@
import Link from 'next/link'
-import React from 'react'
const CategoryGroup = ({ currentCategory, categories }) => {
if (!categories) {
diff --git a/themes/hexo/components/Footer.js b/themes/hexo/components/Footer.js
index 53ba15db..03a8b580 100644
--- a/themes/hexo/components/Footer.js
+++ b/themes/hexo/components/Footer.js
@@ -1,4 +1,3 @@
-import React from 'react'
import BLOG from '@/blog.config'
import { siteConfig } from '@/lib/config'
diff --git a/themes/hexo/components/HexoRecentComments.js b/themes/hexo/components/HexoRecentComments.js
index 2ebf00c8..6ef3a870 100644
--- a/themes/hexo/components/HexoRecentComments.js
+++ b/themes/hexo/components/HexoRecentComments.js
@@ -1,4 +1,4 @@
-import React from 'react'
+import { useEffect, useState } from 'react'
import BLOG from '@/blog.config'
import Card from '@/themes/hexo/components/Card'
import { useGlobal } from '@/lib/global'
@@ -11,10 +11,10 @@ import { RecentComments } from '@waline/client'
* @returns
*/
const HexoRecentComments = (props) => {
- const [comments, updateComments] = React.useState([])
+ const [comments, updateComments] = useState([])
const { locale } = useGlobal()
- const [onLoading, changeLoading] = React.useState(true)
- React.useEffect(() => {
+ const [onLoading, changeLoading] = useState(true)
+ useEffect(() => {
RecentComments({
serverURL: BLOG.COMMENT_WALINE_SERVER_URL,
count: 5
diff --git a/themes/hexo/components/JumpToCommentButton.js b/themes/hexo/components/JumpToCommentButton.js
index fb007712..ded36c9a 100644
--- a/themes/hexo/components/JumpToCommentButton.js
+++ b/themes/hexo/components/JumpToCommentButton.js
@@ -1,4 +1,3 @@
-import React from 'react'
import CONFIG from '../config'
/**
diff --git a/themes/hexo/components/JumpToTopButton.js b/themes/hexo/components/JumpToTopButton.js
index 77313f46..a89899a9 100644
--- a/themes/hexo/components/JumpToTopButton.js
+++ b/themes/hexo/components/JumpToTopButton.js
@@ -1,5 +1,4 @@
import { useGlobal } from '@/lib/global'
-import React from 'react'
import CONFIG from '../config'
/**
diff --git a/themes/hexo/components/Logo.js b/themes/hexo/components/Logo.js
index 61209633..f116988d 100644
--- a/themes/hexo/components/Logo.js
+++ b/themes/hexo/components/Logo.js
@@ -1,6 +1,5 @@
import BLOG from '@/blog.config'
import Link from 'next/link'
-import React from 'react'
import { siteConfig } from '@/lib/config'
const Logo = props => {
diff --git a/themes/hexo/components/MenuGroupCard.js b/themes/hexo/components/MenuGroupCard.js
index 5be22e2b..149ec9d1 100644
--- a/themes/hexo/components/MenuGroupCard.js
+++ b/themes/hexo/components/MenuGroupCard.js
@@ -1,4 +1,3 @@
-import React from 'react'
import Link from 'next/link'
import { useGlobal } from '@/lib/global'
import CONFIG from '../config'
diff --git a/themes/hexo/components/NavButtonGroup.js b/themes/hexo/components/NavButtonGroup.js
index fbac9cca..8539eb49 100644
--- a/themes/hexo/components/NavButtonGroup.js
+++ b/themes/hexo/components/NavButtonGroup.js
@@ -1,5 +1,3 @@
-
-import React from 'react'
import Link from 'next/link'
/**
diff --git a/themes/hexo/components/Progress.js b/themes/hexo/components/Progress.js
index 59ee1697..8c233c54 100644
--- a/themes/hexo/components/Progress.js
+++ b/themes/hexo/components/Progress.js
@@ -1,4 +1,4 @@
-import React, { useEffect, useState } from 'react'
+import { useEffect, useState } from 'react'
import { isBrowser } from '@/lib/utils'
/**
diff --git a/themes/hexo/components/TocDrawer.js b/themes/hexo/components/TocDrawer.js
index 13fad1a9..20c1941b 100644
--- a/themes/hexo/components/TocDrawer.js
+++ b/themes/hexo/components/TocDrawer.js
@@ -1,5 +1,5 @@
import Catalog from './Catalog'
-import React, { useImperativeHandle, useState } from 'react'
+import { useImperativeHandle, useState } from 'react'
/**
* 目录抽屉栏
diff --git a/themes/hexo/components/TocDrawerButton.js b/themes/hexo/components/TocDrawerButton.js
index 8e5053b6..6d7d5294 100644
--- a/themes/hexo/components/TocDrawerButton.js
+++ b/themes/hexo/components/TocDrawerButton.js
@@ -1,5 +1,4 @@
import { useGlobal } from '@/lib/global'
-import React from 'react'
import CONFIG from '../config'
/**
diff --git a/themes/matery/components/BlogPostArchive.js b/themes/matery/components/BlogPostArchive.js
index ea3c6cd2..2d003813 100644
--- a/themes/matery/components/BlogPostArchive.js
+++ b/themes/matery/components/BlogPostArchive.js
@@ -1,6 +1,6 @@
-import React from 'react'
import Link from 'next/link'
import BLOG from '@/blog.config'
+
/**
* 博客归档列表
* @param posts 所有文章
diff --git a/themes/matery/components/BlogPostCard.js b/themes/matery/components/BlogPostCard.js
index 5fa034cc..2ed1a91a 100644
--- a/themes/matery/components/BlogPostCard.js
+++ b/themes/matery/components/BlogPostCard.js
@@ -1,6 +1,5 @@
import BLOG from '@/blog.config'
import Link from 'next/link'
-import React from 'react'
import TagItemMini from './TagItemMini'
import CONFIG from '../config'
import TwikooCommentCount from '@/components/TwikooCommentCount'
diff --git a/themes/matery/components/BlogPostListScroll.js b/themes/matery/components/BlogPostListScroll.js
index 6d0f4743..9a85bf2f 100644
--- a/themes/matery/components/BlogPostListScroll.js
+++ b/themes/matery/components/BlogPostListScroll.js
@@ -2,7 +2,7 @@ import BLOG from '@/blog.config'
import BlogPostCard from './BlogPostCard'
import BlogPostListEmpty from './BlogPostListEmpty'
import { useGlobal } from '@/lib/global'
-import React, { useCallback } from 'react'
+import { useCallback, useEffect, useRef, useState } from 'react'
import CONFIG from '../config'
import { getListByPage } from '@/lib/utils'
import throttle from 'lodash.throttle'
@@ -16,9 +16,18 @@ import throttle from 'lodash.throttle'
*/
const BlogPostListScroll = ({ posts = [], currentSearch, showSummary = CONFIG.POST_LIST_SUMMARY, siteInfo }) => {
const postsPerPage = BLOG.POSTS_PER_PAGE
- const [page, updatePage] = React.useState(1)
+ const [page, updatePage] = useState(1)
const postsToShow = getListByPage(posts, page, postsPerPage)
+ // 监听滚动
+ useEffect(() => {
+ window.addEventListener('scroll', scrollTrigger)
+ return () => {
+ window.removeEventListener('scroll', scrollTrigger)
+ }
+ })
+ const targetRef = useRef(null)
+ const { locale } = useGlobal()
let hasMore = false
if (posts) {
const totalCount = posts.length
@@ -40,16 +49,6 @@ const BlogPostListScroll = ({ posts = [], currentSearch, showSummary = CONFIG.PO
}
})
}, throttleMs))
- // 监听滚动
- React.useEffect(() => {
- window.addEventListener('scroll', scrollTrigger)
- return () => {
- window.removeEventListener('scroll', scrollTrigger)
- }
- })
-
- const targetRef = React.useRef(null)
- const { locale } = useGlobal()
if (!postsToShow || postsToShow.length === 0) {
return
diff --git a/themes/matery/components/CategoryGroup.js b/themes/matery/components/CategoryGroup.js
index ad4e7b2a..62046784 100644
--- a/themes/matery/components/CategoryGroup.js
+++ b/themes/matery/components/CategoryGroup.js
@@ -1,5 +1,4 @@
import Link from 'next/link'
-import React from 'react'
const CategoryGroup = ({ currentCategory, categories }) => {
if (!categories) {
diff --git a/themes/matery/components/Footer.js b/themes/matery/components/Footer.js
index 87c40bad..e8d57c18 100644
--- a/themes/matery/components/Footer.js
+++ b/themes/matery/components/Footer.js
@@ -1,4 +1,3 @@
-import React from 'react'
import BLOG from '@/blog.config'
import { siteConfig } from '@/lib/config'
diff --git a/themes/matery/components/HexoRecentComments.js b/themes/matery/components/HexoRecentComments.js
index 4bdbb82f..1fee58c8 100644
--- a/themes/matery/components/HexoRecentComments.js
+++ b/themes/matery/components/HexoRecentComments.js
@@ -1,4 +1,4 @@
-import React from 'react'
+import { useEffect, useState } from 'react'
import BLOG from '@/blog.config'
import Card from '@/themes/hexo/components/Card'
import { useGlobal } from '@/lib/global'
@@ -11,10 +11,10 @@ import { RecentComments } from '@waline/client'
* @returns
*/
const HexoRecentComments = (props) => {
- const [comments, updateComments] = React.useState([])
+ const [comments, updateComments] = useState([])
const { locale } = useGlobal()
- const [onLoading, changeLoading] = React.useState(true)
- React.useEffect(() => {
+ const [onLoading, changeLoading] = useState(true)
+ useEffect(() => {
RecentComments({
serverURL: BLOG.COMMENT_WALINE_SERVER_URL,
count: 5
diff --git a/themes/matery/components/JumpToCommentButton.js b/themes/matery/components/JumpToCommentButton.js
index 98abb03f..236e9ad8 100644
--- a/themes/matery/components/JumpToCommentButton.js
+++ b/themes/matery/components/JumpToCommentButton.js
@@ -1,4 +1,3 @@
-import React from 'react'
import CONFIG from '../config'
/**
diff --git a/themes/matery/components/JumpToTopButton.js b/themes/matery/components/JumpToTopButton.js
index 2b1e3018..fcbff42d 100644
--- a/themes/matery/components/JumpToTopButton.js
+++ b/themes/matery/components/JumpToTopButton.js
@@ -1,5 +1,4 @@
import { useGlobal } from '@/lib/global'
-import React from 'react'
import CONFIG from '../config'
/**
diff --git a/themes/matery/components/Logo.js b/themes/matery/components/Logo.js
index 104a546e..f2d6448b 100644
--- a/themes/matery/components/Logo.js
+++ b/themes/matery/components/Logo.js
@@ -1,6 +1,6 @@
import BLOG from '@/blog.config'
import Link from 'next/link'
-import React from 'react'
+
import { siteConfig } from '@/lib/config'
const Logo = props => {
diff --git a/themes/matery/components/MenuGroupCard.js b/themes/matery/components/MenuGroupCard.js
index 1c04f4e7..6dc974cb 100644
--- a/themes/matery/components/MenuGroupCard.js
+++ b/themes/matery/components/MenuGroupCard.js
@@ -1,4 +1,3 @@
-import React from 'react'
import Link from 'next/link'
import { useGlobal } from '@/lib/global'
import CONFIG from '../config'
diff --git a/themes/matery/components/MenuList.js b/themes/matery/components/MenuList.js
index 6ea230f2..339ac6e0 100644
--- a/themes/matery/components/MenuList.js
+++ b/themes/matery/components/MenuList.js
@@ -1,4 +1,3 @@
-import React from 'react'
import Link from 'next/link'
import { useRouter } from 'next/router'
import { useGlobal } from '@/lib/global'
diff --git a/themes/matery/components/NavButtonGroup.js b/themes/matery/components/NavButtonGroup.js
index 37d448a7..1b0d471e 100644
--- a/themes/matery/components/NavButtonGroup.js
+++ b/themes/matery/components/NavButtonGroup.js
@@ -1,5 +1,3 @@
-
-import React from 'react'
import Link from 'next/link'
/**
diff --git a/themes/matery/components/Progress.js b/themes/matery/components/Progress.js
index dcdea5ba..2ac2ca81 100644
--- a/themes/matery/components/Progress.js
+++ b/themes/matery/components/Progress.js
@@ -1,4 +1,4 @@
-import React, { useEffect, useState } from 'react'
+import { useEffect, useState } from 'react'
import { isBrowser } from '@/lib/utils'
/**
diff --git a/themes/matery/components/TocDrawer.js b/themes/matery/components/TocDrawer.js
index 7df6d309..051e69a9 100644
--- a/themes/matery/components/TocDrawer.js
+++ b/themes/matery/components/TocDrawer.js
@@ -1,5 +1,5 @@
import Catalog from './Catalog'
-import React, { useImperativeHandle, useState } from 'react'
+import { useImperativeHandle, useState } from 'react'
/**
* 目录抽屉栏
diff --git a/themes/matery/components/TocDrawerButton.js b/themes/matery/components/TocDrawerButton.js
index 8e5053b6..6d7d5294 100644
--- a/themes/matery/components/TocDrawerButton.js
+++ b/themes/matery/components/TocDrawerButton.js
@@ -1,5 +1,4 @@
import { useGlobal } from '@/lib/global'
-import React from 'react'
import CONFIG from '../config'
/**
diff --git a/themes/medium/components/BlogPostCard.js b/themes/medium/components/BlogPostCard.js
index 16a963e6..1d3d69d7 100644
--- a/themes/medium/components/BlogPostCard.js
+++ b/themes/medium/components/BlogPostCard.js
@@ -2,7 +2,6 @@ import BLOG from '@/blog.config'
import NotionPage from '@/components/NotionPage'
import { useGlobal } from '@/lib/global'
import Link from 'next/link'
-import React from 'react'
import CONFIG from '../config'
import CategoryItem from './CategoryItem'
import TagItemMini from './TagItemMini'
diff --git a/themes/medium/components/BlogPostListScroll.js b/themes/medium/components/BlogPostListScroll.js
index 0ed06ae3..457c3565 100644
--- a/themes/medium/components/BlogPostListScroll.js
+++ b/themes/medium/components/BlogPostListScroll.js
@@ -3,7 +3,7 @@ import BlogPostCard from './BlogPostCard'
import BlogPostListEmpty from './BlogPostListEmpty'
import { useGlobal } from '@/lib/global'
import throttle from 'lodash.throttle'
-import React, { useCallback, useEffect, useRef, useState } from 'react'
+import { useCallback, useEffect, useRef, useState } from 'react'
import { useRouter } from 'next/router'
/**
diff --git a/themes/medium/components/BottomMenuBar.js b/themes/medium/components/BottomMenuBar.js
index 808b74eb..fee36eb2 100644
--- a/themes/medium/components/BottomMenuBar.js
+++ b/themes/medium/components/BottomMenuBar.js
@@ -1,5 +1,4 @@
import Link from 'next/link'
-import React from 'react'
import { useMediumGlobal } from '@/themes/medium'
import JumpToTopButton from './JumpToTopButton'
diff --git a/themes/medium/components/CategoryGroup.js b/themes/medium/components/CategoryGroup.js
index 1516c038..d562cd1f 100644
--- a/themes/medium/components/CategoryGroup.js
+++ b/themes/medium/components/CategoryGroup.js
@@ -1,4 +1,3 @@
-import React from 'react'
import CategoryItem from './CategoryItem'
const CategoryGroup = ({ currentCategory, categoryOptions }) => {
diff --git a/themes/medium/components/Footer.js b/themes/medium/components/Footer.js
index b65f8cd9..c7cd0590 100644
--- a/themes/medium/components/Footer.js
+++ b/themes/medium/components/Footer.js
@@ -1,4 +1,3 @@
-import React from 'react'
import BLOG from '@/blog.config'
import DarkModeButton from '@/components/DarkModeButton'
import { siteConfig } from '@/lib/config'
diff --git a/themes/medium/components/InfoCard.js b/themes/medium/components/InfoCard.js
index 60353a6f..6687aa04 100644
--- a/themes/medium/components/InfoCard.js
+++ b/themes/medium/components/InfoCard.js
@@ -1,7 +1,6 @@
import BLOG from '@/blog.config'
import LazyImage from '@/components/LazyImage'
import Router from 'next/router'
-import React from 'react'
import SocialButton from './SocialButton'
import { siteConfig } from '@/lib/config'
diff --git a/themes/medium/components/LeftMenuBar.js b/themes/medium/components/LeftMenuBar.js
index e6636e19..6bde6c51 100644
--- a/themes/medium/components/LeftMenuBar.js
+++ b/themes/medium/components/LeftMenuBar.js
@@ -1,5 +1,4 @@
import Link from 'next/link'
-import React from 'react'
export default function LeftMenuBar () {
return (
diff --git a/themes/medium/components/Progress.js b/themes/medium/components/Progress.js
index 62e1cc87..f6fa94a6 100644
--- a/themes/medium/components/Progress.js
+++ b/themes/medium/components/Progress.js
@@ -1,4 +1,4 @@
-import React, { useEffect, useState } from 'react'
+import { useEffect, useState } from 'react'
import { isBrowser } from '@/lib/utils'
/**
diff --git a/themes/nav/components/BlogPostCard.js b/themes/nav/components/BlogPostCard.js
index 127e2480..08cf87df 100755
--- a/themes/nav/components/BlogPostCard.js
+++ b/themes/nav/components/BlogPostCard.js
@@ -1,13 +1,11 @@
-import BLOG from '@/blog.config'
import Link from 'next/link'
import NotionIcon from './NotionIcon'
import { useRouter } from 'next/router'
-import React from 'react'
const BlogPostCard = ({ post, className }) => {
const router = useRouter()
const currentSelected = router.asPath.split('?')[0] === '/' + post.slug
- const pageIcon = post.pageIcon.indexOf("amazonaws.com")!=-1 ? post.pageIcon+"&width=88" : post.pageIcon
+ const pageIcon = post.pageIcon.indexOf('amazonaws.com') !== -1 ? post.pageIcon + '&width=88' : post.pageIcon
return (
@@ -23,9 +21,9 @@ const BlogPostCard = ({ post, className }) => {
)
function removeHttp(str) {
// 检查字符串是否包含http
- if (str.includes("http")) {
+ if (str.includes('http')) {
// 如果包含,找到http的位置
- let index = str.indexOf("http");
+ const index = str.indexOf('http');
// 返回http之后的部分
return str.slice(index, str.length);
} else {
@@ -35,11 +33,9 @@ const BlogPostCard = ({ post, className }) => {
}
function checkRemoveHttp(str) {
// 检查字符串是否包含http
- if (str.includes("http")) {
+ if (str.includes('http')) {
// 如果包含,找到http的位置
- let index = str.indexOf("http");
- // 包含
- return true;
+ return str.indexOf('http') > -1
} else {
// 不包含
return false;
diff --git a/themes/nav/components/BlogPostItem.js b/themes/nav/components/BlogPostItem.js
index 7500e8ff..d9532cb2 100755
--- a/themes/nav/components/BlogPostItem.js
+++ b/themes/nav/components/BlogPostItem.js
@@ -1,6 +1,4 @@
import BlogPostCard from './BlogPostCard'
-import React, { useState } from 'react'
-import NotionIcon from './NotionIcon'
// import Collapse from '@/components/Collapse'
/**
@@ -11,16 +9,11 @@ import NotionIcon from './NotionIcon'
* @constructor
*/
const BlogPostItem = (props) => {
- const { group, filterLinks } = props
-// const [isOpen, changeIsOpen] = useState(group?.selected)
-
-// const toggleOpenSubMenu = () => {
-// changeIsOpen(!isOpen)
-// }
+ const { group } = props
console.log('####### group')
console.log(group)
-
+
if (group?.category) {
return <>
diff --git a/themes/nav/components/BottomMenuBar.js b/themes/nav/components/BottomMenuBar.js
index 84a13f04..b91c9bc7 100755
--- a/themes/nav/components/BottomMenuBar.js
+++ b/themes/nav/components/BottomMenuBar.js
@@ -1,5 +1,4 @@
import { useNavGlobal } from '@/themes/nav'
-import React from 'react'
import JumpToTopButton from './JumpToTopButton'
export default function BottomMenuBar({ post, className }) {
diff --git a/themes/nav/components/CategoryGroup.js b/themes/nav/components/CategoryGroup.js
index 1516c038..d562cd1f 100755
--- a/themes/nav/components/CategoryGroup.js
+++ b/themes/nav/components/CategoryGroup.js
@@ -1,4 +1,3 @@
-import React from 'react'
import CategoryItem from './CategoryItem'
const CategoryGroup = ({ currentCategory, categoryOptions }) => {
diff --git a/themes/nav/components/Collapse.js b/themes/nav/components/Collapse.js
index caf86152..6a169aa2 100755
--- a/themes/nav/components/Collapse.js
+++ b/themes/nav/components/Collapse.js
@@ -1,4 +1,4 @@
-import React, { useEffect, useImperativeHandle } from 'react'
+import { useEffect, useImperativeHandle, useRef } from 'react'
/**
* 折叠面板组件,支持水平折叠、垂直折叠
@@ -7,7 +7,7 @@ import React, { useEffect, useImperativeHandle } from 'react'
*/
const Collapse = props => {
const { collapseRef } = props
- const ref = React.useRef(null)
+ const ref = useRef(null)
const type = props.type || 'vertical'
useImperativeHandle(collapseRef, () => {
diff --git a/themes/nav/components/LeftMenuBar.js b/themes/nav/components/LeftMenuBar.js
index e6636e19..6bde6c51 100755
--- a/themes/nav/components/LeftMenuBar.js
+++ b/themes/nav/components/LeftMenuBar.js
@@ -1,5 +1,4 @@
import Link from 'next/link'
-import React from 'react'
export default function LeftMenuBar () {
return (
diff --git a/themes/nav/components/NavPostItem.js b/themes/nav/components/NavPostItem.js
index ed869d69..32b22694 100755
--- a/themes/nav/components/NavPostItem.js
+++ b/themes/nav/components/NavPostItem.js
@@ -1,5 +1,5 @@
import BlogPostCard from './BlogPostCard'
-import React, { useState } from 'react'
+import { useState } from 'react'
import Collapse from '@/components/Collapse'
/**
diff --git a/themes/nav/components/Progress.js b/themes/nav/components/Progress.js
index 669d09a8..29feef49 100755
--- a/themes/nav/components/Progress.js
+++ b/themes/nav/components/Progress.js
@@ -1,4 +1,4 @@
-import React, { useEffect, useState } from 'react'
+import { useEffect, useState } from 'react'
import { isBrowser } from '@/lib/utils'
/**
diff --git a/themes/next/components/BlogPostArchive.js b/themes/next/components/BlogPostArchive.js
index b1f22296..ec56d7ce 100644
--- a/themes/next/components/BlogPostArchive.js
+++ b/themes/next/components/BlogPostArchive.js
@@ -1,6 +1,6 @@
-import React from 'react'
import Link from 'next/link'
import BLOG from '@/blog.config'
+
/**
* 博客归档列表
* @param posts 所有文章
diff --git a/themes/next/components/BlogPostCard.js b/themes/next/components/BlogPostCard.js
index 90224ecd..4c9286e9 100644
--- a/themes/next/components/BlogPostCard.js
+++ b/themes/next/components/BlogPostCard.js
@@ -2,7 +2,6 @@ import BLOG from '@/blog.config'
import { useGlobal } from '@/lib/global'
import Image from 'next/image'
import Link from 'next/link'
-import React from 'react'
import Card from './Card'
import TagItemMini from './TagItemMini'
import CONFIG from '../config'
diff --git a/themes/next/components/BlogPostListScroll.js b/themes/next/components/BlogPostListScroll.js
index e9124bc6..6ed6b1d4 100644
--- a/themes/next/components/BlogPostListScroll.js
+++ b/themes/next/components/BlogPostListScroll.js
@@ -3,7 +3,7 @@ import BlogPostCard from './BlogPostCard'
import BlogPostListEmpty from './BlogPostListEmpty'
import { useGlobal } from '@/lib/global'
import throttle from 'lodash.throttle'
-import React, { useCallback, useEffect, useRef, useState } from 'react'
+import { useCallback, useEffect, useRef, useState } from 'react'
import CONFIG from '../config'
/**
diff --git a/themes/next/components/CategoryGroup.js b/themes/next/components/CategoryGroup.js
index 8e24231a..872c4a28 100644
--- a/themes/next/components/CategoryGroup.js
+++ b/themes/next/components/CategoryGroup.js
@@ -1,5 +1,4 @@
import Link from 'next/link'
-import React from 'react'
const CategoryGroup = ({ currentCategory, categories }) => {
if (!categories) return <>>
diff --git a/themes/next/components/CategoryList.js b/themes/next/components/CategoryList.js
index fa466b05..af8e3b52 100644
--- a/themes/next/components/CategoryList.js
+++ b/themes/next/components/CategoryList.js
@@ -1,5 +1,4 @@
import Link from 'next/link'
-import React from 'react'
import { useGlobal } from '@/lib/global'
const CategoryList = ({ currentCategory, categoryOptions }) => {
diff --git a/themes/next/components/ContactButton.js b/themes/next/components/ContactButton.js
index b9e0a75b..bc95ab25 100644
--- a/themes/next/components/ContactButton.js
+++ b/themes/next/components/ContactButton.js
@@ -1,4 +1,3 @@
-import React from 'react'
import Link from 'next/link'
/**
diff --git a/themes/next/components/JumpToBottomButton.js b/themes/next/components/JumpToBottomButton.js
index cc624f2b..8cfc6a43 100644
--- a/themes/next/components/JumpToBottomButton.js
+++ b/themes/next/components/JumpToBottomButton.js
@@ -1,4 +1,4 @@
-import React, { useEffect, useState } from 'react'
+import { useEffect, useState } from 'react'
import CONFIG from '../config'
/**
diff --git a/themes/next/components/JumpToTopButton.js b/themes/next/components/JumpToTopButton.js
index 9629d65b..27521979 100644
--- a/themes/next/components/JumpToTopButton.js
+++ b/themes/next/components/JumpToTopButton.js
@@ -1,5 +1,4 @@
import { useGlobal } from '@/lib/global'
-import React from 'react'
import CONFIG from '../config'
/**
diff --git a/themes/next/components/LeftFloatButton.js b/themes/next/components/LeftFloatButton.js
index a84312da..bf303565 100644
--- a/themes/next/components/LeftFloatButton.js
+++ b/themes/next/components/LeftFloatButton.js
@@ -1,4 +1,4 @@
-import React, { useEffect, useState } from 'react'
+import { useEffect, useState } from 'react'
import throttle from 'lodash.throttle'
import DarkModeButton from './DarkModeButton'
diff --git a/themes/next/components/Logo.js b/themes/next/components/Logo.js
index 7306052f..45b26f4d 100644
--- a/themes/next/components/Logo.js
+++ b/themes/next/components/Logo.js
@@ -1,5 +1,4 @@
import Link from 'next/link'
-import React from 'react'
import { siteConfig } from '@/lib/config'
const Logo = props => {
diff --git a/themes/next/components/NextRecentComments.js b/themes/next/components/NextRecentComments.js
index 2564949e..45eb4409 100644
--- a/themes/next/components/NextRecentComments.js
+++ b/themes/next/components/NextRecentComments.js
@@ -1,4 +1,4 @@
-import React from 'react'
+import { useEffect, useState } from 'react'
import BLOG from '@/blog.config'
import Link from 'next/link'
import { RecentComments } from '@waline/client'
@@ -9,9 +9,9 @@ import { RecentComments } from '@waline/client'
* @returns
*/
const NextRecentComments = (props) => {
- const [comments, updateComments] = React.useState([])
- const [onLoading, changeLoading] = React.useState(true)
- React.useEffect(() => {
+ const [comments, updateComments] = useState([])
+ const [onLoading, changeLoading] = useState(true)
+ useEffect(() => {
RecentComments({
serverURL: BLOG.COMMENT_WALINE_SERVER_URL,
count: 5
diff --git a/themes/next/components/Progress.js b/themes/next/components/Progress.js
index 8eab47e9..bc206206 100644
--- a/themes/next/components/Progress.js
+++ b/themes/next/components/Progress.js
@@ -1,4 +1,4 @@
-import React, { useEffect, useState } from 'react'
+import { useEffect, useState } from 'react'
import { isBrowser } from '@/lib/utils'
/**
diff --git a/themes/next/components/RecommendPosts.js b/themes/next/components/RecommendPosts.js
index 1626f664..d3a2c3f0 100644
--- a/themes/next/components/RecommendPosts.js
+++ b/themes/next/components/RecommendPosts.js
@@ -1,4 +1,3 @@
-import React from 'react'
import Link from 'next/link'
import { useGlobal } from '@/lib/global'
import CONFIG from '../config'
@@ -7,10 +6,10 @@ import CONFIG from '../config'
* 展示文章推荐
*/
const RecommendPosts = ({ recommendPosts }) => {
+ const { locale } = useGlobal()
if (!CONFIG.ARTICLE_RELATE_POSTS || !recommendPosts || recommendPosts.length < 1) {
return <>>
}
- const { locale } = useGlobal()
return (
diff --git a/themes/next/components/RewardButton.js b/themes/next/components/RewardButton.js
index 44733d6d..fe3e10bb 100644
--- a/themes/next/components/RewardButton.js
+++ b/themes/next/components/RewardButton.js
@@ -1,4 +1,3 @@
-import React from 'react'
import Image from 'next/image'
/**
diff --git a/themes/next/components/SideAreaLeft.js b/themes/next/components/SideAreaLeft.js
index 0fb39643..0bd6290f 100644
--- a/themes/next/components/SideAreaLeft.js
+++ b/themes/next/components/SideAreaLeft.js
@@ -3,7 +3,6 @@ import { MenuList } from './MenuList'
import SearchInput from './SearchInput'
import Toc from './Toc'
import { useGlobal } from '@/lib/global'
-import React from 'react'
import Tabs from '@/components/Tabs'
import Logo from './Logo'
import Card from './Card'
diff --git a/themes/next/components/SideAreaRight.js b/themes/next/components/SideAreaRight.js
index ee694d35..397be4c7 100644
--- a/themes/next/components/SideAreaRight.js
+++ b/themes/next/components/SideAreaRight.js
@@ -1,6 +1,5 @@
import { useGlobal } from '@/lib/global'
import Link from 'next/link'
-import React from 'react'
import Card from './Card'
import CategoryGroup from './CategoryGroup'
import TagGroups from './TagGroups'
diff --git a/themes/next/components/SideBar.js b/themes/next/components/SideBar.js
index 3af651c5..27fe65b0 100644
--- a/themes/next/components/SideBar.js
+++ b/themes/next/components/SideBar.js
@@ -3,7 +3,6 @@ import InfoCard from './InfoCard'
import TagGroups from './TagGroups'
import { useGlobal } from '@/lib/global'
import Link from 'next/link'
-import React from 'react'
/**
* 侧边栏
diff --git a/themes/next/components/SideBarDrawer.js b/themes/next/components/SideBarDrawer.js
index 213269f4..999e6b80 100644
--- a/themes/next/components/SideBarDrawer.js
+++ b/themes/next/components/SideBarDrawer.js
@@ -1,6 +1,6 @@
import SideBar from './SideBar'
import { useRouter } from 'next/router'
-import React, { useEffect, useImperativeHandle } from 'react'
+import { useEffect, useImperativeHandle } from 'react'
/**
* 侧边栏抽屉面板,可以从侧面拉出
diff --git a/themes/next/components/TagItem.js b/themes/next/components/TagItem.js
index 85f6e0be..bb40a2f1 100644
--- a/themes/next/components/TagItem.js
+++ b/themes/next/components/TagItem.js
@@ -1,5 +1,4 @@
import Link from 'next/link'
-import React from 'react'
import { useGlobal } from '@/lib/global'
const TagItem = ({ tag, selected }) => {
diff --git a/themes/next/components/TagList.js b/themes/next/components/TagList.js
index 973e7b68..08d25add 100644
--- a/themes/next/components/TagList.js
+++ b/themes/next/components/TagList.js
@@ -1,5 +1,5 @@
-import React from 'react'
import TagItem from './TagItem'
+
/**
* 横向的标签列表
* @param tags
diff --git a/themes/next/components/Toc.js b/themes/next/components/Toc.js
index f734990d..077c9863 100644
--- a/themes/next/components/Toc.js
+++ b/themes/next/components/Toc.js
@@ -1,8 +1,7 @@
-import React, { useRef } from 'react'
+import { useCallback, useEffect, useRef, useState } from 'react'
import throttle from 'lodash.throttle'
import { uuidToId } from 'notion-utils'
import Progress from './Progress'
-// import { cs } from 'react-notion-x'
/**
* 目录导航组件
@@ -12,7 +11,7 @@ import Progress from './Progress'
*/
const Toc = ({ toc }) => {
// 监听滚动事件
- React.useEffect(() => {
+ useEffect(() => {
window.addEventListener('scroll', actionSectionScrollSpy)
actionSectionScrollSpy()
return () => {
@@ -25,9 +24,9 @@ const Toc = ({ toc }) => {
const tocIds = []
// 同步选中目录事件
- const [activeSection, setActiveSection] = React.useState(null)
+ const [activeSection, setActiveSection] = useState(null)
const throttleMs = 200
- const actionSectionScrollSpy = React.useCallback(throttle(() => {
+ const actionSectionScrollSpy = useCallback(throttle(() => {
const sections = document.getElementsByClassName('notion-h')
let prevBBox = null
let currentSectionId = activeSection
diff --git a/themes/next/components/TocDrawer.js b/themes/next/components/TocDrawer.js
index 83861934..33172166 100644
--- a/themes/next/components/TocDrawer.js
+++ b/themes/next/components/TocDrawer.js
@@ -1,5 +1,5 @@
import Toc from './Toc'
-import React, { useImperativeHandle, useState } from 'react'
+import { useImperativeHandle, useState } from 'react'
import { useGlobal } from '@/lib/global'
/**
diff --git a/themes/next/components/TocDrawerButton.js b/themes/next/components/TocDrawerButton.js
index fc8548e4..030b1d59 100644
--- a/themes/next/components/TocDrawerButton.js
+++ b/themes/next/components/TocDrawerButton.js
@@ -1,5 +1,4 @@
import { useGlobal } from '@/lib/global'
-import React from 'react'
import CONFIG from '../config'
/**
diff --git a/themes/nobelium/components/BlogListScroll.js b/themes/nobelium/components/BlogListScroll.js
index 90d1d0e1..79fa0252 100644
--- a/themes/nobelium/components/BlogListScroll.js
+++ b/themes/nobelium/components/BlogListScroll.js
@@ -4,13 +4,13 @@ import Link from 'next/link'
import throttle from 'lodash.throttle'
import { deepClone } from '@/lib/utils'
import { siteConfig } from '@/lib/config'
-import { useEffect } from 'react'
+import { useCallback, useEffect, useRef, useState } from 'react'
export const BlogListScroll = props => {
const { posts } = props
const { locale } = useGlobal()
- const [page, updatePage] = React.useState(1)
+ const [page, updatePage] = useState(1)
let hasMore = false
const postsToShow = posts && Array.isArray(posts)
@@ -26,10 +26,10 @@ export const BlogListScroll = props => {
updatePage(page + 1)
}
- const targetRef = React.useRef(null)
+ const targetRef = useRef(null)
// 监听滚动自动分页加载
- const scrollTrigger = React.useCallback(throttle(() => {
+ const scrollTrigger = useCallback(throttle(() => {
const scrollS = window.scrollY + window.outerHeight
const clientHeight = targetRef ? (targetRef.current ? (targetRef.current.clientHeight) : 0) : 0
if (scrollS > clientHeight + 100) {
diff --git a/themes/nobelium/components/ExampleRecentComments.js b/themes/nobelium/components/ExampleRecentComments.js
index b1555c1d..7e2c3517 100644
--- a/themes/nobelium/components/ExampleRecentComments.js
+++ b/themes/nobelium/components/ExampleRecentComments.js
@@ -1,4 +1,4 @@
-import React from 'react'
+import { useEffect, useState } from 'react'
import BLOG from '@/blog.config'
import Link from 'next/link'
import { RecentComments } from '@waline/client'
@@ -9,9 +9,9 @@ import { RecentComments } from '@waline/client'
* @returns
*/
const ExampleRecentComments = (props) => {
- const [comments, updateComments] = React.useState([])
- const [onLoading, changeLoading] = React.useState(true)
- React.useEffect(() => {
+ const [comments, updateComments] = useState([])
+ const [onLoading, changeLoading] = useState(true)
+ useEffect(() => {
RecentComments({
serverURL: BLOG.COMMENT_WALINE_SERVER_URL,
count: 5
diff --git a/themes/nobelium/components/JumpToTopButton.js b/themes/nobelium/components/JumpToTopButton.js
index 30e684a8..f5e22b61 100644
--- a/themes/nobelium/components/JumpToTopButton.js
+++ b/themes/nobelium/components/JumpToTopButton.js
@@ -1,5 +1,4 @@
import { useGlobal } from '@/lib/global'
-import React from 'react'
/**
* 跳转到网页顶部
diff --git a/themes/nobelium/index.js b/themes/nobelium/index.js
index 319cd37f..e2750ab4 100644
--- a/themes/nobelium/index.js
+++ b/themes/nobelium/index.js
@@ -1,6 +1,6 @@
import BLOG from '@/blog.config'
import CONFIG from './config'
-import React, { createContext, useEffect, useState, useContext, useRef } from 'react'
+import { createContext, useEffect, useState, useContext, useRef } from 'react'
import Nav from './components/Nav'
import { Footer } from './components/Footer'
import JumpToTopButton from './components/JumpToTopButton'
diff --git a/themes/plog/components/BlogListScroll.js b/themes/plog/components/BlogListScroll.js
index 809451f6..24b00b69 100644
--- a/themes/plog/components/BlogListScroll.js
+++ b/themes/plog/components/BlogListScroll.js
@@ -1,7 +1,7 @@
import BLOG from '@/blog.config'
import { useGlobal } from '@/lib/global'
import Link from 'next/link'
-import React from 'react'
+import { useCallback, useEffect, useRef, useState } from 'react'
import throttle from 'lodash.throttle'
import { siteConfig } from '@/lib/config'
@@ -9,7 +9,7 @@ export const BlogListScroll = props => {
const { posts } = props
const { locale } = useGlobal()
- const [page, updatePage] = React.useState(1)
+ const [page, updatePage] = useState(1)
let hasMore = false
const postsToShow = posts
@@ -25,10 +25,10 @@ export const BlogListScroll = props => {
updatePage(page + 1)
}
- const targetRef = React.useRef(null)
+ const targetRef = useRef(null)
// 监听滚动自动分页加载
- const scrollTrigger = React.useCallback(throttle(() => {
+ const scrollTrigger = useCallback(throttle(() => {
const scrollS = window.scrollY + window.outerHeight
const clientHeight = targetRef ? (targetRef.current ? (targetRef.current.clientHeight) : 0) : 0
if (scrollS > clientHeight + 100) {
@@ -36,7 +36,7 @@ export const BlogListScroll = props => {
}
}, 500))
- React.useEffect(() => {
+ useEffect(() => {
window.addEventListener('scroll', scrollTrigger)
return () => {
diff --git a/themes/plog/components/ExampleRecentComments.js b/themes/plog/components/ExampleRecentComments.js
index b1555c1d..7e2c3517 100644
--- a/themes/plog/components/ExampleRecentComments.js
+++ b/themes/plog/components/ExampleRecentComments.js
@@ -1,4 +1,4 @@
-import React from 'react'
+import { useEffect, useState } from 'react'
import BLOG from '@/blog.config'
import Link from 'next/link'
import { RecentComments } from '@waline/client'
@@ -9,9 +9,9 @@ import { RecentComments } from '@waline/client'
* @returns
*/
const ExampleRecentComments = (props) => {
- const [comments, updateComments] = React.useState([])
- const [onLoading, changeLoading] = React.useState(true)
- React.useEffect(() => {
+ const [comments, updateComments] = useState([])
+ const [onLoading, changeLoading] = useState(true)
+ useEffect(() => {
RecentComments({
serverURL: BLOG.COMMENT_WALINE_SERVER_URL,
count: 5
diff --git a/themes/plog/components/JumpToTopButton.js b/themes/plog/components/JumpToTopButton.js
index 30e684a8..f5e22b61 100644
--- a/themes/plog/components/JumpToTopButton.js
+++ b/themes/plog/components/JumpToTopButton.js
@@ -1,5 +1,4 @@
import { useGlobal } from '@/lib/global'
-import React from 'react'
/**
* 跳转到网页顶部
diff --git a/themes/simple/components/BlogListScroll.js b/themes/simple/components/BlogListScroll.js
index dc0b7dd3..c81b2f80 100644
--- a/themes/simple/components/BlogListScroll.js
+++ b/themes/simple/components/BlogListScroll.js
@@ -1,6 +1,6 @@
import BLOG from '@/blog.config'
import { useGlobal } from '@/lib/global'
-import React from 'react'
+import { useCallback, useEffect, useRef, useState } from 'react'
import throttle from 'lodash.throttle'
import { BlogItem } from './BlogItem'
@@ -8,7 +8,7 @@ export const BlogListScroll = props => {
const { posts } = props
const { locale } = useGlobal()
- const [page, updatePage] = React.useState(1)
+ const [page, updatePage] = useState(1)
let hasMore = false
const postsToShow = posts
@@ -24,10 +24,10 @@ export const BlogListScroll = props => {
updatePage(page + 1)
}
- const targetRef = React.useRef(null)
+ const targetRef = useRef(null)
// 监听滚动自动分页加载
- const scrollTrigger = React.useCallback(throttle(() => {
+ const scrollTrigger = useCallback(throttle(() => {
const scrollS = window.scrollY + window.outerHeight
const clientHeight = targetRef ? (targetRef.current ? (targetRef.current.clientHeight) : 0) : 0
if (scrollS > clientHeight + 100) {
@@ -35,7 +35,7 @@ export const BlogListScroll = props => {
}
}, 500))
- React.useEffect(() => {
+ useEffect(() => {
window.addEventListener('scroll', scrollTrigger)
return () => {
diff --git a/themes/simple/components/ExampleRecentComments.js b/themes/simple/components/ExampleRecentComments.js
index b1555c1d..d2a4d7a2 100644
--- a/themes/simple/components/ExampleRecentComments.js
+++ b/themes/simple/components/ExampleRecentComments.js
@@ -1,7 +1,7 @@
-import React from 'react'
import BLOG from '@/blog.config'
import Link from 'next/link'
import { RecentComments } from '@waline/client'
+import { useEffect, useState } from 'react'
/**
* @see https://waline.js.org/guide/get-started.html
@@ -9,9 +9,9 @@ import { RecentComments } from '@waline/client'
* @returns
*/
const ExampleRecentComments = (props) => {
- const [comments, updateComments] = React.useState([])
- const [onLoading, changeLoading] = React.useState(true)
- React.useEffect(() => {
+ const [comments, updateComments] = useState([])
+ const [onLoading, changeLoading] = useState(true)
+ useEffect(() => {
RecentComments({
serverURL: BLOG.COMMENT_WALINE_SERVER_URL,
count: 5
diff --git a/themes/simple/components/JumpToTopButton.js b/themes/simple/components/JumpToTopButton.js
index 2ed28ab4..358c9372 100644
--- a/themes/simple/components/JumpToTopButton.js
+++ b/themes/simple/components/JumpToTopButton.js
@@ -1,5 +1,5 @@
import { useGlobal } from '@/lib/global'
-import React from 'react'
+import { useEffect, useState } from 'react'
/**
* 跳转到网页顶部
@@ -11,7 +11,7 @@ import React from 'react'
*/
const JumpToTopButton = () => {
const { locale } = useGlobal()
- const [show, switchShow] = React.useState(false)
+ const [show, switchShow] = useState(false)
const scrollListener = () => {
const scrollY = window.pageYOffset
const shouldShow = scrollY > 200
@@ -20,7 +20,7 @@ const JumpToTopButton = () => {
}
}
- React.useEffect(() => {
+ useEffect(() => {
document.addEventListener('scroll', scrollListener)
return () => document.removeEventListener('scroll', scrollListener)
}, [show])