mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-16 17:40:55 +08:00
添加缺省值
This commit is contained in:
@@ -9,6 +9,8 @@ hexo.extend.helper.register('inject_head_js', function () {
|
||||
const { darkmode, aside } = this.theme
|
||||
|
||||
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'
|
||||
|
||||
const localStore = `
|
||||
win.saveToLocal = {
|
||||
@@ -64,13 +66,13 @@ hexo.extend.helper.register('inject_head_js', function () {
|
||||
win.activateDarkMode = function () {
|
||||
document.documentElement.setAttribute('data-theme', 'dark')
|
||||
if (document.querySelector('meta[name="theme-color"]') !== null) {
|
||||
document.querySelector('meta[name="theme-color"]').setAttribute('content', '${theme_color.meta_theme_color_dark}')
|
||||
document.querySelector('meta[name="theme-color"]').setAttribute('content', '${themeColorDark}')
|
||||
}
|
||||
}
|
||||
win.activateLightMode = function () {
|
||||
document.documentElement.setAttribute('data-theme', 'light')
|
||||
if (document.querySelector('meta[name="theme-color"]') !== null) {
|
||||
document.querySelector('meta[name="theme-color"]').setAttribute('content', '${theme_color.meta_theme_color_light}')
|
||||
document.querySelector('meta[name="theme-color"]').setAttribute('content', '${themeColorLight}')
|
||||
}
|
||||
}
|
||||
const t = saveToLocal.get('theme')
|
||||
|
||||
Reference in New Issue
Block a user