From f0c2bb05f6d8eeccc0dd41c9d99f0751aacab599 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Sun, 16 Jan 2022 10:03:36 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20NEXT=20=E4=B8=BB=E9=A2=98=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E8=A7=84=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/NEXT/LayoutBase.js | 2 +- themes/NEXT/LayoutCategory.js | 2 +- themes/NEXT/components/ArticleCopyright.js | 2 +- themes/NEXT/components/ArticleDetail.js | 13 ++++++------- themes/NEXT/components/BlogPostCard.js | 2 +- themes/NEXT/components/BlogPostListPage.js | 4 ++-- themes/NEXT/components/BlogPostListScroll.js | 6 +++--- themes/NEXT/components/DarkModeButton.js | 3 ++- themes/NEXT/components/FloatDarkModeButton.js | 2 +- themes/NEXT/components/Header.js | 2 +- themes/NEXT/components/JumpToBottomButton.js | 2 +- themes/NEXT/components/JumpToTopButton.js | 2 +- themes/NEXT/components/LeftFloatButton.js | 2 +- themes/NEXT/components/Live2D.js | 2 +- themes/NEXT/components/RecommendPosts.js | 2 +- themes/NEXT/components/ShareBar.js | 2 +- themes/NEXT/components/ShareButton.js | 2 +- themes/NEXT/components/SideAreaLeft.js | 16 ++++++++-------- themes/NEXT/components/SideAreaRight.js | 2 +- themes/NEXT/components/SideBar.js | 15 +++++++-------- themes/NEXT/components/SideBarDrawer.js | 6 +++--- themes/NEXT/components/StickyBar.js | 2 +- themes/NEXT/components/TagGroups.js | 2 +- themes/NEXT/components/TagItem.js | 2 +- themes/NEXT/components/TagList.js | 2 +- themes/NEXT/components/TocDrawer.js | 2 +- themes/NEXT/components/TocDrawerButton.js | 2 +- themes/NEXT/components/TopNav.js | 2 +- 28 files changed, 52 insertions(+), 53 deletions(-) diff --git a/themes/NEXT/LayoutBase.js b/themes/NEXT/LayoutBase.js index 92344b00..a720f518 100644 --- a/themes/NEXT/LayoutBase.js +++ b/themes/NEXT/LayoutBase.js @@ -11,7 +11,7 @@ import { useGlobal } from '@/lib/global' import PropTypes from 'prop-types' import React, { useEffect, useRef, useState } from 'react' import smoothscroll from 'smoothscroll-polyfill' -import CONFIG_NEXT from '@/themes/NEXT/config_next' +import CONFIG_NEXT from './config_next' /** * 基础布局 采用左右两侧布局,移动端使用顶部导航栏 diff --git a/themes/NEXT/LayoutCategory.js b/themes/NEXT/LayoutCategory.js index 25d6e58e..ea629e0d 100644 --- a/themes/NEXT/LayoutCategory.js +++ b/themes/NEXT/LayoutCategory.js @@ -1,6 +1,6 @@ import { useGlobal } from '@/lib/global' import BLOG from '@/blog.config' -import LayoutBase from '@/themes/NEXT/LayoutBase' +import LayoutBase from './LayoutBase' import StickyBar from './components/StickyBar' import CategoryList from './components/CategoryList' import BlogPostListScroll from './components/BlogPostListScroll' diff --git a/themes/NEXT/components/ArticleCopyright.js b/themes/NEXT/components/ArticleCopyright.js index 527d31c6..7ae6a349 100644 --- a/themes/NEXT/components/ArticleCopyright.js +++ b/themes/NEXT/components/ArticleCopyright.js @@ -1,6 +1,6 @@ import { useGlobal } from '@/lib/global' import Link from 'next/link' -import CONFIG_NEXT from '@/themes/NEXT/config_next' +import CONFIG_NEXT from '../config_next' export default function ArticleCopyright ({ author, url }) { if (!CONFIG_NEXT.ARTICLE_COPYRIGHT) { diff --git a/themes/NEXT/components/ArticleDetail.js b/themes/NEXT/components/ArticleDetail.js index ad29e8f6..f8bc66d3 100644 --- a/themes/NEXT/components/ArticleDetail.js +++ b/themes/NEXT/components/ArticleDetail.js @@ -1,9 +1,9 @@ import BLOG from '@/blog.config' -import BlogAround from '@/themes/NEXT/components/BlogAround' +import BlogAround from './BlogAround' import Comment from '@/components/Comment' -import RecommendPosts from '@/themes/NEXT/components/RecommendPosts' -import ShareBar from '@/themes/NEXT/components/ShareBar' -import TagItem from '@/themes/NEXT/components/TagItem' +import RecommendPosts from './RecommendPosts' +import ShareBar from './ShareBar' +import TagItem from './TagItem' import formatDate from '@/lib/formatDate' import { useGlobal } from '@/lib/global' import { faEye, faFolderOpen } from '@fortawesome/free-solid-svg-icons' @@ -102,8 +102,7 @@ export default function ArticleDetail ({ post, recommendPosts, prev, next }) {
  - + |
@@ -141,7 +140,7 @@ export default function ArticleDetail ({ post, recommendPosts, prev, next }) { data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-2708419466378217" - data-ad-slot="3806269138"> + data-ad-slot="3806269138"/> {/* 版权声明 */} diff --git a/themes/NEXT/components/BlogPostCard.js b/themes/NEXT/components/BlogPostCard.js index d127df1c..c3c630d4 100644 --- a/themes/NEXT/components/BlogPostCard.js +++ b/themes/NEXT/components/BlogPostCard.js @@ -8,7 +8,7 @@ import React from 'react' import { Code, Collection, CollectionRow, Equation, NotionRenderer } from 'react-notion-x' import Card from './Card' import TagItemMini from './TagItemMini' -import CONFIG_NEXT from '@/themes/NEXT/config_next' +import CONFIG_NEXT from '../config_next' const BlogPostCard = ({ post, showSummary }) => { const { locale } = useGlobal() diff --git a/themes/NEXT/components/BlogPostListPage.js b/themes/NEXT/components/BlogPostListPage.js index 1f1b89b5..007a1b29 100644 --- a/themes/NEXT/components/BlogPostListPage.js +++ b/themes/NEXT/components/BlogPostListPage.js @@ -1,7 +1,7 @@ -import BlogPostCard from '@/themes/NEXT/components/BlogPostCard' +import BlogPostCard from './BlogPostCard' import PaginationNumber from './PaginationNumber' import BLOG from '@/blog.config' -import BlogPostListEmpty from '@/themes/NEXT/components/BlogPostListEmpty' +import BlogPostListEmpty from './BlogPostListEmpty' /** * 文章列表分页表格 diff --git a/themes/NEXT/components/BlogPostListScroll.js b/themes/NEXT/components/BlogPostListScroll.js index 966c956a..992d7979 100644 --- a/themes/NEXT/components/BlogPostListScroll.js +++ b/themes/NEXT/components/BlogPostListScroll.js @@ -1,10 +1,10 @@ import BLOG from '@/blog.config' -import BlogPostCard from '@/themes/NEXT/components/BlogPostCard' -import BlogPostListEmpty from '@/themes/NEXT/components/BlogPostListEmpty' +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 CONFIG_NEXT from '@/themes/NEXT/config_next' +import CONFIG_NEXT from '../config_next' /** * 博客列表滚动分页 diff --git a/themes/NEXT/components/DarkModeButton.js b/themes/NEXT/components/DarkModeButton.js index ae344cf1..145b9358 100644 --- a/themes/NEXT/components/DarkModeButton.js +++ b/themes/NEXT/components/DarkModeButton.js @@ -1,6 +1,7 @@ -import { loadUserThemeFromCookies, saveTheme, useGlobal } from '@/lib/global' +import { useGlobal } from '@/lib/global' import { faMoon, faSun } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' +import { loadUserThemeFromCookies, saveTheme } from '@/lib/theme' const DarkModeButton = () => { const { changeTheme } = useGlobal() diff --git a/themes/NEXT/components/FloatDarkModeButton.js b/themes/NEXT/components/FloatDarkModeButton.js index d78a77ae..74257bf0 100644 --- a/themes/NEXT/components/FloatDarkModeButton.js +++ b/themes/NEXT/components/FloatDarkModeButton.js @@ -2,7 +2,7 @@ import { useGlobal } from '@/lib/global' import { loadUserThemeFromCookies, saveTheme } from '@/lib/theme' import { faMoon, faSun } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import CONFIG_NEXT from '@/themes/NEXT/config_next' +import CONFIG_NEXT from '../config_next' export default function FloatDarkModeButton () { if (!CONFIG_NEXT.WIDGET_DARK_MODE) { diff --git a/themes/NEXT/components/Header.js b/themes/NEXT/components/Header.js index 13eedfdb..2e18fbe3 100644 --- a/themes/NEXT/components/Header.js +++ b/themes/NEXT/components/Header.js @@ -3,7 +3,7 @@ import { faAngleDown } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { useEffect, useState } from 'react' import Typed from 'typed.js' -import CONFIG_NEXT from '@/themes/NEXT/config_next' +import CONFIG_NEXT from '../config_next' let wrapperTop = 0 let windowTop = 0 diff --git a/themes/NEXT/components/JumpToBottomButton.js b/themes/NEXT/components/JumpToBottomButton.js index bf024e03..70c31f2e 100644 --- a/themes/NEXT/components/JumpToBottomButton.js +++ b/themes/NEXT/components/JumpToBottomButton.js @@ -2,7 +2,7 @@ import { faArrowDown } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import React, { useEffect, useState } from 'react' import smoothscroll from 'smoothscroll-polyfill' -import CONFIG_NEXT from '@/themes/NEXT/config_next' +import CONFIG_NEXT from '../config_next' /** * 跳转到网页顶部 diff --git a/themes/NEXT/components/JumpToTopButton.js b/themes/NEXT/components/JumpToTopButton.js index e08f3a10..e4f27c05 100644 --- a/themes/NEXT/components/JumpToTopButton.js +++ b/themes/NEXT/components/JumpToTopButton.js @@ -2,7 +2,7 @@ import { useGlobal } from '@/lib/global' import { faArrowUp } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import React from 'react' -import CONFIG_NEXT from '@/themes/NEXT/config_next' +import CONFIG_NEXT from '../config_next' /** * 跳转到网页顶部 diff --git a/themes/NEXT/components/LeftFloatButton.js b/themes/NEXT/components/LeftFloatButton.js index 86f343ba..4872a746 100644 --- a/themes/NEXT/components/LeftFloatButton.js +++ b/themes/NEXT/components/LeftFloatButton.js @@ -1,6 +1,6 @@ import React, { useEffect, useState } from 'react' import throttle from 'lodash.throttle' -import DarkModeButton from '@/themes/NEXT/components/DarkModeButton' +import DarkModeButton from './DarkModeButton' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faBars } from '@fortawesome/free-solid-svg-icons' diff --git a/themes/NEXT/components/Live2D.js b/themes/NEXT/components/Live2D.js index ce99d4d7..5ad27c93 100644 --- a/themes/NEXT/components/Live2D.js +++ b/themes/NEXT/components/Live2D.js @@ -1,5 +1,5 @@ /* eslint-disable no-undef */ -import CONFIG_NEXT from '@/themes/NEXT/config_next' +import CONFIG_NEXT from '../config_next' let hasLoad = false export default function Live2D () { diff --git a/themes/NEXT/components/RecommendPosts.js b/themes/NEXT/components/RecommendPosts.js index 5d2b8bc6..c25a710c 100644 --- a/themes/NEXT/components/RecommendPosts.js +++ b/themes/NEXT/components/RecommendPosts.js @@ -1,7 +1,7 @@ import React from 'react' import Link from 'next/link' import { useGlobal } from '@/lib/global' -import CONFIG_NEXT from '@/themes/NEXT/config_next' +import CONFIG_NEXT from '../config_next' /** * 展示文章推荐 diff --git a/themes/NEXT/components/ShareBar.js b/themes/NEXT/components/ShareBar.js index 806594bb..ee541452 100644 --- a/themes/NEXT/components/ShareBar.js +++ b/themes/NEXT/components/ShareBar.js @@ -15,7 +15,7 @@ import { faWeixin } from '@fortawesome/free-brands-svg-icons' import { faLink } from '@fortawesome/free-solid-svg-icons' -import CONFIG_NEXT from '@/themes/NEXT/config_next' +import CONFIG_NEXT from '../config_next' const ShareBar = ({ post }) => { if (!CONFIG_NEXT.ARTICLE_SHARE) { diff --git a/themes/NEXT/components/ShareButton.js b/themes/NEXT/components/ShareButton.js index 64955fb9..f872e910 100644 --- a/themes/NEXT/components/ShareButton.js +++ b/themes/NEXT/components/ShareButton.js @@ -1,5 +1,5 @@ import React from 'react' -import ShareBar from '@/themes/NEXT/components/ShareBar' +import ShareBar from './ShareBar' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faShareAltSquare } from '@fortawesome/free-solid-svg-icons' diff --git a/themes/NEXT/components/SideAreaLeft.js b/themes/NEXT/components/SideAreaLeft.js index 87e50324..b1c203a8 100644 --- a/themes/NEXT/components/SideAreaLeft.js +++ b/themes/NEXT/components/SideAreaLeft.js @@ -1,13 +1,13 @@ -import InfoCard from '@/themes/NEXT/components/InfoCard' -import MenuButtonGroup from '@/themes/NEXT/components/MenuButtonGroup' -import SearchInput from '@/themes/NEXT/components/SearchInput' -import Toc from '@/themes/NEXT/components/Toc' +import InfoCard from './InfoCard' +import MenuButtonGroup from './MenuButtonGroup' +import SearchInput from './SearchInput' +import Toc from './Toc' import { useGlobal } from '@/lib/global' import React from 'react' -import Tabs from '@/themes/NEXT/components/Tabs' +import Tabs from './Tabs' import Logo from './Logo' import Card from './Card' -import CONFIG_NEXT from '@/themes/NEXT/config_next' +import CONFIG_NEXT from '../config_next' /** * 侧边平铺 @@ -52,9 +52,9 @@ const SideAreaLeft = ({ currentTag, post, postCount, currentSearch }) => { {postCount}{locale.COMMON.POSTS} - | {locale.COMMON.VISITORS} + | {locale.COMMON.VISITORS} {/* - | {locale.COMMON.VIEWS} */} + | {locale.COMMON.VIEWS} */} diff --git a/themes/NEXT/components/SideAreaRight.js b/themes/NEXT/components/SideAreaRight.js index b14bba59..01860a39 100644 --- a/themes/NEXT/components/SideAreaRight.js +++ b/themes/NEXT/components/SideAreaRight.js @@ -6,7 +6,7 @@ import React from 'react' import Card from './Card' import CategoryGroup from './CategoryGroup' import TagGroups from './TagGroups' -import CONFIG_NEXT from '@/themes/NEXT/config_next' +import CONFIG_NEXT from '../config_next' /** * 侧边平铺 diff --git a/themes/NEXT/components/SideBar.js b/themes/NEXT/components/SideBar.js index 4989d5c4..dfe9f643 100644 --- a/themes/NEXT/components/SideBar.js +++ b/themes/NEXT/components/SideBar.js @@ -1,6 +1,6 @@ -import CategoryGroup from '@/themes/NEXT/components/CategoryGroup' -import InfoCard from '@/themes/NEXT/components/InfoCard' -import TagGroups from '@/themes/NEXT/components/TagGroups' +import CategoryGroup from './CategoryGroup' +import InfoCard from './InfoCard' +import TagGroups from './TagGroups' import { useGlobal } from '@/lib/global' import { faAngleDoubleRight, faTag, faThList } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' @@ -15,11 +15,10 @@ import React from 'react' * @param posts * @param categories * @param currentCategory - * @param currentSearch * @returns {JSX.Element} * @constructor */ -const SideBar = ({ title, tags, currentTag, post, slot, categories, currentCategory, currentSearch }) => { +const SideBar = ({ tags, currentTag, post, slot, categories, currentCategory }) => { const { locale } = useGlobal() return diff --git a/themes/NEXT/components/SideBarDrawer.js b/themes/NEXT/components/SideBarDrawer.js index 9b76f431..e1ff3d9a 100644 --- a/themes/NEXT/components/SideBarDrawer.js +++ b/themes/NEXT/components/SideBarDrawer.js @@ -1,4 +1,4 @@ -import SideBar from '@/themes/NEXT/components/SideBar' +import SideBar from './SideBar' import { useRouter } from 'next/router' import React, { useEffect, useImperativeHandle } from 'react' @@ -7,7 +7,7 @@ import React, { useEffect, useImperativeHandle } from 'react' * @returns {JSX.Element} * @constructor */ -const SideBarDrawer = ({ post, currentTag, cRef, tags, slot, categories, currentCategory }) => { +const SideBarDrawer = ({ post, cRef, tags, slot, categories, currentCategory }) => { // 暴露给父组件 通过cRef.current.handleMenuClick 调用 useImperativeHandle(cRef, () => { return { @@ -22,7 +22,7 @@ const SideBarDrawer = ({ post, currentTag, cRef, tags, slot, categories, current const router = useRouter() useEffect(() => { - const sideBarDrawerRouteListener = url => { + const sideBarDrawerRouteListener = () => { switchSideDrawerVisible(false) } router.events.on('routeChangeComplete', sideBarDrawerRouteListener) diff --git a/themes/NEXT/components/StickyBar.js b/themes/NEXT/components/StickyBar.js index 61d52106..281d7477 100644 --- a/themes/NEXT/components/StickyBar.js +++ b/themes/NEXT/components/StickyBar.js @@ -1,6 +1,6 @@ import throttle from 'lodash.throttle' import { useCallback, useEffect } from 'react' -import CONFIG_NEXT from '@/themes/NEXT/config_next' +import CONFIG_NEXT from '../config_next' let windowTop = 0 diff --git a/themes/NEXT/components/TagGroups.js b/themes/NEXT/components/TagGroups.js index b9ca5fc9..1a406ed3 100644 --- a/themes/NEXT/components/TagGroups.js +++ b/themes/NEXT/components/TagGroups.js @@ -1,4 +1,4 @@ -import TagItemMini from '@/themes/NEXT/components/TagItemMini' +import TagItemMini from './TagItemMini' /** * 标签组 diff --git a/themes/NEXT/components/TagItem.js b/themes/NEXT/components/TagItem.js index 6051eed8..d972e0cd 100644 --- a/themes/NEXT/components/TagItem.js +++ b/themes/NEXT/components/TagItem.js @@ -7,7 +7,7 @@ import { useGlobal } from '@/lib/global' const TagItem = ({ tag, selected }) => { const { locale } = useGlobal() if (!tag) { - <>{locale.COMMON.NOTAG} +
{ locale.COMMON.NOTAG }
} return ( diff --git a/themes/NEXT/components/TagList.js b/themes/NEXT/components/TagList.js index 31c741fc..f5b7d030 100644 --- a/themes/NEXT/components/TagList.js +++ b/themes/NEXT/components/TagList.js @@ -1,5 +1,5 @@ import React from 'react' -import TagItem from '@/themes/NEXT/components/TagItem' +import TagItem from './TagItem' /** * 横向的标签列表 * @param tags diff --git a/themes/NEXT/components/TocDrawer.js b/themes/NEXT/components/TocDrawer.js index 20e41ff5..72cbefe3 100644 --- a/themes/NEXT/components/TocDrawer.js +++ b/themes/NEXT/components/TocDrawer.js @@ -1,4 +1,4 @@ -import Toc from '@/themes/NEXT/components/Toc' +import Toc from './Toc' import React, { useImperativeHandle, useState } from 'react' import { useGlobal } from '@/lib/global' diff --git a/themes/NEXT/components/TocDrawerButton.js b/themes/NEXT/components/TocDrawerButton.js index 9255c67f..473514a3 100644 --- a/themes/NEXT/components/TocDrawerButton.js +++ b/themes/NEXT/components/TocDrawerButton.js @@ -2,7 +2,7 @@ import { useGlobal } from '@/lib/global' import { faListOl } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import React from 'react' -import CONFIG_NEXT from '@/themes/NEXT/config_next' +import CONFIG_NEXT from '../config_next' /** * 点击召唤目录抽屉 diff --git a/themes/NEXT/components/TopNav.js b/themes/NEXT/components/TopNav.js index 2dabbdbe..a199e038 100644 --- a/themes/NEXT/components/TopNav.js +++ b/themes/NEXT/components/TopNav.js @@ -10,7 +10,7 @@ import Logo from './Logo' import MenuButtonGroup from './MenuButtonGroup' import SearchDrawer from './SearchDrawer' import TagGroups from './TagGroups' -import CONFIG_NEXT from '@/themes/NEXT/config_next' +import CONFIG_NEXT from '../config_next' let windowTop = 0