Skip to content

Commit

Permalink
fix: save the theme mode to localStorage (#468)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeeChenn authored Apr 1, 2024
1 parent c1f4ad6 commit 39dc3ac
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions apps/client/composables/darkMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function useDarkMode() {
window.matchMedia &&
window.matchMedia("(prefers-color-scheme: dark)").matches;

const cacheDarkMode = sessionStorage.getItem(DARK_MODE) as Theme | null;
const cacheDarkMode = localStorage.getItem(DARK_MODE) as Theme | null;

const initDarkMode = () => {
if (isDarkMode && !cacheDarkMode) {
Expand Down Expand Up @@ -85,7 +85,7 @@ export function useDarkMode() {
document.documentElement.classList.toggle(DARK_THEME_CLASS, state);
document.documentElement.setAttribute("data-theme", themeClass);
darkMode.value = themeValue;
sessionStorage.setItem(DARK_MODE, themeValue);
localStorage.setItem(DARK_MODE, themeValue);
};

return {
Expand Down

0 comments on commit 39dc3ac

Please sign in to comment.