From a78a25ae96372aae51eb09f5f2cdb2464f5bbb96 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 21 Dec 2021 15:04:05 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20=E7=BB=9F=E8=AE=A1=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/ArticleDetail.js | 6 +++--- components/FloatDarkModeButton.js | 4 ++-- components/InfoCard.js | 9 --------- components/SideAreaLeft.js | 23 +++++++++++++++++++---- components/SideAreaRight.js | 2 +- layouts/BaseLayout.js | 2 +- lib/global.js | 8 ++++---- lib/lang/en-US.js | 3 +++ lib/lang/zh-CN.js | 4 ++++ 9 files changed, 37 insertions(+), 24 deletions(-) diff --git a/components/ArticleDetail.js b/components/ArticleDetail.js index dabf6941..d9fd7703 100644 --- a/components/ArticleDetail.js +++ b/components/ArticleDetail.js @@ -42,7 +42,7 @@ export default function ArticleDetail ({ post, blockMap, recommendPosts, prev, n return (<>
{post.type && !post.type.includes('Page') && post?.page_cover && ( @@ -80,13 +80,13 @@ export default function ArticleDetail ({ post, blockMap, recommendPosts, prev, n )} -
+
  -
diff --git a/components/FloatDarkModeButton.js b/components/FloatDarkModeButton.js index 53e28513..5fb61c72 100644 --- a/components/FloatDarkModeButton.js +++ b/components/FloatDarkModeButton.js @@ -27,8 +27,8 @@ export default function FloatDarkModeButton () { changeTheme(newTheme) const htmlElement = document.getElementsByTagName('html')[0] console.log('切换主题', htmlElement) - htmlElement.classList.remove(userTheme) - htmlElement.classList.add(newTheme) + htmlElement.classList?.remove(userTheme) + htmlElement.classList?.add(newTheme) } return ( diff --git a/components/InfoCard.js b/components/InfoCard.js index 7077a84a..bc4c7337 100644 --- a/components/InfoCard.js +++ b/components/InfoCard.js @@ -19,15 +19,6 @@ const InfoCard = ({ postCount }) => { />
{BLOG.title}
-
- - - - - - - {postCount} -
} diff --git a/components/SideAreaLeft.js b/components/SideAreaLeft.js index 5cb644d5..025480e1 100644 --- a/components/SideAreaLeft.js +++ b/components/SideAreaLeft.js @@ -4,7 +4,7 @@ import MenuButtonGroup from '@/components/MenuButtonGroup' import SearchInput from '@/components/SearchInput' import Toc from '@/components/Toc' import { useGlobal } from '@/lib/global' -import { faAngleDoubleRight, faThList } from '@fortawesome/free-solid-svg-icons' +import { faAngleDoubleRight, faChartBar, faThList } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import Link from 'next/link' import React from 'react' @@ -24,13 +24,14 @@ import React from 'react' const SideAreaLeft = ({ title, tags, currentTag, post, posts, categories, currentCategory, currentSearch }) => { const { locale } = useGlobal() const showToc = post && post.toc && post.toc.length > 1 - const postCount = posts.length + const postCount = posts?.length || 0 return <> -
+
+ {/* 菜单 */}
@@ -38,6 +39,20 @@ const SideAreaLeft = ({ title, tags, currentTag, post, posts, categories, curren
+ + {/* 统计 */} +
+
{locale.COMMON.ANALYTICS}
+
+ + {postCount}{locale.COMMON.POSTS} + + | {locale.COMMON.VISITORS} + + | {locale.COMMON.VIEWS} +
+
+ {/* 分类 */} {!post && categories && (
@@ -55,7 +70,7 @@ const SideAreaLeft = ({ title, tags, currentTag, post, posts, categories, curren
{showToc && ( -
+
{locale.COMMON.TABLE_OF_CONTENTS}
diff --git a/components/SideAreaRight.js b/components/SideAreaRight.js index dd42716d..f8579f1b 100644 --- a/components/SideAreaRight.js +++ b/components/SideAreaRight.js @@ -51,7 +51,7 @@ const SideAreaRight = ({ >
-
+
{/* 最新文章 */} {posts && (
diff --git a/layouts/BaseLayout.js b/layouts/BaseLayout.js index ecbc1fec..948ad096 100644 --- a/layouts/BaseLayout.js +++ b/layouts/BaseLayout.js @@ -71,7 +71,7 @@ const BaseLayout = ({ {/* 顶部导航栏 */} -
+
diff --git a/lib/global.js b/lib/global.js index 7329ac72..a5346535 100644 --- a/lib/global.js +++ b/lib/global.js @@ -92,13 +92,13 @@ const initTheme = (theme, changeTheme) => { if (useDark) { changeTheme('dark') saveTheme('dark') - htmlElement.classList.remove('light') - htmlElement.classList.add('dark') + htmlElement.classList?.remove('light') + htmlElement.classList?.add('dark') } else { changeTheme('light') saveTheme('light') - htmlElement.classList.remove('dark') - htmlElement.classList.add('light') + htmlElement.classList?.remove('dark') + htmlElement.classList?.add('light') } } } diff --git a/lib/lang/en-US.js b/lib/lang/en-US.js index ff9cfe31..fa0619ea 100644 --- a/lib/lang/en-US.js +++ b/lib/lang/en-US.js @@ -23,6 +23,9 @@ export default { COPYRIGHT: 'Copyright', AUTHOR: 'Author', URL: 'URL', + POSTS: 'Posts', + VISITORS: 'Visitors', + VIEWS: 'Views', COPYRIGHT_NOTICE: 'All articles in this blog, except for special statements, adopt BY-NC-SA agreement. Please indicate the source!' }, PAGINATION: { diff --git a/lib/lang/zh-CN.js b/lib/lang/zh-CN.js index 03a28a03..e7a8e22b 100644 --- a/lib/lang/zh-CN.js +++ b/lib/lang/zh-CN.js @@ -24,6 +24,10 @@ export default { COPYRIGHT: '版权声明', AUTHOR: '作者', URL: '链接', + ANALYTICS: '统计', + POSTS: '篇文章', + VISITORS: '位访客', + VIEWS: '次查看', COPYRIGHT_NOTICE: '本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!' }, PAGINATION: {