fix merge

This commit is contained in:
Jerry
2023-04-10 16:49:53 +08:00
2 changed files with 7 additions and 3 deletions

View File

@@ -316,6 +316,9 @@ darkmode:
# autoChangeMode: 2 Switch dark mode between 6 pm to 6 am # autoChangeMode: 2 Switch dark mode between 6 pm to 6 am
# autoChangeMode: false # autoChangeMode: false
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 # show scroll percent in scroll-to-top button
rightside_scroll_percent: false rightside_scroll_percent: false

View File

@@ -7,7 +7,8 @@
hexo.extend.helper.register('inject_head_js', function () { hexo.extend.helper.register('inject_head_js', function () {
const { darkmode, aside } = this.theme 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 { theme_color } = hexo.theme.config
const themeColorLight = (theme_color && theme_color.enable && theme_color.meta_theme_color_light) || '#ffffff' 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' 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) { else if (isNotSpecified || hasNoSupport) {
const now = new Date() const now = new Date()
const hour = now.getHours() const hour = now.getHours()
const isNight = hour <= 6 || hour >= 18 const isNight = hour <= ${start} || hour >= ${end}
isNight ? activateDarkMode() : activateLightMode() isNight ? activateDarkMode() : activateLightMode()
} }
window.matchMedia('(prefers-color-scheme: dark)').addListener(function (e) { window.matchMedia('(prefers-color-scheme: dark)').addListener(function (e) {
@@ -125,7 +126,7 @@ hexo.extend.helper.register('inject_head_js', function () {
darkmodeJs += ` darkmodeJs += `
const now = new Date() const now = new Date()
const hour = now.getHours() const hour = now.getHours()
const isNight = hour <= 6 || hour >= 18 const isNight = hour <= ${start} || hour >= ${end}
if (t === undefined) isNight ? activateDarkMode() : activateLightMode() if (t === undefined) isNight ? activateDarkMode() : activateLightMode()
else if (t === 'light') activateLightMode() else if (t === 'light') activateLightMode()
else activateDarkMode() else activateDarkMode()