diff --git a/blog.config.js b/blog.config.js index acea5a5c..19169747 100644 --- a/blog.config.js +++ b/blog.config.js @@ -75,6 +75,8 @@ const BLOG = { ], FONT_AWESOME: process.env.NEXT_PUBLIC_FONT_AWESOME_PATH || '/css/all.min.css', // font-awesome 字体图标地址、默认读取本地; 可选 https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/font-awesome/6.0.0/css/all.min.css + CUSTOM_RIGHT_CLICK_CONTEXT_MENU: process.env.NEXT_PUBLIC_FONT_AWESOME_PATH || true, // 自定义右键菜单,覆盖系统菜单 + // 自定义外部脚本,外部样式 CUSTOM_EXTERNAL_JS: [''], // e.g. ['http://xx.com/script.js','http://xx.com/script.js'] CUSTOM_EXTERNAL_CSS: [''], // e.g. ['http://xx.com/style.css','http://xx.com/style.css'] diff --git a/themes/heo/components/CustomContextMenu.js b/components/CustomContextMenu.js similarity index 81% rename from themes/heo/components/CustomContextMenu.js rename to components/CustomContextMenu.js index de1fcec9..b577c072 100644 --- a/themes/heo/components/CustomContextMenu.js +++ b/components/CustomContextMenu.js @@ -2,7 +2,7 @@ import Link from 'next/link' import { useRouter } from 'next/router' import { useEffect, useState, useRef } from 'react' import { useGlobal } from '@/lib/global' -import { saveDarkModeToCookies } from '@/themes/theme' +import { saveDarkModeToCookies, THEMES } from '@/themes/theme' /** * 自定义右键菜单 @@ -74,6 +74,16 @@ export default function CustomContextMenu(props) { setShow(false) } + /** + * 切换主题 + */ + function handeChangeTheme() { + const randomTheme = THEMES[Math.floor(Math.random() * THEMES.length)] // 从THEMES数组中 随机取一个主题 + const query = router.query + query.theme = randomTheme + router.push({ pathname: router.pathname, query }) + } + function handleChangeDarkMode() { const newStatus = !isDarkMode saveDarkModeToCookies(newStatus) @@ -111,12 +121,12 @@ export default function CustomContextMenu(props) { - +
博客分类
- +
文章标签
@@ -128,18 +138,21 @@ export default function CustomContextMenu(props) {
- +
复制地址
- -
深色模式
+ {isDarkMode ? : } +
{isDarkMode ? '浅色模式' : '深色模式'}
+
+
+ +
切换主题
-
- + ) } diff --git a/components/ExternalPlugins.js b/components/ExternalPlugins.js index 867bb32b..c4b62548 100644 --- a/components/ExternalPlugins.js +++ b/components/ExternalPlugins.js @@ -29,6 +29,7 @@ const Busuanzi = dynamic(() => import('@/components/Busuanzi'), { ssr: false }) const GoogleAdsense = dynamic(() => import('@/components/GoogleAdsense'), { ssr: false }) const Messenger = dynamic(() => import('@/components/FacebookMessenger'), { ssr: false }) const VConsole = dynamic(() => import('@/components/VConsole'), { ssr: false }) +const CustomContextMenu = dynamic(() => import('@/components/CustomContextMenu'), { ssr: false }) /** * 各种第三方组件 @@ -53,6 +54,7 @@ const ExternalPlugin = (props) => { {JSON.parse(BLOG.FLUTTERINGRIBBON) && } {JSON.parse(BLOG.COMMENT_TWIKOO_COUNT_ENABLE) && } {JSON.parse(BLOG.RIBBON) && } + {JSON.parse(BLOG.CUSTOM_RIGHT_CLICK_CONTEXT_MENU) && } } diff --git a/components/ThemeSwitch.js b/components/ThemeSwitch.js index fc875dae..ab11bab5 100644 --- a/components/ThemeSwitch.js +++ b/components/ThemeSwitch.js @@ -23,15 +23,17 @@ const ThemeSwitch = () => { return (<> -
-
- - - +
+
+ +
+ +
+
diff --git a/pages/_app.js b/pages/_app.js index e0d11382..38e16c99 100644 --- a/pages/_app.js +++ b/pages/_app.js @@ -1,6 +1,6 @@ import { useEffect } from 'react' -// import 'animate.css' +import 'animate.css' import '@/styles/globals.css' import '@/styles/nprogress.css' import '@/styles/utility-patterns.css' diff --git a/themes/gitbook/index.js b/themes/gitbook/index.js index d3387d0e..2b034195 100644 --- a/themes/gitbook/index.js +++ b/themes/gitbook/index.js @@ -172,7 +172,7 @@ const LayoutIndex = (props) => { const article = document.getElementById('notion-article') if (!article) { console.log('请检查您的Notion数据库中是否包含此slug页面: ', CONFIG.INDEX_PAGE) - const containerInner = document.getElementById('container-inner') + const containerInner = document.querySelector('#theme-gitbook #container-inner') const newHTML = `

配置有误

请在您的notion中添加一个slug为${CONFIG.INDEX_PAGE}的文章
` containerInner?.insertAdjacentHTML('afterbegin', newHTML) } diff --git a/themes/heo/components/BlogPostCard.js b/themes/heo/components/BlogPostCard.js index d89aab5c..add783ea 100644 --- a/themes/heo/components/BlogPostCard.js +++ b/themes/heo/components/BlogPostCard.js @@ -12,7 +12,8 @@ const BlogPostCard = ({ index, post, showSummary, siteInfo }) => { const showPageCover = CONFIG.POST_LIST_COVER && post?.pageCoverThumbnail && !showPreview return (
-
+ +
{/* 图片封面 */} {showPageCover && ( diff --git a/themes/heo/components/Catalog.js b/themes/heo/components/Catalog.js index 115ddd0c..627e3ef3 100644 --- a/themes/heo/components/Catalog.js +++ b/themes/heo/components/Catalog.js @@ -1,7 +1,6 @@ import React, { useRef } from 'react' import throttle from 'lodash.throttle' import { uuidToId } from 'notion-utils' -import Progress from './Progress' import { useGlobal } from '@/lib/global' /** @@ -63,9 +62,6 @@ const Catalog = ({ toc }) => { return
{locale.COMMON.TABLE_OF_CONTENTS}
-
- -