From 63353566d21c936c8bcc12be973d1b3015b13541 Mon Sep 17 00:00:00 2001 From: Leonus <553344777@qq.com> Date: Sun, 9 Apr 2023 00:03:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E6=B7=B1=E6=B5=85=E6=A8=A1=E5=BC=8F=E5=88=87=E6=8D=A2=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _config.yml | 3 +++ scripts/helpers/inject_head_js.js | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/_config.yml b/_config.yml index 57d523a46..ac4288816 100644 --- a/_config.yml +++ b/_config.yml @@ -760,6 +760,9 @@ darkmode: # autoChangeMode: 2 Switch dark mode between 6 pm to 6 am # autoChangeMode: false autoChangeMode: false + # Set the light mode time. The value is between 0 and 24. If not set, the default value is 6 and 18 + start: # 8 + end: # 22 # show scroll percent in scroll-to-top button rightside_scroll_percent: false diff --git a/scripts/helpers/inject_head_js.js b/scripts/helpers/inject_head_js.js index 25a65c8e9..e4ad6fb15 100644 --- a/scripts/helpers/inject_head_js.js +++ b/scripts/helpers/inject_head_js.js @@ -7,7 +7,8 @@ hexo.extend.helper.register('inject_head_js', function () { const { darkmode, aside } = this.theme - + const start = darkmode.start ? darkmode.start : 6 + const end = darkmode.end ? darkmode.end : 18 const { theme_color } = hexo.theme.config const themeColorLight = (theme_color && theme_color.enable && theme_color.meta_theme_color_light) || '#ffffff' const themeColorDark = (theme_color && theme_color.enable && theme_color.meta_theme_color_dark) || '#0d0d0d' @@ -110,7 +111,7 @@ hexo.extend.helper.register('inject_head_js', function () { else if (isNotSpecified || hasNoSupport) { const now = new Date() const hour = now.getHours() - const isNight = hour <= 6 || hour >= 18 + const isNight = hour <= ${start} || hour >= ${end} isNight ? activateDarkMode() : activateLightMode() } window.matchMedia('(prefers-color-scheme: dark)').addListener(function (e) { @@ -125,7 +126,7 @@ hexo.extend.helper.register('inject_head_js', function () { darkmodeJs += ` const now = new Date() const hour = now.getHours() - const isNight = hour <= 6 || hour >= 18 + const isNight = hour <= ${start} || hour >= ${end} if (t === undefined) isNight ? activateDarkMode() : activateLightMode() else if (t === 'light') activateLightMode() else activateDarkMode()