添加缺省值

This commit is contained in:
ImCaO 2022-02-28 09:48:51 +08:00
parent 7ebed025f0
commit 0726c2263f
No known key found for this signature in database
GPG Key ID: E7B267EBE9D31E0B
2 changed files with 7 additions and 3 deletions

View File

@ -16,7 +16,9 @@
- else pageKeywords = Array.isArray(config.keywords) ? (config.keywords).join(','): ([]).join(',') || config.keywords
- var pageAuthor = config.email ? config.author + ',' + config.email : config.author
- var pageCopyright = config.copyright || config.author
- var themeColor = theme.display_mode === 'dark' ? theme.theme_color.meta_theme_color_dark : theme.theme_color.meta_theme_color_light
- var themeColorLight = theme.theme_color && theme.theme_color.enable && theme.theme_color.meta_theme_color_light || '#ffffff'
- var themeColorDark = theme.theme_color && theme.theme_color.enable && theme.theme_color.meta_theme_color_dark || '#0d0d0d'
- var themeColor = theme.display_mode === 'dark' ? themeColorDark : themeColorLight
meta(charset='UTF-8')
meta(http-equiv="X-UA-Compatible" content="IE=edge")

View File

@ -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')