refine theme logic
This commit is contained in:
parent
bdeb5df5a5
commit
2ba0c005b9
1 changed files with 6 additions and 2 deletions
|
@ -37,8 +37,12 @@
|
||||||
|
|
||||||
// init
|
// init
|
||||||
const darkScheme = window.matchMedia('(prefers-color-scheme: dark)');
|
const darkScheme = window.matchMedia('(prefers-color-scheme: dark)');
|
||||||
const darkVal = localStorage.getItem('dark');
|
if (htmlClass.contains('dark')) {
|
||||||
setDark(darkVal ? darkVal === 'true' : darkScheme.matches);
|
setDark(true);
|
||||||
|
} else {
|
||||||
|
const darkVal = localStorage.getItem('dark');
|
||||||
|
setDark(darkVal ? darkVal === 'true' : darkScheme.matches);
|
||||||
|
}
|
||||||
|
|
||||||
// listen system
|
// listen system
|
||||||
darkScheme.addEventListener('change', (event) => {
|
darkScheme.addEventListener('change', (event) => {
|
||||||
|
|
Loading…
Reference in a new issue