Skip to content

Commit 1307c8a

Browse files
committed
fix: type error
1 parent ada7191 commit 1307c8a

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

packages/core/src/components/word/TypeWord.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<script setup lang="ts">
22
import type { Question, Word } from '../../types'
33
import { getDefaultWord, IdentifyMethod, ShortcutKey, WordPracticeType } from '../../types'
4-
import { useSettingStore } from '../../stores/setting'
5-
import { useBaseStore } from '../../stores/base'
4+
import { useBaseStore, useSettingStore } from '../../stores'
65
import { usePlayBeep, usePlayCorrect, usePlayKeyboardAudio, usePlayWordAudio, useTTsPlayAudio } from '../../hooks/sound'
76
import { emitter, EventKey, useEventsByWatch } from '../../utils/eventBus'
87
import { onMounted, onUnmounted, watch } from 'vue'
@@ -17,7 +16,7 @@ const { t: $t } = useI18n()
1716
1817
interface IProps {
1918
word: Word
20-
question: Question
19+
question?: Question
2120
}
2221
2322
const 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

Comments
 (0)