From 0dae01f5470d72c127b6f0815f189a776adbbeda Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Fri, 13 Sep 2024 17:07:09 +0800 Subject: [PATCH] =?UTF-8?q?Magzine=E4=B8=BB=E9=A2=98=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/ExternalPlugins.js | 3 +- components/OpenWrite.js | 5 +- lib/cache/cache_manager.js | 2 +- themes/magzine/components/Announcement.js | 3 + themes/magzine/components/ArticleInfo.js | 43 +++++- themes/magzine/components/Footer.js | 137 +++++++++++++----- themes/magzine/components/Header.js | 2 +- themes/magzine/components/Hero.js | 2 +- themes/magzine/components/JumpToTopButton.js | 3 +- themes/magzine/components/LoadingCover.js | 7 - themes/magzine/components/MenuBarMobile.js | 9 +- .../components/PostBannerGroupByCategory.js | 87 +++++++++++ themes/magzine/components/PostItemCard.js | 96 ++++-------- .../magzine/components/PostItemCardSimple.js | 8 +- themes/magzine/components/PostItemCardTop.js | 12 +- themes/magzine/components/PostItemCardWide.js | 8 +- .../magzine/components/PostListHorizontal.js | 15 +- .../magzine/components/PostListRecommend.js | 79 ++++++++++ .../components/PostListSimpleHorizontal.js | 2 +- themes/magzine/components/SocialButton.js | 20 +-- themes/magzine/components/TopNavBar.js | 9 +- themes/magzine/config.js | 96 +++++++++++- themes/magzine/index.js | 80 +++------- 23 files changed, 499 insertions(+), 229 deletions(-) delete mode 100644 themes/magzine/components/LoadingCover.js create mode 100644 themes/magzine/components/PostBannerGroupByCategory.js create mode 100644 themes/magzine/components/PostListRecommend.js diff --git a/components/ExternalPlugins.js b/components/ExternalPlugins.js index ce0b5e63..d798a940 100644 --- a/components/ExternalPlugins.js +++ b/components/ExternalPlugins.js @@ -63,7 +63,8 @@ const ExternalPlugin = props => { const MOUSE_FOLLOW = siteConfig('MOUSE_FOLLOW') const CUSTOM_EXTERNAL_CSS = siteConfig('CUSTOM_EXTERNAL_CSS') const CUSTOM_EXTERNAL_JS = siteConfig('CUSTOM_EXTERNAL_JS') - const ENABLE_NPROGRSS = siteConfig('ENABLE_NPROGRSS', true) + // 默认关闭NProgress + const ENABLE_NPROGRSS = siteConfig('ENABLE_NPROGRSS', false) // 自定义样式css和js引入 if (isBrowser) { diff --git a/components/OpenWrite.js b/components/OpenWrite.js index 973931a8..5caf5d7b 100644 --- a/components/OpenWrite.js +++ b/components/OpenWrite.js @@ -73,8 +73,11 @@ const OpenWrite = () => { console.error('OpenWrite 加载异常', error) } } - useEffect(() => { + if (process.env.NODE_ENV === 'development') { + console.log('开发环境:屏蔽OpenWrite') + return + } if (isBrowser && blogId) { // Check if the element with id 'read-more-wrap' already exists const readMoreWrap = document.getElementById('read-more-wrap') diff --git a/lib/cache/cache_manager.js b/lib/cache/cache_manager.js index 6070958c..bbfbfdac 100644 --- a/lib/cache/cache_manager.js +++ b/lib/cache/cache_manager.js @@ -8,7 +8,7 @@ import MemoryCache from './memory_cache' * @returns */ export async function getDataFromCache(key, force) { - if (JSON.parse(BLOG.ENABLE_CACHE) || force) { + if (BLOG.ENABLE_CACHE || force) { const dataFromCache = await getApi().getCache(key) if (JSON.stringify(dataFromCache) === '[]') { return null diff --git a/themes/magzine/components/Announcement.js b/themes/magzine/components/Announcement.js index 522f0784..62ab01d0 100644 --- a/themes/magzine/components/Announcement.js +++ b/themes/magzine/components/Announcement.js @@ -3,6 +3,9 @@ import dynamic from 'next/dynamic' const NotionPage = dynamic(() => import('@/components/NotionPage')) +/** + * Magzine主题的公告 + */ const Announcement = ({ post, className }) => { // const { locale } = useGlobal() if (post?.blockMap) { diff --git a/themes/magzine/components/ArticleInfo.js b/themes/magzine/components/ArticleInfo.js index e2f79ea3..02461b8d 100644 --- a/themes/magzine/components/ArticleInfo.js +++ b/themes/magzine/components/ArticleInfo.js @@ -2,6 +2,8 @@ import LazyImage from '@/components/LazyImage' import NotionIcon from '@/components/NotionIcon' import { siteConfig } from '@/lib/config' import Link from 'next/link' +import CategoryItem from './CategoryItem' +import TagItemMini from './TagItemMini' /** * 文章详情页介绍 @@ -13,11 +15,42 @@ export default function ArticleInfo(props) { return ( <> - {/* title */} -

- {siteConfig('POST_TITLE_ICON') && } - {post?.title} -

+
+
+ {siteConfig('MAGZINE_POST_LIST_CATEGORY') && ( + + )} +
+ {siteConfig('MAGZINE_POST_LIST_TAG') && + post?.tagItems?.map(tag => ( + + ))} +
+
+ + {/* title */} +

+ {siteConfig('POST_TITLE_ICON') && ( + + )} + {post?.title} +

+ +
{post?.summary}
+
+ + {post?.type && !post?.type !== 'Page' && post?.pageCover && ( +
+ +
+ )} {/* meta */}
diff --git a/themes/magzine/components/Footer.js b/themes/magzine/components/Footer.js index aaf801f8..b3672dda 100644 --- a/themes/magzine/components/Footer.js +++ b/themes/magzine/components/Footer.js @@ -1,56 +1,113 @@ import DarkModeButton from '@/components/DarkModeButton' +import LazyImage from '@/components/LazyImage' import { siteConfig } from '@/lib/config' +import { useGlobal } from '@/lib/global' +import Link from 'next/link' import SocialButton from './SocialButton' +/** + * 网页底脚 + */ const Footer = ({ title }) => { const d = new Date() const currentYear = d.getFullYear() const since = siteConfig('SINCE') const copyrightDate = parseInt(since) < currentYear ? since + '-' + currentYear : currentYear + const { siteInfo } = useGlobal() + const MAGZINE_FOOTER_LINKS = siteConfig('MAGZINE_FOOTER_LINKS', []) + console.log('菜单', MAGZINE_FOOTER_LINKS) return ( -