forked from jerryc127/hexo-theme-butterfly
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 修復當hexo的_config沒有設置description時,會導致pjax在頁面與文章間切換會無效 close jerryc127#381 improvement: 當隱藏部分沒配置時,左下角設置按鈕會消失 jerryc127#353 improvement: 網站背景可配置 (顏色(HEX值/RGB值/顔色單詞/漸變色)/漸變色/圖片鏈接) improvement: 夜間模式下,背景顔色/top-img/footer-bg 設置為顔色時,不再強制顯示黑色,而是改為遮罩降低亮度
- Loading branch information
Showing
11 changed files
with
83 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,53 @@ | ||
if theme.darkmode.enable | ||
script. | ||
var activateDarkMode = function () { | ||
document.documentElement.setAttribute('data-theme', 'dark') | ||
if (document.querySelector('meta[name="theme-color"]') !== null) { | ||
document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d') | ||
(function () { | ||
window.activateDarkMode = function () { | ||
document.documentElement.setAttribute('data-theme', 'dark') | ||
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') | ||
window.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 | ||
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) { | ||
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) { | ||
e.matches ? activateDarkMode() : activateLightMode() | ||
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() | ||
} | ||
}) | ||
} else if (t === 'light') activateLightMode() | ||
else activateDarkMode() | ||
} else if (autoChangeMode === '2') { | ||
now = new Date() | ||
hour = now.getHours() | ||
isNight = hour <= 6 || hour >= 18 | ||
if (t === undefined) isNight ? activateDarkMode() : activateLightMode() | ||
else if (t === 'light') activateLightMode() | ||
else activateDarkMode() | ||
} else { | ||
if (t === 'dark') activateDarkMode() | ||
else if (t === 'light') activateLightMode() | ||
} | ||
window.matchMedia('(prefers-color-scheme: dark)').addListener(function (e) { | ||
if (saveToLocal.get('theme') === undefined) { | ||
e.matches ? activateDarkMode() : activateLightMode() | ||
} | ||
}) | ||
} else if (t === 'light') activateLightMode() | ||
else activateDarkMode() | ||
} else if (autoChangeMode === '2') { | ||
const now = new Date() | ||
const hour = now.getHours() | ||
const isNight = hour <= 6 || hour >= 18 | ||
if (t === undefined) isNight ? activateDarkMode() : activateLightMode() | ||
else if (t === 'light') activateLightMode() | ||
else activateDarkMode() | ||
} else { | ||
if (t === 'dark') activateDarkMode() | ||
else if (t === 'light') activateLightMode() | ||
} | ||
})() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,31 @@ | ||
section#rightside | ||
#rightside-config-hide | ||
if is_post() | ||
if theme.readmode | ||
button#readmode(type="button" title=_p('rightside.readmode_title')) | ||
i.fas.fa-book-open | ||
if theme.translate && theme.translate.enable | ||
if is_post() && theme.readmode | ||
button#readmode(type="button" title=_p('rightside.readmode_title')) | ||
i.fas.fa-book-open | ||
if theme.translate.enable | ||
button#translateLink(type="button" title=_p('rightside.translate_title'))= theme.translate.default | ||
if theme.darkmode.enable && theme.darkmode.button | ||
button#darkmode(type="button" title=_p('rightside.night_mode_title')) | ||
i.fas.fa-adjust | ||
#rightside-config-show | ||
button#rightside_config(type="button" title=_p("rightside.setting")) | ||
i.fas.fa-cog | ||
if is_post() && page.comments !== false && theme.comments.use | ||
a#to_comment(href="#post-comment" title=_p("rightside.scroll_to_comment")) | ||
i.fas.fa-comments | ||
if showToc | ||
button#mobile-toc-button.close(type="button" title=_p("rightside.toc")) | ||
i.fas.fa-list-ul | ||
if is_post() | ||
if (theme.readmode || theme.translate.enable || (theme.darkmode.enable && theme.darkmode.button)) | ||
button#rightside_config(type="button" title=_p("rightside.setting")) | ||
i.fas.fa-cog | ||
if commentsJsLoad | ||
a#to_comment(href="#post-comment" title=_p("rightside.scroll_to_comment")) | ||
i.fas.fa-comments | ||
if showToc | ||
button#mobile-toc-button.close(type="button" title=_p("rightside.toc")) | ||
i.fas.fa-list-ul | ||
else if theme.translate.enable || (theme.darkmode.enable && theme.darkmode.button) | ||
button#rightside_config(type="button" title=_p("rightside.setting")) | ||
i.fas.fa-cog | ||
|
||
if theme.chat_btn | ||
button#chat_btn(type="button" title=_p("rightside.chat_btn")) | ||
i.fas.fa-sms | ||
|
||
button#go-up(type="button" title=_p("rightside.back_to_top")) | ||
i.fas.fa-arrow-up | ||
|
||
|
||
i.fas.fa-arrow-up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters