1
0
Fork 0

refine theme logic

This commit is contained in:
nanxiaobei 2022-10-24 21:31:58 +08:00
parent bdeb5df5a5
commit 2ba0c005b9

View file

@ -37,8 +37,12 @@
// init
const darkScheme = window.matchMedia('(prefers-color-scheme: dark)');
const darkVal = localStorage.getItem('dark');
setDark(darkVal ? darkVal === 'true' : darkScheme.matches);
if (htmlClass.contains('dark')) {
setDark(true);
} else {
const darkVal = localStorage.getItem('dark');
setDark(darkVal ? darkVal === 'true' : darkScheme.matches);
}
// listen system
darkScheme.addEventListener('change', (event) => {