Merge pull request #981 from fgprodigal/patch

feat: new config APPEARANCE_DARK_TIME
This commit is contained in:
tangly1024
2023-04-18 14:41:49 +08:00
committed by GitHub
2 changed files with 115 additions and 46 deletions

View File

@@ -51,7 +51,7 @@ export function isPreferDark() {
// 系统深色模式或时间是夜间时,强行置为夜间模式
const date = new Date()
const prefersDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches
return prefersDarkMode || (date.getHours() >= 18 || date.getHours() < 6)
return prefersDarkMode || (BLOG.APPEARANCE_DARK_TIME && (date.getHours() >= BLOG.APPEARANCE_DARK_TIME[0] || date.getHours() < BLOG.APPEARANCE_DARK_TIME[1]))
}
return false
}