Skip to content

Commit

Permalink
perf(comment): 评论区支持动态黑暗模式切换
Browse files Browse the repository at this point in the history
  • Loading branch information
nineya committed Jan 3, 2024
1 parent d4c7ca6 commit 32b10fa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ const commonContext = {
} else {
document.documentElement.classList.remove('night')
}
$('.comment-section>div').each(function () {
const shadowDom = this.shadowRoot.querySelectorAll('.halo-comment-widget')[0]
$(shadowDom)[`${isNightValue ? 'add' : 'remove'}Class`]('dark')
$(shadowDom)[`${isNightValue ? 'remove' : 'add'}Class`]('light')
})
localStorage.setItem('night', isNightValue)
isNight = isNightValue
}
Expand Down Expand Up @@ -418,7 +423,7 @@ const commonContext = {
group: target === 'Moment' ? 'moment.halo.run' : 'content.halo.run',
kind: target,
name: id,
colorScheme: window.dataTheme
colorScheme: (localStorage.getItem('night') !== 'true' ? 'light' : 'dark')
}
)
})
Expand Down
2 changes: 1 addition & 1 deletion templates/assets/css/style.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion templates/assets/js/common.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 32b10fa

Please sign in to comment.