File tree Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,9 @@ import StoreUpdateCountStatus from "@/components/StoreUpdateCountStatus.vue";
6
6
import ManualControlView from " @/views/ManualControlView.vue" ;
7
7
import ProtocolList from " @/components/protocol/ProtocolList.vue" ;
8
8
import {useQuasar } from " quasar" ;
9
+ import {useUiStateStore } from " @/store/uiState" ;
10
+
11
+ const uiState = useUiStateStore ()
9
12
10
13
const leftDrawerOpen = ref (false )
11
14
const toggleLeftDrawer = () => {
@@ -19,6 +22,11 @@ const $q = useQuasar()
19
22
const darkMode = computed (() => $q .dark .isActive )
20
23
const toggleDarkMode = () => {
21
24
$q .dark .toggle ()
25
+ uiState .darkMode = $q .dark .isActive
26
+ }
27
+
28
+ if (uiState .darkMode !== undefined ) {
29
+ $q .dark .set (uiState .darkMode )
22
30
}
23
31
24
32
const dev = computed (() => {
Original file line number Diff line number Diff line change 1
1
import { createApp } from 'vue'
2
2
import App from './App.vue'
3
+ import { subscribeToLocalStorage } from "@/store/uiState" ;
3
4
4
5
import { createPinia } from "pinia" ;
5
6
import router from './router'
@@ -28,3 +29,5 @@ createApp(App)
28
29
}
29
30
} )
30
31
. mount ( '#app' )
32
+
33
+ subscribeToLocalStorage ( )
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ interface UiState {
7
7
teamDetailsFoulsExpanded : boolean ,
8
8
teamDetailsYellowCardsExpanded : boolean ,
9
9
teamDetailsRedCardsExpanded : boolean ,
10
+ darkMode ?: boolean ,
10
11
}
11
12
12
13
export const useUiStateStore = defineStore ( 'uiState' , {
@@ -16,6 +17,7 @@ export const useUiStateStore = defineStore('uiState', {
16
17
teamDetailsFoulsExpanded : true ,
17
18
teamDetailsYellowCardsExpanded : true ,
18
19
teamDetailsRedCardsExpanded : true ,
20
+ darkMode : undefined ,
19
21
}
20
22
const storedData = localStorage . getItem ( 'ui-state' )
21
23
if ( storedData ) {
@@ -25,6 +27,8 @@ export const useUiStateStore = defineStore('uiState', {
25
27
} ,
26
28
} )
27
29
28
- useUiStateStore ( ) . $subscribe ( ( mutation : SubscriptionCallbackMutation < UiState > , state : UnwrapRef < UiState > ) => {
29
- localStorage . setItem ( 'ui-state' , JSON . stringify ( state ) )
30
- } )
30
+ export function subscribeToLocalStorage ( ) {
31
+ useUiStateStore ( ) . $subscribe ( ( mutation : SubscriptionCallbackMutation < UiState > , state : UnwrapRef < UiState > ) => {
32
+ localStorage . setItem ( 'ui-state' , JSON . stringify ( state ) )
33
+ } )
34
+ }
You can’t perform that action at this time.
0 commit comments