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
|
||||
const darkScheme = window.matchMedia('(prefers-color-scheme: dark)');
|
||||
if (htmlClass.contains('dark')) {
|
||||
setDark(true);
|
||||
} else {
|
||||
const darkVal = localStorage.getItem('dark');
|
||||
setDark(darkVal ? darkVal === 'true' : darkScheme.matches);
|
||||
}
|
||||
|
||||
// listen system
|
||||
darkScheme.addEventListener('change', (event) => {
|
||||
|
|
Loading…
Reference in a new issue