Skip to content

Commit

Permalink
feat: memorize show error state (#117)
Browse files Browse the repository at this point in the history
Co-authored-by: 三咲智子 Kevin Deng <[email protected]>
  • Loading branch information
chenxch and sxzz authored Jun 26, 2023
1 parent 434d64a commit ab4b7cd
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/editor/EditorContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,36 @@
import FileSelector from './FileSelector.vue'
import Message from '../Message.vue'
import { debounce } from '../utils'
import { inject, ref } from 'vue'
import { inject, ref, watch } from 'vue'
import { Store } from '../store'
import MessageToggle from './MessageToggle.vue'
import type { EditorComponentType } from './types'
const SHOW_ERROR_KEY = 'repl_show_error'
const props = defineProps<{
editorComponent: EditorComponentType
}>()
const store = inject('store') as Store
const showMessage = ref(true)
const showMessage = ref(getItem())
const onChange = debounce((code: string) => {
store.state.activeFile.code = code
}, 250)
function setItem() {
localStorage.setItem(SHOW_ERROR_KEY, showMessage.value ? 'true' : 'false')
}
function getItem() {
const item = localStorage.getItem(SHOW_ERROR_KEY)
return !(item === 'false')
}
watch(showMessage, () => {
setItem()
})
</script>

<template>
Expand Down

0 comments on commit ab4b7cd

Please sign in to comment.