feat: save theme to the localStorage

This commit is contained in:
Terry Geng 2020-03-12 09:25:10 +08:00
parent a750eeeab6
commit 7e768c926d
2 changed files with 12 additions and 5 deletions

File diff suppressed because one or more lines are too long

View File

@ -435,15 +435,21 @@
} }
var theme = "light"; function themeInit(){
var theme = localStorage.getItem("theme");
if(theme !== null){
setPageTheme(theme);
}
}
function switchTheme(){ function switchTheme(){
if(theme === "light"){ var theme = localStorage.getItem("theme");
if(theme === "light" || theme === null){
setPageTheme("dark"); setPageTheme("dark");
theme = "dark"; localStorage.setItem("theme", "dark");
}else{ }else{
setPageTheme("light"); setPageTheme("light");
theme = "light"; localStorage.setItem("theme", "light");
} }
} }
@ -471,6 +477,7 @@
}); });
} , 3000); } , 3000);
themeInit();
$(document).ready(updatePlaylist); $(document).ready(updatePlaylist);
</script> </script>