perf(comment): 评论区支持动态黑暗模式切换

This commit is contained in:
nineya 2024-01-03 17:02:33 +08:00
parent d4c7ca6c1b
commit 32b10fa108
3 changed files with 8 additions and 3 deletions

View File

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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long