diff --git a/components/CustomContextMenu.js b/components/CustomContextMenu.js index b577c072..054c04fa 100644 --- a/components/CustomContextMenu.js +++ b/components/CustomContextMenu.js @@ -12,7 +12,7 @@ import { saveDarkModeToCookies, THEMES } from '@/themes/theme' export default function CustomContextMenu(props) { const [position, setPosition] = useState({ x: '0px', y: '0px' }) const [show, setShow] = useState(false) - const { isDarkMode, updateDarkMode } = useGlobal() + const { isDarkMode, updateDarkMode, locale } = useGlobal() const menuRef = useRef(null) const { latestPosts } = props @@ -97,7 +97,7 @@ export default function CustomContextMenu(props) {
{/* 菜单内容 */} @@ -115,19 +115,19 @@ export default function CustomContextMenu(props) { {/* 跳转导航按钮 */}
-
+
-
随便逛逛
+
{locale.MENU.WALK_AROUND}
- + -
博客分类
+
{locale.MENU.CATEGORY}
- + -
文章标签
+
{locale.MENU.TAGS}
@@ -137,18 +137,18 @@ export default function CustomContextMenu(props) { {/* 功能按钮 */}
-
+
-
复制地址
+
{locale.MENU.COPY_URL}
-
+
{isDarkMode ? : } -
{isDarkMode ? '浅色模式' : '深色模式'}
+
{isDarkMode ? locale.MENU.LIGHT_MODE : locale.MENU.DARK_MODE}
-
+
-
切换主题
+
{locale.MENU.THEME_SWITCH}
diff --git a/lib/lang/en-US.js b/lib/lang/en-US.js index 7d036425..51e38115 100644 --- a/lib/lang/en-US.js +++ b/lib/lang/en-US.js @@ -1,5 +1,14 @@ export default { LOCALE: 'en-US', + MENU: { + WALK_AROUND: 'Walk Around', + CATEGORY: 'Category', + TAGS: 'Tags', + COPY_URL: 'Copy URL', + DARK_MODE: 'Dark Mode', + LIGHT_MODE: 'Light Mode', + THEME_SWITCH: 'Theme Switch' + }, NAV: { INDEX: 'Home', RSS: 'RSS', diff --git a/lib/lang/zh-CN.js b/lib/lang/zh-CN.js index fe130d6f..91a4600a 100644 --- a/lib/lang/zh-CN.js +++ b/lib/lang/zh-CN.js @@ -1,5 +1,14 @@ export default { LOCALE: 'zh-CN', + MENU: { + WALK_AROUND: '随便逛逛', + CATEGORY: '博客分类', + TAGS: '博客标签', + COPY_URL: '复制地址', + DARK_MODE: '深色模式', + LIGHT_MODE: '浅色模式', + THEME_SWITCH: '主题切换' + }, NAV: { INDEX: '首页', RSS: '订阅', diff --git a/themes/heo/components/Catalog.js b/themes/heo/components/Catalog.js index 627e3ef3..726aed27 100644 --- a/themes/heo/components/Catalog.js +++ b/themes/heo/components/Catalog.js @@ -1,4 +1,4 @@ -import React, { useRef } from 'react' +import { useCallback, useEffect, useRef, useState } from 'react' import throttle from 'lodash.throttle' import { uuidToId } from 'notion-utils' import { useGlobal } from '@/lib/global' @@ -12,7 +12,7 @@ import { useGlobal } from '@/lib/global' const Catalog = ({ toc }) => { const { locale } = useGlobal() // 监听滚动事件 - React.useEffect(() => { + useEffect(() => { window.addEventListener('scroll', actionSectionScrollSpy) actionSectionScrollSpy() return () => { @@ -25,10 +25,10 @@ const Catalog = ({ toc }) => { const tocIds = [] // 同步选中目录事件 - const [activeSection, setActiveSection] = React.useState(null) + const [activeSection, setActiveSection] = useState(null) const throttleMs = 200 - const actionSectionScrollSpy = React.useCallback(throttle(() => { + const actionSectionScrollSpy = useCallback(throttle(() => { const sections = document.getElementsByClassName('notion-h') let prevBBox = null let currentSectionId = activeSection