diff --git a/docs/.vitepress/theme/components/VocabQuiz.vue b/docs/.vitepress/theme/components/VocabQuiz.vue index 269675b..8447c9a 100644 --- a/docs/.vitepress/theme/components/VocabQuiz.vue +++ b/docs/.vitepress/theme/components/VocabQuiz.vue @@ -66,7 +66,7 @@ import TTS from "./TTS.vue"; const vCats = ref([]); const vChosenCats = ref([]); const vList = ref([]); -const vIndex = ref(0); +const vIndex = ref(-1); const vSentAutoplayAudio = ref(true); const sentenceDetails = useTemplateRef("sdetails"); @@ -124,10 +124,20 @@ function mark(isRight: boolean) { if (sentenceDetails.value) { sentenceDetails.value.open = false; } + + if (vSentAutoplayAudio.value) { + if (stts.value) { + stts.value.playAudio(); + } else if (example.value?.audio) { + new Audio(example.value.audio).play(); + } + } }); if (isRight) { vList.value = [...vList.value.filter((_, i) => i !== vIndex.value)]; + vIndex.value = -1; + if (vList.value.length === 0) { makeVList(); return; @@ -143,16 +153,6 @@ function mark(isRight: boolean) { } else { vIndex.value = i; } - - if (vSentAutoplayAudio.value) { - nextTick(() => { - if (stts.value) { - stts.value.playAudio(); - } else if (example.value?.audio) { - new Audio(example.value.audio).play(); - } - }); - } } function updateCats(cat: string) {