Skip to content

Commit

Permalink
chore(sfc-playground): persistent autoSave with localStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
phk422 committed Sep 10, 2024
1 parent 532dcf2 commit 414846f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages-private/sfc-playground/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ window.addEventListener('resize', setVH)
setVH()
const useSSRMode = ref(false)
const autoSave = ref(true)
const AUTO_SAVE_STORAGE_KEY = 'vue-sfc-playground-auto-save'
const initAutoSave: boolean = JSON.parse(localStorage.getItem(AUTO_SAVE_STORAGE_KEY) ?? 'true')
const autoSave = ref(initAutoSave)
const { productionMode, vueVersion, importMap } = useVueImportMap({
runtimeDev: import.meta.env.PROD
Expand Down Expand Up @@ -92,6 +95,7 @@ function toggleSSR() {
function toggleAutoSave() {
autoSave.value = !autoSave.value
localStorage.setItem(AUTO_SAVE_STORAGE_KEY, String(autoSave.value))
}
function reloadPage() {
Expand Down

0 comments on commit 414846f

Please sign in to comment.