11<script setup lang="ts">
22import type { Question , Word } from ' ../../types'
33import { getDefaultWord , IdentifyMethod , ShortcutKey , WordPracticeType } from ' ../../types'
4- import { useSettingStore } from ' ../../stores/setting'
5- import { useBaseStore } from ' ../../stores/base'
4+ import { useBaseStore , useSettingStore } from ' ../../stores'
65import { usePlayBeep , usePlayCorrect , usePlayKeyboardAudio , usePlayWordAudio , useTTsPlayAudio } from ' ../../hooks/sound'
76import { emitter , EventKey , useEventsByWatch } from ' ../../utils/eventBus'
87import { onMounted , onUnmounted , watch } from ' vue'
@@ -17,7 +16,7 @@ const { t: $t } = useI18n()
1716
1817interface IProps {
1918 word: Word
20- question: Question
19+ question? : Question
2120}
2221
2322const props = withDefaults (defineProps <IProps >(), {
@@ -214,7 +213,7 @@ function select(e, index: number) {
214213 if (completeSelect ) return
215214 if (isWordTest ) {
216215 completeSelect = true
217- if (index == props .question .correctIndex ) {
216+ if (index == props ? .question ? .correctIndex ) {
218217 input = props .word .word
219218 playCorrect ()
220219 emit (' know' )
@@ -744,7 +743,7 @@ const isCollect = $computed(() => isWordCollect(props.word))
744743 </div >
745744
746745 <div v-if =" isWordTest && !showWordResult" class =" flex gap-8 flex-col mt-16 mb-8 w-full" >
747- <div v-for =" (value, index) in question.candidates" class =" flex gap-2 min-h-20" >
746+ <div v-for =" (value, index) in question? .candidates ?? [] " class =" flex gap-2 min-h-20" >
748747 <BaseButton
749748 :keyboard =" `${$t('shortcut')}(${settingStore.shortcutKeyMap[[ShortcutKey.ChooseA, ShortcutKey.ChooseB, ShortcutKey.ChooseC, ShortcutKey.ChooseD][index]]})`"
750749 @click =" e => select(e, index)"
0 commit comments