fix light toggle
This commit is contained in:
parent
a60c1fef23
commit
dba1380966
1 changed files with 9 additions and 6 deletions
|
@ -1,5 +1,12 @@
|
|||
function themeToggle() {
|
||||
const oldValue = localStorage.getItem('theme');
|
||||
let oldValue = localStorage.getItem('theme');
|
||||
if (!oldValue) {
|
||||
oldValue = 'light';
|
||||
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
||||
oldValue = 'dark';
|
||||
}
|
||||
}
|
||||
|
||||
let newValue;
|
||||
if (oldValue == 'light') {
|
||||
newValue = 'dark';
|
||||
|
@ -15,11 +22,7 @@ function themeClear() {
|
|||
themeRefresh();
|
||||
}
|
||||
|
||||
function themeRefresh(newValue) {
|
||||
if (newValue !== undefined) {
|
||||
localStorage.setItem('theme', newValue);
|
||||
}
|
||||
|
||||
function themeRefresh() {
|
||||
const theme = localStorage.getItem('theme')
|
||||
const el = document.getElementsByTagName('html')[0];
|
||||
if (theme == 'light') {
|
||||
|
|
Loading…
Add table
Reference in a new issue