-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup state and store for toggling advanced mode
- Loading branch information
Showing
2 changed files
with
55 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { computed, onMounted, ref } from '@vue/composition-api'; | ||
import { LocalStorage } from 'quasar'; | ||
|
||
// Shared state between instances | ||
const advancedMode = ref(false); // true if user has advanced mode turned on | ||
|
||
// Composition function for managing state | ||
export default function useSettingsStore() { | ||
onMounted(() => (advancedMode.value = Boolean(LocalStorage.getItem('advanced-mode')))); | ||
|
||
function toggleAdvancedMode() { | ||
advancedMode.value = !advancedMode.value; | ||
LocalStorage.set('advanced-mode', advancedMode.value); | ||
} | ||
|
||
return { toggleAdvancedMode, advancedMode: computed(() => advancedMode.value) }; | ||
} |