From 86fd5adf599a02b584ee87df9be2e6118a6c6ae9 Mon Sep 17 00:00:00 2001 From: LooseLi <1329307562@qq.com> Date: Tue, 1 Aug 2023 18:20:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E9=98=B2=E5=A4=8D=E5=88=B6=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blog.config.js | 1 + lib/global.js | 7 +++++++ themes/example/style.js | 6 ++++++ themes/fukasawa/style.js | 6 ++++++ themes/gitbook/style.js | 6 ++++++ themes/heo/style.js | 6 ++++++ themes/hexo/style.js | 6 ++++++ themes/landing/style.js | 6 ++++++ themes/matery/style.js | 6 ++++++ themes/medium/style.js | 6 ++++++ themes/next/style.js | 6 ++++++ themes/nobelium/style.js | 6 ++++++ themes/plog/style.js | 6 ++++++ themes/simple/style.js | 6 ++++++ 14 files changed, 80 insertions(+) diff --git a/blog.config.js b/blog.config.js index d1a0d961..489c87ff 100644 --- a/blog.config.js +++ b/blog.config.js @@ -15,6 +15,7 @@ const BLOG = { // 3.14.1版本后,欢迎语在此配置,英文逗号隔开 , 即可支持多个欢迎语打字效果。 GREETING_WORDS: process.env.NEXT_PUBLIC_GREETING_WORDS || 'Hi,我是一个程序员, Hi,我是一个打工人,Hi,我是一个干饭人,欢迎来到我的博客🎉', + CAN_COPY: process.env.NEXT_PUBLIC_CAN_COPY || true, // 是否允许复制页面内容 默认允许 CUSTOM_MENU: process.env.NEXT_PUBLIC_CUSTOM_MENU || false, // 支持Menu 类型,从3.12.0版本起,各主题将逐步支持灵活的二级菜单配置,替代了原来的Page类型,此配置是试验功能、默认关闭。 AUTHOR: process.env.NEXT_PUBLIC_AUTHOR || 'NotionNext', // 您的昵称 例如 tangly1024 diff --git a/lib/global.js b/lib/global.js index 04d0176e..9e6819f8 100644 --- a/lib/global.js +++ b/lib/global.js @@ -29,6 +29,13 @@ export function GlobalContextProvider(props) { initTheme() }, []) + // 是否允许复制页面内容 + useEffect(() => { + if (!BLOG.CAN_COPY) { + document.getElementsByTagName('html')[0].classList.add('forbid-copy') + } + }, []) + useEffect(() => { const handleStart = (url) => { NProgress.start() diff --git a/themes/example/style.js b/themes/example/style.js index 0708b7b5..b5c3e553 100644 --- a/themes/example/style.js +++ b/themes/example/style.js @@ -10,6 +10,12 @@ const Style = () => { .dark body{ background-color: black; } + // 文本不可选取 + .forbid-copy { + user-select: none; + -webkit-user-select: none; + -ms-user-select: none; + } `} } diff --git a/themes/fukasawa/style.js b/themes/fukasawa/style.js index e730d919..bc024d7a 100644 --- a/themes/fukasawa/style.js +++ b/themes/fukasawa/style.js @@ -13,6 +13,12 @@ const Style = () => { .dark body{ background-color: black; } + // 文本不可选取 + .forbid-copy { + user-select: none; + -webkit-user-select: none; + -ms-user-select: none; + } /* fukasawa的首页响应式分栏 */ #theme-fukasawa .grid-item { diff --git a/themes/gitbook/style.js b/themes/gitbook/style.js index 5e8eaa5a..47e60906 100644 --- a/themes/gitbook/style.js +++ b/themes/gitbook/style.js @@ -11,6 +11,12 @@ const Style = () => { .dark body{ background-color: black; } + // 文本不可选取 + .forbid-copy { + user-select: none; + -webkit-user-select: none; + -ms-user-select: none; + } `} } diff --git a/themes/heo/style.js b/themes/heo/style.js index b0de7c2d..f7e96a21 100644 --- a/themes/heo/style.js +++ b/themes/heo/style.js @@ -10,6 +10,12 @@ const Style = () => { background-color: #f7f9fe; overflow-x: hidden; } + // 文本不可选取 + .forbid-copy { + user-select: none; + -webkit-user-select: none; + -ms-user-select: none; + } // 公告栏中的字体固定白色 #theme-heo #announcement-content .notion{ diff --git a/themes/hexo/style.js b/themes/hexo/style.js index 33d2878a..8e789ca1 100644 --- a/themes/hexo/style.js +++ b/themes/hexo/style.js @@ -13,6 +13,12 @@ const Style = () => { .dark body{ background-color: black; } + // 文本不可选取 + .forbid-copy { + user-select: none; + -webkit-user-select: none; + -ms-user-select: none; + } /* 菜单下划线动画 */ #theme-hexo .menu-link { diff --git a/themes/landing/style.js b/themes/landing/style.js index 7a59e053..6f4aeb36 100644 --- a/themes/landing/style.js +++ b/themes/landing/style.js @@ -10,6 +10,12 @@ const Style = () => { .test { text-color: red; } + // 文本不可选取 + .forbid-copy { + user-select: none; + -webkit-user-select: none; + -ms-user-select: none; + } `} } diff --git a/themes/matery/style.js b/themes/matery/style.js index 711670c9..6263f78c 100644 --- a/themes/matery/style.js +++ b/themes/matery/style.js @@ -13,6 +13,12 @@ const Style = () => { .dark body{ background-color: black; } + // 文本不可选取 + .forbid-copy { + user-select: none; + -webkit-user-select: none; + -ms-user-select: none; + } /* 设置了从上到下的渐变黑色 */ #theme-matery .header-cover::before { diff --git a/themes/medium/style.js b/themes/medium/style.js index 5e8eaa5a..47e60906 100644 --- a/themes/medium/style.js +++ b/themes/medium/style.js @@ -11,6 +11,12 @@ const Style = () => { .dark body{ background-color: black; } + // 文本不可选取 + .forbid-copy { + user-select: none; + -webkit-user-select: none; + -ms-user-select: none; + } `} } diff --git a/themes/next/style.js b/themes/next/style.js index d01b13b3..86ca0fc1 100644 --- a/themes/next/style.js +++ b/themes/next/style.js @@ -14,6 +14,12 @@ const Style = () => { .dark body{ background-color: black; } + // 文本不可选取 + .forbid-copy { + user-select: none; + -webkit-user-select: none; + -ms-user-select: none; + } `} } diff --git a/themes/nobelium/style.js b/themes/nobelium/style.js index 5e8eaa5a..47e60906 100644 --- a/themes/nobelium/style.js +++ b/themes/nobelium/style.js @@ -11,6 +11,12 @@ const Style = () => { .dark body{ background-color: black; } + // 文本不可选取 + .forbid-copy { + user-select: none; + -webkit-user-select: none; + -ms-user-select: none; + } `} } diff --git a/themes/plog/style.js b/themes/plog/style.js index 23643fa9..d1db3053 100644 --- a/themes/plog/style.js +++ b/themes/plog/style.js @@ -10,6 +10,12 @@ const Style = () => { .dark body{ background-color: black; } + // 文本不可选取 + .forbid-copy { + user-select: none; + -webkit-user-select: none; + -ms-user-select: none; + } `} } diff --git a/themes/simple/style.js b/themes/simple/style.js index 647a404e..2bccde8a 100644 --- a/themes/simple/style.js +++ b/themes/simple/style.js @@ -11,6 +11,12 @@ const Style = () => { .dark body{ background-color: black; } + // 文本不可选取 + .forbid-copy { + user-select: none; + -webkit-user-select: none; + -ms-user-select: none; + } #theme-simple #announcement-content { /* background-color: #f6f6f6; */