mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-10-04 06:22:00 +08:00
label: 3.2.0
fix: 修復當hexo的_config沒有設置description時,會導致pjax在頁面與文章間切換會無效 close #381 improvement: 當隱藏部分沒配置時,左下角設置按鈕會消失 #353 improvement: 網站背景可配置 (顏色(HEX值/RGB值/顔色單詞/漸變色)/漸變色/圖片鏈接) improvement: 夜間模式下,背景顔色/top-img/footer-bg 設置為顔色時,不再強制顯示黑色,而是改為遮罩降低亮度
This commit is contained in:
1 parent
d5670e25e4
commit
de11040293
11 files changed
+85
-94
No files matched your search
+1
-3
@@ -486,12 +486,10 @@ tag_ui: # 留空或 index
|
|||||||
|
|
||||||
# Website Background (設置網站背景)
|
# Website Background (設置網站背景)
|
||||||
# can set it to color or image (可設置圖片 或者 顔色)
|
# can set it to color or image (可設置圖片 或者 顔色)
|
||||||
# The formal of color: '#49B202'
|
|
||||||
# The formal of image: url(http://xxxxxx.com/xxx.jpg)
|
# The formal of image: url(http://xxxxxx.com/xxx.jpg)
|
||||||
# White color will be shown as default
|
|
||||||
background:
|
background:
|
||||||
|
|
||||||
# Show the footer background image (same as top_img)
|
# Footer Background
|
||||||
footer_bg: false
|
footer_bg: false
|
||||||
|
|
||||||
# the position of bottom right button/default unit: px (右下角按鈕距離底部的距離/默認單位為px)
|
# the position of bottom right button/default unit: px (右下角按鈕距離底部的距離/默認單位為px)
|
||||||
|
|||||||
+1
-2
@@ -13,8 +13,7 @@ html(lang=config.language data-theme=theme.display_mode)
|
|||||||
canvas.fireworks
|
canvas.fireworks
|
||||||
|
|
||||||
if theme.background
|
if theme.background
|
||||||
- var is_photo = theme.background.startsWith('url') ? 'photo':'color'
|
#web_bg
|
||||||
#web_bg(data-type=is_photo)
|
|
||||||
|
|
||||||
#error-wrap
|
#error-wrap
|
||||||
.error-content
|
.error-content
|
||||||
|
|||||||
@@ -1,50 +1,53 @@
|
|||||||
if theme.darkmode.enable
|
if theme.darkmode.enable
|
||||||
script.
|
script.
|
||||||
var activateDarkMode = function () {
|
(function () {
|
||||||
document.documentElement.setAttribute('data-theme', 'dark')
|
window.activateDarkMode = function () {
|
||||||
if (document.querySelector('meta[name="theme-color"]') !== null) {
|
document.documentElement.setAttribute('data-theme', 'dark')
|
||||||
document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
|
if (document.querySelector('meta[name="theme-color"]') !== null) {
|
||||||
}
|
document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
|
||||||
}
|
|
||||||
var activateLightMode = function () {
|
|
||||||
document.documentElement.setAttribute('data-theme', 'light')
|
|
||||||
if (document.querySelector('meta[name="theme-color"]') !== null) {
|
|
||||||
document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var autoChangeMode = '#{theme.darkmode.autoChangeMode}'
|
|
||||||
var t = saveToLocal.get('theme')
|
|
||||||
if (autoChangeMode === '1') {
|
|
||||||
var isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
||||||
var isLightMode = window.matchMedia('(prefers-color-scheme: light)').matches
|
|
||||||
var isNotSpecified = window.matchMedia('(prefers-color-scheme: no-preference)').matches
|
|
||||||
var hasNoSupport = !isDarkMode && !isLightMode && !isNotSpecified
|
|
||||||
|
|
||||||
if (t === undefined) {
|
|
||||||
if (isLightMode) activateLightMode()
|
|
||||||
else if (isDarkMode) activateDarkMode()
|
|
||||||
else if (isNotSpecified || hasNoSupport) {
|
|
||||||
var now = new Date()
|
|
||||||
var hour = now.getHours()
|
|
||||||
var isNight = hour <= 6 || hour >= 18
|
|
||||||
isNight ? activateDarkMode() : activateLightMode()
|
|
||||||
}
|
}
|
||||||
window.matchMedia('(prefers-color-scheme: dark)').addListener(function (e) {
|
}
|
||||||
if (saveToLocal.get('theme') === undefined) {
|
window.activateLightMode = function () {
|
||||||
e.matches ? activateDarkMode() : activateLightMode()
|
document.documentElement.setAttribute('data-theme', 'light')
|
||||||
|
if (document.querySelector('meta[name="theme-color"]') !== null) {
|
||||||
|
document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const autoChangeMode = '#{theme.darkmode.autoChangeMode}'
|
||||||
|
const t = saveToLocal.get('theme')
|
||||||
|
if (autoChangeMode === '1') {
|
||||||
|
const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches
|
||||||
|
const isLightMode = window.matchMedia('(prefers-color-scheme: light)').matches
|
||||||
|
const isNotSpecified = window.matchMedia('(prefers-color-scheme: no-preference)').matches
|
||||||
|
const hasNoSupport = !isDarkMode && !isLightMode && !isNotSpecified
|
||||||
|
|
||||||
|
if (t === undefined) {
|
||||||
|
if (isLightMode) activateLightMode()
|
||||||
|
else if (isDarkMode) activateDarkMode()
|
||||||
|
else if (isNotSpecified || hasNoSupport) {
|
||||||
|
const now = new Date()
|
||||||
|
const hour = now.getHours()
|
||||||
|
const isNight = hour <= 6 || hour >= 18
|
||||||
|
isNight ? activateDarkMode() : activateLightMode()
|
||||||
}
|
}
|
||||||
})
|
window.matchMedia('(prefers-color-scheme: dark)').addListener(function (e) {
|
||||||
} else if (t === 'light') activateLightMode()
|
if (saveToLocal.get('theme') === undefined) {
|
||||||
else activateDarkMode()
|
e.matches ? activateDarkMode() : activateLightMode()
|
||||||
} else if (autoChangeMode === '2') {
|
}
|
||||||
now = new Date()
|
})
|
||||||
hour = now.getHours()
|
} else if (t === 'light') activateLightMode()
|
||||||
isNight = hour <= 6 || hour >= 18
|
else activateDarkMode()
|
||||||
if (t === undefined) isNight ? activateDarkMode() : activateLightMode()
|
} else if (autoChangeMode === '2') {
|
||||||
else if (t === 'light') activateLightMode()
|
const now = new Date()
|
||||||
else activateDarkMode()
|
const hour = now.getHours()
|
||||||
} else {
|
const isNight = hour <= 6 || hour >= 18
|
||||||
if (t === 'dark') activateDarkMode()
|
if (t === undefined) isNight ? activateDarkMode() : activateLightMode()
|
||||||
else if (t === 'light') activateLightMode()
|
else if (t === 'light') activateLightMode()
|
||||||
}
|
else activateDarkMode()
|
||||||
|
} else {
|
||||||
|
if (t === 'dark') activateDarkMode()
|
||||||
|
else if (t === 'light') activateLightMode()
|
||||||
|
}
|
||||||
|
})()
|
||||||
|
|
||||||
Loaded 3 of 11 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user