diff --git a/src/App.vue b/src/App.vue index 6dd6649b..6c85af14 100644 --- a/src/App.vue +++ b/src/App.vue @@ -51,12 +51,7 @@ onMounted(() => { let configStr = localStorage.getItem(saveKey) if (configStr) { let obj: Config = JSON.parse(configStr) - config.newWords = obj.newWords - config.skipWords = obj.skipWords - config.skipWordNames = obj.skipWordNames - config.dict = obj.dict - config.chapterIndex = obj.chapterIndex - config.wordIndex = 0 + store.init(obj) } if (config.dict === 'nce2') { wordList = chunk(NCE_2, 15) as any @@ -66,7 +61,6 @@ onMounted(() => { } } - window.addEventListener('keydown', onKeyDown) }) @@ -178,7 +172,7 @@ function playAudio() {
{{ input }} {{ wrong }} - {{ word.name.slice(input.length + wrong.length) }} + {{ store.word.name.slice(input.length + wrong.length) }}
播放
diff --git a/src/stores/base.ts b/src/stores/base.ts index 3ba2afc9..b270f6aa 100644 --- a/src/stores/base.ts +++ b/src/stores/base.ts @@ -21,6 +21,12 @@ export const useBaseStore = defineStore('base', { }, actions: { init(config: Config) { + this.newWords = config.newWords + this.skipWords = config.skipWords + this.skipWordNames = config.skipWordNames + this.dict = config.dict + this.chapterIndex = config.chapterIndex + this.wordIndex = 0 }, }, }) \ No newline at end of file