build React.

This commit is contained in:
tangly1024.com
2023-11-06 14:20:43 +08:00
parent 0a6c59ed7b
commit ecf7825dad
117 changed files with 121 additions and 206 deletions

View File

@@ -1,4 +1,3 @@
import React from 'react'
import Link from 'next/link' import Link from 'next/link'
import BLOG from '@/blog.config' import BLOG from '@/blog.config'
/** /**

View File

@@ -2,9 +2,9 @@ import BLOG from '@/blog.config'
import ProductCard from './ProductCard' import ProductCard from './ProductCard'
import BlogPostListEmpty from './BlogPostListEmpty' import BlogPostListEmpty from './BlogPostListEmpty'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import React from 'react'
import CONFIG from '../config' import CONFIG from '../config'
import { getListByPage } from '@/lib/utils' 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 BlogPostListScroll = ({ posts = [], currentSearch, showSummary = CONFIG.POST_LIST_SUMMARY, siteInfo }) => {
const postsPerPage = BLOG.POSTS_PER_PAGE const postsPerPage = BLOG.POSTS_PER_PAGE
const [page, updatePage] = React.useState(1) const [page, updatePage] = useState(1)
const postsToShow = getListByPage(posts, page, postsPerPage) const postsToShow = getListByPage(posts, page, postsPerPage)
let hasMore = false let hasMore = false
@@ -41,14 +41,14 @@ const BlogPostListScroll = ({ posts = [], currentSearch, showSummary = CONFIG.PO
} }
// 监听滚动 // 监听滚动
React.useEffect(() => { useEffect(() => {
window.addEventListener('scroll', scrollTrigger) window.addEventListener('scroll', scrollTrigger)
return () => { return () => {
window.removeEventListener('scroll', scrollTrigger) window.removeEventListener('scroll', scrollTrigger)
} }
}) })
const targetRef = React.useRef(null) const targetRef = useRef(null)
const { locale } = useGlobal() const { locale } = useGlobal()
if (!postsToShow || postsToShow.length === 0) { if (!postsToShow || postsToShow.length === 0) {

View File

@@ -1,5 +1,4 @@
import Link from 'next/link' import Link from 'next/link'
import React from 'react'
const CategoryGroup = ({ currentCategory, categories }) => { const CategoryGroup = ({ currentCategory, categories }) => {
if (!categories) { if (!categories) {

View File

@@ -1,4 +1,3 @@
import React from 'react'
import { siteConfig } from '@/lib/config' import { siteConfig } from '@/lib/config'
import Link from 'next/link' import Link from 'next/link'

View File

@@ -1,4 +1,4 @@
import React from 'react' import { useEffect, useState } from 'react'
import BLOG from '@/blog.config' import BLOG from '@/blog.config'
import Card from '@/themes/hexo/components/Card' import Card from '@/themes/hexo/components/Card'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
@@ -11,10 +11,10 @@ import { RecentComments } from '@waline/client'
* @returns * @returns
*/ */
const HexoRecentComments = (props) => { const HexoRecentComments = (props) => {
const [comments, updateComments] = React.useState([]) const [comments, updateComments] = useState([])
const { locale } = useGlobal() const { locale } = useGlobal()
const [onLoading, changeLoading] = React.useState(true) const [onLoading, changeLoading] = useState(true)
React.useEffect(() => { useEffect(() => {
RecentComments({ RecentComments({
serverURL: BLOG.COMMENT_WALINE_SERVER_URL, serverURL: BLOG.COMMENT_WALINE_SERVER_URL,
count: 5 count: 5

View File

@@ -1,4 +1,3 @@
import React from 'react'
import CONFIG from '../config' import CONFIG from '../config'
/** /**

View File

@@ -1,5 +1,4 @@
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import React from 'react'
import CONFIG from '../config' import CONFIG from '../config'
/** /**

View File

@@ -1,4 +1,3 @@
import React from 'react'
import Link from 'next/link' import Link from 'next/link'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import CONFIG from '../config' import CONFIG from '../config'

View File

@@ -1,5 +1,3 @@
import React from 'react'
import Link from 'next/link' import Link from 'next/link'
/** /**

View File

@@ -1,5 +1,4 @@
import Link from 'next/link' import Link from 'next/link'
import React from 'react'
import CONFIG from '../config' import CONFIG from '../config'
import BLOG from '@/blog.config' import BLOG from '@/blog.config'
import LazyImage from '@/components/LazyImage' import LazyImage from '@/components/LazyImage'

View File

@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { isBrowser } from '@/lib/utils' import { isBrowser } from '@/lib/utils'
/** /**

View File

@@ -1,5 +1,5 @@
import Catalog from './Catalog' import Catalog from './Catalog'
import React, { useImperativeHandle, useState } from 'react' import { useImperativeHandle, useState } from 'react'
/** /**
* 目录抽屉栏 * 目录抽屉栏

View File

@@ -1,5 +1,4 @@
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import React from 'react'
import CONFIG from '../config' import CONFIG from '../config'
/** /**

View File

@@ -1,6 +1,6 @@
import BLOG from '@/blog.config' import BLOG from '@/blog.config'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import React, { useEffect } from 'react' import { useCallback, useEffect, useRef, useState } from 'react'
import throttle from 'lodash.throttle' import throttle from 'lodash.throttle'
import BlogPostCard from './BlogPostCard' import BlogPostCard from './BlogPostCard'
import CONFIG from '../config' import CONFIG from '../config'
@@ -9,7 +9,7 @@ export const BlogListScroll = props => {
const { posts } = props const { posts } = props
const { locale } = useGlobal() const { locale } = useGlobal()
const [page, updatePage] = React.useState(1) const [page, updatePage] = useState(1)
let hasMore = false let hasMore = false
const postsToShow = posts const postsToShow = posts
@@ -25,10 +25,10 @@ export const BlogListScroll = props => {
updatePage(page + 1) 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 scrollS = window.scrollY + window.outerHeight
const clientHeight = targetRef ? (targetRef.current ? (targetRef.current.clientHeight) : 0) : 0 const clientHeight = targetRef ? (targetRef.current ? (targetRef.current.clientHeight) : 0) : 0
if (scrollS > clientHeight + 100) { if (scrollS > clientHeight + 100) {

View File

@@ -1,4 +1,4 @@
import React from 'react' import { useEffect, useState } from 'react'
import BLOG from '@/blog.config' import BLOG from '@/blog.config'
import Link from 'next/link' import Link from 'next/link'
import { RecentComments } from '@waline/client' import { RecentComments } from '@waline/client'
@@ -9,9 +9,9 @@ import { RecentComments } from '@waline/client'
* @returns * @returns
*/ */
const ExampleRecentComments = (props) => { const ExampleRecentComments = (props) => {
const [comments, updateComments] = React.useState([]) const [comments, updateComments] = useState([])
const [onLoading, changeLoading] = React.useState(true) const [onLoading, changeLoading] = useState(true)
React.useEffect(() => { useEffect(() => {
RecentComments({ RecentComments({
serverURL: BLOG.COMMENT_WALINE_SERVER_URL, serverURL: BLOG.COMMENT_WALINE_SERVER_URL,
count: 5 count: 5

View File

@@ -1,5 +1,4 @@
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import React from 'react'
/** /**
* 跳转到网页顶部 * 跳转到网页顶部

View File

@@ -1,7 +1,6 @@
import BLOG from '@/blog.config' import BLOG from '@/blog.config'
import Link from 'next/link' import Link from 'next/link'
import TagItemMini from './TagItemMini' import TagItemMini from './TagItemMini'
import React from 'react'
import CONFIG_FUKA from '../config' import CONFIG_FUKA from '../config'
import LazyImage from '@/components/LazyImage' import LazyImage from '@/components/LazyImage'

View File

@@ -1,5 +1,5 @@
import BLOG from '@/blog.config' import BLOG from '@/blog.config'
import React from 'react' import { useEffect, useRef, useState } from 'react'
import BlogCard from './BlogCard' import BlogCard from './BlogCard'
import BlogPostListEmpty from './BlogListEmpty' import BlogPostListEmpty from './BlogListEmpty'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
@@ -15,9 +15,9 @@ import { useGlobal } from '@/lib/global'
const BlogListScroll = props => { const BlogListScroll = props => {
const { posts = [], siteInfo } = props const { posts = [], siteInfo } = props
const { locale } = useGlobal() 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 let hasMore = false
const postsToShow = posts const postsToShow = posts
@@ -44,7 +44,7 @@ const BlogListScroll = props => {
}) })
} }
React.useEffect(() => { useEffect(() => {
window.addEventListener('scroll', scrollTrigger) window.addEventListener('scroll', scrollTrigger)
return () => { return () => {
window.removeEventListener('scroll', scrollTrigger) window.removeEventListener('scroll', scrollTrigger)

View File

@@ -1,4 +1,3 @@
import React from 'react'
import Link from 'next/link' import Link from 'next/link'
import BLOG from '@/blog.config' import BLOG from '@/blog.config'
/** /**

View File

@@ -1,4 +1,4 @@
import React, { useEffect, useRef, useState } from 'react' import { useEffect, useRef, useState } from 'react'
import throttle from 'lodash.throttle' import throttle from 'lodash.throttle'
import { uuidToId } from 'notion-utils' import { uuidToId } from 'notion-utils'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'

View File

@@ -1,5 +1,4 @@
import Link from 'next/link' import Link from 'next/link'
import React from 'react'
function GroupCategory ({ currentCategory, categories }) { function GroupCategory ({ currentCategory, categories }) {
if (!categories) { if (!categories) {

View File

@@ -1,5 +1,4 @@
import Link from 'next/link' import Link from 'next/link'
import React from 'react'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
const TagItem = ({ tag, selected }) => { const TagItem = ({ tag, selected }) => {

View File

@@ -1,7 +1,6 @@
import BLOG from '@/blog.config' import BLOG from '@/blog.config'
import Link from 'next/link' import Link from 'next/link'
import { useRouter } from 'next/router' import { useRouter } from 'next/router'
import React from 'react'
const BlogPostCard = ({ post, className }) => { const BlogPostCard = ({ post, className }) => {
const router = useRouter() const router = useRouter()

View File

@@ -1,5 +1,4 @@
import { useGitBookGlobal } from '@/themes/gitbook' import { useGitBookGlobal } from '@/themes/gitbook'
import React from 'react'
import JumpToTopButton from './JumpToTopButton' import JumpToTopButton from './JumpToTopButton'
export default function BottomMenuBar({ post, className }) { export default function BottomMenuBar({ post, className }) {

View File

@@ -1,4 +1,4 @@
import React from 'react'
import CategoryItem from './CategoryItem' import CategoryItem from './CategoryItem'
const CategoryGroup = ({ currentCategory, categoryOptions }) => { const CategoryGroup = ({ currentCategory, categoryOptions }) => {

View File

@@ -1,4 +1,4 @@
import React from 'react'
import BLOG from '@/blog.config' import BLOG from '@/blog.config'
import { siteConfig } from '@/lib/config' import { siteConfig } from '@/lib/config'

View File

@@ -1,5 +1,4 @@
import Link from 'next/link' import Link from 'next/link'
import React from 'react'
export default function LeftMenuBar () { export default function LeftMenuBar () {
return ( return (

View File

@@ -1,5 +1,5 @@
import BlogPostCard from './BlogPostCard' import BlogPostCard from './BlogPostCard'
import React, { useState } from 'react' import { useState } from 'react'
import Collapse from '@/components/Collapse' import Collapse from '@/components/Collapse'
/** /**

View File

@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { isBrowser } from '@/lib/utils' import { isBrowser } from '@/lib/utils'
/** /**

View File

@@ -1,4 +1,3 @@
import React from 'react'
import Link from 'next/link' import Link from 'next/link'
import BLOG from '@/blog.config' import BLOG from '@/blog.config'
import CONFIG from '../config' import CONFIG from '../config'

View File

@@ -2,7 +2,7 @@ import BLOG from '@/blog.config'
import BlogPostCard from './BlogPostCard' import BlogPostCard from './BlogPostCard'
import BlogPostListEmpty from './BlogPostListEmpty' import BlogPostListEmpty from './BlogPostListEmpty'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import React, { useEffect, useRef, useState } from 'react' import { useEffect, useRef, useState } from 'react'
import CONFIG from '../config' import CONFIG from '../config'
import { getListByPage } from '@/lib/utils' import { getListByPage } from '@/lib/utils'

View File

@@ -1,5 +1,4 @@
import Link from 'next/link' import Link from 'next/link'
import React from 'react'
const CategoryGroup = ({ currentCategory, categories }) => { const CategoryGroup = ({ currentCategory, categories }) => {
if (!categories) { if (!categories) {

View File

@@ -1,4 +1,3 @@
import React from 'react'
import BLOG from '@/blog.config' import BLOG from '@/blog.config'
import SocialButton from './SocialButton' import SocialButton from './SocialButton'
import { siteConfig } from '@/lib/config' import { siteConfig } from '@/lib/config'

View File

@@ -1,9 +1,9 @@
import React from 'react'
import BLOG from '@/blog.config' import BLOG from '@/blog.config'
import Card from '@/themes/hexo/components/Card' import Card from '@/themes/hexo/components/Card'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import Link from 'next/link' import Link from 'next/link'
import { RecentComments } from '@waline/client' import { RecentComments } from '@waline/client'
import { useEffect, useState } from 'react'
/** /**
* @see https://waline.js.org/guide/get-started.html * @see https://waline.js.org/guide/get-started.html
@@ -11,10 +11,10 @@ import { RecentComments } from '@waline/client'
* @returns * @returns
*/ */
const HexoRecentComments = (props) => { const HexoRecentComments = (props) => {
const [comments, updateComments] = React.useState([]) const [comments, updateComments] = useState([])
const { locale } = useGlobal() const { locale } = useGlobal()
const [onLoading, changeLoading] = React.useState(true) const [onLoading, changeLoading] = useState(true)
React.useEffect(() => { useEffect(() => {
RecentComments({ RecentComments({
serverURL: BLOG.COMMENT_WALINE_SERVER_URL, serverURL: BLOG.COMMENT_WALINE_SERVER_URL,
count: 5 count: 5

View File

@@ -1,4 +1,3 @@
import React from 'react'
import CONFIG from '../config' import CONFIG from '../config'
/** /**

View File

@@ -1,5 +1,4 @@
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import React from 'react'
import CONFIG from '../config' import CONFIG from '../config'
/** /**

View File

@@ -1,4 +1,3 @@
import React from 'react'
import Link from 'next/link' import Link from 'next/link'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import CONFIG from '../config' import CONFIG from '../config'

View File

@@ -1,5 +1,3 @@
import React from 'react'
import Link from 'next/link' import Link from 'next/link'
/** /**

View File

@@ -1,5 +1,4 @@
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import React from 'react'
import CONFIG from '../config' import CONFIG from '../config'
/** /**

View File

@@ -1,4 +1,3 @@
import React from 'react'
import Link from 'next/link' import Link from 'next/link'
import BLOG from '@/blog.config' import BLOG from '@/blog.config'
/** /**

View File

@@ -1,5 +1,4 @@
import Link from 'next/link' import Link from 'next/link'
import React from 'react'
import CONFIG from '../config' import CONFIG from '../config'
import { BlogPostCardInfo } from './BlogPostCardInfo' import { BlogPostCardInfo } from './BlogPostCardInfo'
import BLOG from '@/blog.config' import BLOG from '@/blog.config'

View File

@@ -2,7 +2,7 @@ import BLOG from '@/blog.config'
import BlogPostCard from './BlogPostCard' import BlogPostCard from './BlogPostCard'
import BlogPostListEmpty from './BlogPostListEmpty' import BlogPostListEmpty from './BlogPostListEmpty'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import React from 'react' import { useEffect, useRef, useState } from 'react'
import CONFIG from '../config' import CONFIG from '../config'
import { getListByPage } from '@/lib/utils' 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 BlogPostListScroll = ({ posts = [], currentSearch, showSummary = CONFIG.POST_LIST_SUMMARY, siteInfo }) => {
const postsPerPage = BLOG.POSTS_PER_PAGE const postsPerPage = BLOG.POSTS_PER_PAGE
const [page, updatePage] = React.useState(1) const [page, updatePage] = useState(1)
const postsToShow = getListByPage(posts, page, postsPerPage) const postsToShow = getListByPage(posts, page, postsPerPage)
let hasMore = false let hasMore = false
@@ -41,14 +41,14 @@ const BlogPostListScroll = ({ posts = [], currentSearch, showSummary = CONFIG.PO
} }
// 监听滚动 // 监听滚动
React.useEffect(() => { useEffect(() => {
window.addEventListener('scroll', scrollTrigger) window.addEventListener('scroll', scrollTrigger)
return () => { return () => {
window.removeEventListener('scroll', scrollTrigger) window.removeEventListener('scroll', scrollTrigger)
} }
}) })
const targetRef = React.useRef(null) const targetRef = useRef(null)
const { locale } = useGlobal() const { locale } = useGlobal()
if (!postsToShow || postsToShow.length === 0) { if (!postsToShow || postsToShow.length === 0) {

View File

@@ -1,5 +1,4 @@
import Link from 'next/link' import Link from 'next/link'
import React from 'react'
const CategoryGroup = ({ currentCategory, categories }) => { const CategoryGroup = ({ currentCategory, categories }) => {
if (!categories) { if (!categories) {

View File

@@ -1,4 +1,3 @@
import React from 'react'
import BLOG from '@/blog.config' import BLOG from '@/blog.config'
import { siteConfig } from '@/lib/config' import { siteConfig } from '@/lib/config'

View File

@@ -1,4 +1,4 @@
import React from 'react' import { useEffect, useState } from 'react'
import BLOG from '@/blog.config' import BLOG from '@/blog.config'
import Card from '@/themes/hexo/components/Card' import Card from '@/themes/hexo/components/Card'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
@@ -11,10 +11,10 @@ import { RecentComments } from '@waline/client'
* @returns * @returns
*/ */
const HexoRecentComments = (props) => { const HexoRecentComments = (props) => {
const [comments, updateComments] = React.useState([]) const [comments, updateComments] = useState([])
const { locale } = useGlobal() const { locale } = useGlobal()
const [onLoading, changeLoading] = React.useState(true) const [onLoading, changeLoading] = useState(true)
React.useEffect(() => { useEffect(() => {
RecentComments({ RecentComments({
serverURL: BLOG.COMMENT_WALINE_SERVER_URL, serverURL: BLOG.COMMENT_WALINE_SERVER_URL,
count: 5 count: 5

View File

@@ -1,4 +1,3 @@
import React from 'react'
import CONFIG from '../config' import CONFIG from '../config'
/** /**

View File

@@ -1,5 +1,4 @@
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import React from 'react'
import CONFIG from '../config' import CONFIG from '../config'
/** /**

View File

@@ -1,6 +1,5 @@
import BLOG from '@/blog.config' import BLOG from '@/blog.config'
import Link from 'next/link' import Link from 'next/link'
import React from 'react'
import { siteConfig } from '@/lib/config' import { siteConfig } from '@/lib/config'
const Logo = props => { const Logo = props => {

View File

@@ -1,4 +1,3 @@
import React from 'react'
import Link from 'next/link' import Link from 'next/link'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import CONFIG from '../config' import CONFIG from '../config'

View File

@@ -1,5 +1,3 @@
import React from 'react'
import Link from 'next/link' import Link from 'next/link'
/** /**

View File

@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { isBrowser } from '@/lib/utils' import { isBrowser } from '@/lib/utils'
/** /**

View File

@@ -1,5 +1,5 @@
import Catalog from './Catalog' import Catalog from './Catalog'
import React, { useImperativeHandle, useState } from 'react' import { useImperativeHandle, useState } from 'react'
/** /**
* 目录抽屉栏 * 目录抽屉栏

View File

@@ -1,5 +1,4 @@
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import React from 'react'
import CONFIG from '../config' import CONFIG from '../config'
/** /**

View File

@@ -1,6 +1,6 @@
import React from 'react'
import Link from 'next/link' import Link from 'next/link'
import BLOG from '@/blog.config' import BLOG from '@/blog.config'
/** /**
* 博客归档列表 * 博客归档列表
* @param posts 所有文章 * @param posts 所有文章

View File

@@ -1,6 +1,5 @@
import BLOG from '@/blog.config' import BLOG from '@/blog.config'
import Link from 'next/link' import Link from 'next/link'
import React from 'react'
import TagItemMini from './TagItemMini' import TagItemMini from './TagItemMini'
import CONFIG from '../config' import CONFIG from '../config'
import TwikooCommentCount from '@/components/TwikooCommentCount' import TwikooCommentCount from '@/components/TwikooCommentCount'

View File

@@ -2,7 +2,7 @@ import BLOG from '@/blog.config'
import BlogPostCard from './BlogPostCard' import BlogPostCard from './BlogPostCard'
import BlogPostListEmpty from './BlogPostListEmpty' import BlogPostListEmpty from './BlogPostListEmpty'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import React, { useCallback } from 'react' import { useCallback, useEffect, useRef, useState } from 'react'
import CONFIG from '../config' import CONFIG from '../config'
import { getListByPage } from '@/lib/utils' import { getListByPage } from '@/lib/utils'
import throttle from 'lodash.throttle' 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 BlogPostListScroll = ({ posts = [], currentSearch, showSummary = CONFIG.POST_LIST_SUMMARY, siteInfo }) => {
const postsPerPage = BLOG.POSTS_PER_PAGE const postsPerPage = BLOG.POSTS_PER_PAGE
const [page, updatePage] = React.useState(1) const [page, updatePage] = useState(1)
const postsToShow = getListByPage(posts, page, postsPerPage) 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 let hasMore = false
if (posts) { if (posts) {
const totalCount = posts.length const totalCount = posts.length
@@ -40,16 +49,6 @@ const BlogPostListScroll = ({ posts = [], currentSearch, showSummary = CONFIG.PO
} }
}) })
}, throttleMs)) }, 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) { if (!postsToShow || postsToShow.length === 0) {
return <BlogPostListEmpty currentSearch={currentSearch} /> return <BlogPostListEmpty currentSearch={currentSearch} />

View File

@@ -1,5 +1,4 @@
import Link from 'next/link' import Link from 'next/link'
import React from 'react'
const CategoryGroup = ({ currentCategory, categories }) => { const CategoryGroup = ({ currentCategory, categories }) => {
if (!categories) { if (!categories) {

View File

@@ -1,4 +1,3 @@
import React from 'react'
import BLOG from '@/blog.config' import BLOG from '@/blog.config'
import { siteConfig } from '@/lib/config' import { siteConfig } from '@/lib/config'

View File

@@ -1,4 +1,4 @@
import React from 'react' import { useEffect, useState } from 'react'
import BLOG from '@/blog.config' import BLOG from '@/blog.config'
import Card from '@/themes/hexo/components/Card' import Card from '@/themes/hexo/components/Card'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
@@ -11,10 +11,10 @@ import { RecentComments } from '@waline/client'
* @returns * @returns
*/ */
const HexoRecentComments = (props) => { const HexoRecentComments = (props) => {
const [comments, updateComments] = React.useState([]) const [comments, updateComments] = useState([])
const { locale } = useGlobal() const { locale } = useGlobal()
const [onLoading, changeLoading] = React.useState(true) const [onLoading, changeLoading] = useState(true)
React.useEffect(() => { useEffect(() => {
RecentComments({ RecentComments({
serverURL: BLOG.COMMENT_WALINE_SERVER_URL, serverURL: BLOG.COMMENT_WALINE_SERVER_URL,
count: 5 count: 5

View File

@@ -1,4 +1,3 @@
import React from 'react'
import CONFIG from '../config' import CONFIG from '../config'
/** /**

View File

@@ -1,5 +1,4 @@
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import React from 'react'
import CONFIG from '../config' import CONFIG from '../config'
/** /**

View File

@@ -1,6 +1,6 @@
import BLOG from '@/blog.config' import BLOG from '@/blog.config'
import Link from 'next/link' import Link from 'next/link'
import React from 'react'
import { siteConfig } from '@/lib/config' import { siteConfig } from '@/lib/config'
const Logo = props => { const Logo = props => {

View File

@@ -1,4 +1,3 @@
import React from 'react'
import Link from 'next/link' import Link from 'next/link'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import CONFIG from '../config' import CONFIG from '../config'

View File

@@ -1,4 +1,3 @@
import React from 'react'
import Link from 'next/link' import Link from 'next/link'
import { useRouter } from 'next/router' import { useRouter } from 'next/router'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'

View File

@@ -1,5 +1,3 @@
import React from 'react'
import Link from 'next/link' import Link from 'next/link'
/** /**

View File

@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { isBrowser } from '@/lib/utils' import { isBrowser } from '@/lib/utils'
/** /**

View File

@@ -1,5 +1,5 @@
import Catalog from './Catalog' import Catalog from './Catalog'
import React, { useImperativeHandle, useState } from 'react' import { useImperativeHandle, useState } from 'react'
/** /**
* 目录抽屉栏 * 目录抽屉栏

View File

@@ -1,5 +1,4 @@
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import React from 'react'
import CONFIG from '../config' import CONFIG from '../config'
/** /**

View File

@@ -2,7 +2,6 @@ import BLOG from '@/blog.config'
import NotionPage from '@/components/NotionPage' import NotionPage from '@/components/NotionPage'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import Link from 'next/link' import Link from 'next/link'
import React from 'react'
import CONFIG from '../config' import CONFIG from '../config'
import CategoryItem from './CategoryItem' import CategoryItem from './CategoryItem'
import TagItemMini from './TagItemMini' import TagItemMini from './TagItemMini'

View File

@@ -3,7 +3,7 @@ import BlogPostCard from './BlogPostCard'
import BlogPostListEmpty from './BlogPostListEmpty' import BlogPostListEmpty from './BlogPostListEmpty'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import throttle from 'lodash.throttle' 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' import { useRouter } from 'next/router'
/** /**

View File

@@ -1,5 +1,4 @@
import Link from 'next/link' import Link from 'next/link'
import React from 'react'
import { useMediumGlobal } from '@/themes/medium' import { useMediumGlobal } from '@/themes/medium'
import JumpToTopButton from './JumpToTopButton' import JumpToTopButton from './JumpToTopButton'

View File

@@ -1,4 +1,3 @@
import React from 'react'
import CategoryItem from './CategoryItem' import CategoryItem from './CategoryItem'
const CategoryGroup = ({ currentCategory, categoryOptions }) => { const CategoryGroup = ({ currentCategory, categoryOptions }) => {

View File

@@ -1,4 +1,3 @@
import React from 'react'
import BLOG from '@/blog.config' import BLOG from '@/blog.config'
import DarkModeButton from '@/components/DarkModeButton' import DarkModeButton from '@/components/DarkModeButton'
import { siteConfig } from '@/lib/config' import { siteConfig } from '@/lib/config'

View File

@@ -1,7 +1,6 @@
import BLOG from '@/blog.config' import BLOG from '@/blog.config'
import LazyImage from '@/components/LazyImage' import LazyImage from '@/components/LazyImage'
import Router from 'next/router' import Router from 'next/router'
import React from 'react'
import SocialButton from './SocialButton' import SocialButton from './SocialButton'
import { siteConfig } from '@/lib/config' import { siteConfig } from '@/lib/config'

View File

@@ -1,5 +1,4 @@
import Link from 'next/link' import Link from 'next/link'
import React from 'react'
export default function LeftMenuBar () { export default function LeftMenuBar () {
return ( return (

View File

@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { isBrowser } from '@/lib/utils' import { isBrowser } from '@/lib/utils'
/** /**

View File

@@ -1,13 +1,11 @@
import BLOG from '@/blog.config'
import Link from 'next/link' import Link from 'next/link'
import NotionIcon from './NotionIcon' import NotionIcon from './NotionIcon'
import { useRouter } from 'next/router' import { useRouter } from 'next/router'
import React from 'react'
const BlogPostCard = ({ post, className }) => { const BlogPostCard = ({ post, className }) => {
const router = useRouter() const router = useRouter()
const currentSelected = router.asPath.split('?')[0] === '/' + post.slug 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 ( return (
<Link href={`${removeHttp(post.slug)}`} target={(checkRemoveHttp(post.slug) ? '_blank' : '_self')} passHref> <Link href={`${removeHttp(post.slug)}`} target={(checkRemoveHttp(post.slug) ? '_blank' : '_self')} passHref>
<div key={post.id} className={`${className} h-full rounded-lg p-4 dark:bg-neutral-800 cursor-pointer bg-white hover:bg-white rounded-2xl dark:hover:bg-gray-800 ${currentSelected ? 'bg-green-50 text-green-500' : ''}`}> <div key={post.id} className={`${className} h-full rounded-lg p-4 dark:bg-neutral-800 cursor-pointer bg-white hover:bg-white rounded-2xl dark:hover:bg-gray-800 ${currentSelected ? 'bg-green-50 text-green-500' : ''}`}>
@@ -23,9 +21,9 @@ const BlogPostCard = ({ post, className }) => {
) )
function removeHttp(str) { function removeHttp(str) {
// 检查字符串是否包含http // 检查字符串是否包含http
if (str.includes("http")) { if (str.includes('http')) {
// 如果包含找到http的位置 // 如果包含找到http的位置
let index = str.indexOf("http"); const index = str.indexOf('http');
// 返回http之后的部分 // 返回http之后的部分
return str.slice(index, str.length); return str.slice(index, str.length);
} else { } else {
@@ -35,11 +33,9 @@ const BlogPostCard = ({ post, className }) => {
} }
function checkRemoveHttp(str) { function checkRemoveHttp(str) {
// 检查字符串是否包含http // 检查字符串是否包含http
if (str.includes("http")) { if (str.includes('http')) {
// 如果包含找到http的位置 // 如果包含找到http的位置
let index = str.indexOf("http"); return str.indexOf('http') > -1
// 包含
return true;
} else { } else {
// 不包含 // 不包含
return false; return false;

View File

@@ -1,6 +1,4 @@
import BlogPostCard from './BlogPostCard' import BlogPostCard from './BlogPostCard'
import React, { useState } from 'react'
import NotionIcon from './NotionIcon'
// import Collapse from '@/components/Collapse' // import Collapse from '@/components/Collapse'
/** /**
@@ -11,12 +9,7 @@ import NotionIcon from './NotionIcon'
* @constructor * @constructor
*/ */
const BlogPostItem = (props) => { const BlogPostItem = (props) => {
const { group, filterLinks } = props const { group } = props
// const [isOpen, changeIsOpen] = useState(group?.selected)
// const toggleOpenSubMenu = () => {
// changeIsOpen(!isOpen)
// }
console.log('####### group') console.log('####### group')
console.log(group) console.log(group)

View File

@@ -1,5 +1,4 @@
import { useNavGlobal } from '@/themes/nav' import { useNavGlobal } from '@/themes/nav'
import React from 'react'
import JumpToTopButton from './JumpToTopButton' import JumpToTopButton from './JumpToTopButton'
export default function BottomMenuBar({ post, className }) { export default function BottomMenuBar({ post, className }) {

View File

@@ -1,4 +1,3 @@
import React from 'react'
import CategoryItem from './CategoryItem' import CategoryItem from './CategoryItem'
const CategoryGroup = ({ currentCategory, categoryOptions }) => { const CategoryGroup = ({ currentCategory, categoryOptions }) => {

View File

@@ -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 Collapse = props => {
const { collapseRef } = props const { collapseRef } = props
const ref = React.useRef(null) const ref = useRef(null)
const type = props.type || 'vertical' const type = props.type || 'vertical'
useImperativeHandle(collapseRef, () => { useImperativeHandle(collapseRef, () => {

View File

@@ -1,5 +1,4 @@
import Link from 'next/link' import Link from 'next/link'
import React from 'react'
export default function LeftMenuBar () { export default function LeftMenuBar () {
return ( return (

View File

@@ -1,5 +1,5 @@
import BlogPostCard from './BlogPostCard' import BlogPostCard from './BlogPostCard'
import React, { useState } from 'react' import { useState } from 'react'
import Collapse from '@/components/Collapse' import Collapse from '@/components/Collapse'
/** /**

View File

@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { isBrowser } from '@/lib/utils' import { isBrowser } from '@/lib/utils'
/** /**

View File

@@ -1,6 +1,6 @@
import React from 'react'
import Link from 'next/link' import Link from 'next/link'
import BLOG from '@/blog.config' import BLOG from '@/blog.config'
/** /**
* 博客归档列表 * 博客归档列表
* @param posts 所有文章 * @param posts 所有文章

View File

@@ -2,7 +2,6 @@ import BLOG from '@/blog.config'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import Image from 'next/image' import Image from 'next/image'
import Link from 'next/link' import Link from 'next/link'
import React from 'react'
import Card from './Card' import Card from './Card'
import TagItemMini from './TagItemMini' import TagItemMini from './TagItemMini'
import CONFIG from '../config' import CONFIG from '../config'

View File

@@ -3,7 +3,7 @@ import BlogPostCard from './BlogPostCard'
import BlogPostListEmpty from './BlogPostListEmpty' import BlogPostListEmpty from './BlogPostListEmpty'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import throttle from 'lodash.throttle' import throttle from 'lodash.throttle'
import React, { useCallback, useEffect, useRef, useState } from 'react' import { useCallback, useEffect, useRef, useState } from 'react'
import CONFIG from '../config' import CONFIG from '../config'
/** /**

View File

@@ -1,5 +1,4 @@
import Link from 'next/link' import Link from 'next/link'
import React from 'react'
const CategoryGroup = ({ currentCategory, categories }) => { const CategoryGroup = ({ currentCategory, categories }) => {
if (!categories) return <></> if (!categories) return <></>

View File

@@ -1,5 +1,4 @@
import Link from 'next/link' import Link from 'next/link'
import React from 'react'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
const CategoryList = ({ currentCategory, categoryOptions }) => { const CategoryList = ({ currentCategory, categoryOptions }) => {

View File

@@ -1,4 +1,3 @@
import React from 'react'
import Link from 'next/link' import Link from 'next/link'
/** /**

View File

@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import CONFIG from '../config' import CONFIG from '../config'
/** /**

View File

@@ -1,5 +1,4 @@
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import React from 'react'
import CONFIG from '../config' import CONFIG from '../config'
/** /**

View File

@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import throttle from 'lodash.throttle' import throttle from 'lodash.throttle'
import DarkModeButton from './DarkModeButton' import DarkModeButton from './DarkModeButton'

View File

@@ -1,5 +1,4 @@
import Link from 'next/link' import Link from 'next/link'
import React from 'react'
import { siteConfig } from '@/lib/config' import { siteConfig } from '@/lib/config'
const Logo = props => { const Logo = props => {

View File

@@ -1,4 +1,4 @@
import React from 'react' import { useEffect, useState } from 'react'
import BLOG from '@/blog.config' import BLOG from '@/blog.config'
import Link from 'next/link' import Link from 'next/link'
import { RecentComments } from '@waline/client' import { RecentComments } from '@waline/client'
@@ -9,9 +9,9 @@ import { RecentComments } from '@waline/client'
* @returns * @returns
*/ */
const NextRecentComments = (props) => { const NextRecentComments = (props) => {
const [comments, updateComments] = React.useState([]) const [comments, updateComments] = useState([])
const [onLoading, changeLoading] = React.useState(true) const [onLoading, changeLoading] = useState(true)
React.useEffect(() => { useEffect(() => {
RecentComments({ RecentComments({
serverURL: BLOG.COMMENT_WALINE_SERVER_URL, serverURL: BLOG.COMMENT_WALINE_SERVER_URL,
count: 5 count: 5

View File

@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { isBrowser } from '@/lib/utils' import { isBrowser } from '@/lib/utils'
/** /**

View File

@@ -1,4 +1,3 @@
import React from 'react'
import Link from 'next/link' import Link from 'next/link'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import CONFIG from '../config' import CONFIG from '../config'
@@ -7,10 +6,10 @@ import CONFIG from '../config'
* 展示文章推荐 * 展示文章推荐
*/ */
const RecommendPosts = ({ recommendPosts }) => { const RecommendPosts = ({ recommendPosts }) => {
const { locale } = useGlobal()
if (!CONFIG.ARTICLE_RELATE_POSTS || !recommendPosts || recommendPosts.length < 1) { if (!CONFIG.ARTICLE_RELATE_POSTS || !recommendPosts || recommendPosts.length < 1) {
return <></> return <></>
} }
const { locale } = useGlobal()
return ( return (
<div className="pt-2 border pl-4 py-2 my-4 dark:text-gray-300 "> <div className="pt-2 border pl-4 py-2 my-4 dark:text-gray-300 ">

View File

@@ -1,4 +1,3 @@
import React from 'react'
import Image from 'next/image' import Image from 'next/image'
/** /**

View File

@@ -3,7 +3,6 @@ import { MenuList } from './MenuList'
import SearchInput from './SearchInput' import SearchInput from './SearchInput'
import Toc from './Toc' import Toc from './Toc'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import React from 'react'
import Tabs from '@/components/Tabs' import Tabs from '@/components/Tabs'
import Logo from './Logo' import Logo from './Logo'
import Card from './Card' import Card from './Card'

View File

@@ -1,6 +1,5 @@
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import Link from 'next/link' import Link from 'next/link'
import React from 'react'
import Card from './Card' import Card from './Card'
import CategoryGroup from './CategoryGroup' import CategoryGroup from './CategoryGroup'
import TagGroups from './TagGroups' import TagGroups from './TagGroups'

Some files were not shown because too many files have changed in this diff Show More