File tree Expand file tree Collapse file tree 3 files changed +15
-1
lines changed
Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,8 @@ import { useThemeStore } from '@/stores/themeStore'
101101import { useMainStore } from ' @/stores'
102102
103103const themeStore = useThemeStore ()
104+ themeStore .applyTheme ()
105+
104106const store = useMainStore ()
105107
106108const props = defineProps <{
Original file line number Diff line number Diff line change 11import { defineStore } from 'pinia'
2- import { ref } from 'vue'
2+ import { ref , onMounted } from 'vue'
33
44export const useThemeStore = defineStore ( 'theme' , ( ) => {
55 const isDarkTheme = ref ( false )
@@ -9,9 +9,19 @@ export const useThemeStore = defineStore('theme', () => {
99 document . documentElement . classList . toggle ( 'dark' , isDarkTheme . value )
1010 }
1111
12+ const applyTheme = ( ) => {
13+ document . documentElement . classList . toggle ( 'dark' , isDarkTheme . value )
14+ }
15+
16+ // Check the saved theme when the store is created
17+ onMounted ( ( ) => {
18+ applyTheme ( )
19+ } )
20+
1221 return {
1322 isDarkTheme,
1423 toggleTheme,
24+ applyTheme
1525 }
1626} , {
1727 persist : true
Original file line number Diff line number Diff line change @@ -43,6 +43,8 @@ import AppLayout from '@/components/AppLayout.vue'
4343import { api } from ' @/api'
4444
4545const themeStore = useThemeStore ()
46+ themeStore .applyTheme ()
47+
4648const router = useRouter ()
4749const store = useMainStore ()
4850const loading = ref (false )
You can’t perform that action at this time.
0 commit comments