From 195b54e6617dadb2513e9aa692e73f192ea1d839 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 31 Jan 2024 11:32:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E5=8F=B3=E9=94=AE=E5=8A=A0=E5=85=A5=E5=A4=8D=E5=88=B6=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/CustomContextMenu.js | 40 ++++++++++++++++++++++++++++----- lib/lang/en-US.js | 5 +++-- lib/lang/zh-CN.js | 5 +++-- 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/components/CustomContextMenu.js b/components/CustomContextMenu.js index bf396d39..43adac7c 100644 --- a/components/CustomContextMenu.js +++ b/components/CustomContextMenu.js @@ -93,13 +93,33 @@ export default function CustomContextMenu(props) { /** * 切换主题 */ - function handeChangeTheme() { + function handleChangeTheme() { const randomTheme = THEMES[Math.floor(Math.random() * THEMES.length)] // 从THEMES数组中 随机取一个主题 const query = router.query query.theme = randomTheme router.push({ pathname: router.pathname, query }) } + /** + * 复制内容 + */ + function handleCopy(){ + var selectedText = document.getSelection().toString(); + if (selectedText) { + var tempInput = document.createElement("input"); + tempInput.value = selectedText; + document.body.appendChild(tempInput); + tempInput.select(); + document.execCommand("copy"); + document.body.removeChild(tempInput); + // alert("Text copied: " + selectedText); + } else { + // alert("Please select some text first."); + } + + setShow(false) + } + function handleChangeDarkMode() { const newStatus = !isDarkMode saveDarkModeToCookies(newStatus) @@ -153,21 +173,29 @@ export default function CustomContextMenu(props) { {/* 功能按钮 */}
-
+ {siteConfig('CAN_COPY') && ( +
+ +
{locale.MENU.COPY}
+
+ )} + +
-
{locale.MENU.COPY_URL}
+
{locale.MENU.SHARE_URL}
{isDarkMode ? : }
{isDarkMode ? locale.MENU.LIGHT_MODE : locale.MENU.DARK_MODE}
- {siteConfig('CUSTOM_RIGHT_CLICK_CONTEXT_MENU_THEME_SWITCH') && ( -
+ {siteConfig('CUSTOM_RIGHT_CLICK_CONTEXT_MENU_THEME_SWITCH') && ( +
{locale.MENU.THEME_SWITCH}
- )} + )} +
diff --git a/lib/lang/en-US.js b/lib/lang/en-US.js index 063da7f8..47bb171c 100644 --- a/lib/lang/en-US.js +++ b/lib/lang/en-US.js @@ -4,10 +4,11 @@ export default { WALK_AROUND: 'Walk Around', CATEGORY: 'Category', TAGS: 'Tags', - COPY_URL: 'Copy URL', + SHARE_URL: 'Share URL', DARK_MODE: 'Dark Mode', LIGHT_MODE: 'Light Mode', - THEME_SWITCH: 'Theme Switch' + THEME_SWITCH: 'Theme Switch', + COPY: 'Copy' }, NAV: { INDEX: 'Home', diff --git a/lib/lang/zh-CN.js b/lib/lang/zh-CN.js index 2f4af10f..52c3b997 100644 --- a/lib/lang/zh-CN.js +++ b/lib/lang/zh-CN.js @@ -4,10 +4,11 @@ export default { WALK_AROUND: '随便逛逛', CATEGORY: '博客分类', TAGS: '博客标签', - COPY_URL: '复制地址', + SHARE_URL: '分享地址', DARK_MODE: '深色模式', LIGHT_MODE: '浅色模式', - THEME_SWITCH: '主题切换' + THEME_SWITCH: '主题切换', + COPY:'复制' }, NAV: { INDEX: '首页',