fix:optimize the article practice

This commit is contained in:
zyronon
2025-09-02 22:36:17 +08:00
parent 5bfabd24f7
commit da11913bb7
5 changed files with 27 additions and 10 deletions

View File

@@ -149,6 +149,7 @@ function setArticle(val: Article) {
articleData.article.sections.map((v, i) => {
v.map((w, j) => {
w.words.map(s => {
s.input = ''
if (!ignoreList.includes(s.word.toLowerCase()) && !s.isSymbol) {
statisticsStore.total++
}
@@ -188,6 +189,10 @@ function edit(val: Article = articleData.article) {
function wrong(word: Word) {
let temp = word.word.toLowerCase();
//过滤简单词
if (settingStore.ignoreSimpleWord) {
if (this.simpleWords.includes(temp)) return
}
if (!allWrongWords.has(word.word.toLowerCase())) {
allWrongWords.add(word.word.toLowerCase())
statisticsStore.wrong++
@@ -277,6 +282,12 @@ onUnmounted(() => {
let audioRef = $ref<HTMLAudioElement>()
const {playSentenceAudio} = usePlaySentenceAudio()
function play2(e) {
if (settingStore.wordSound || e.handle) {
playSentenceAudio(e.sentence, audioRef, articleData.article)
}
}
</script>
<template>
<PracticeLayout
@@ -289,7 +300,7 @@ const {playSentenceAudio} = usePlaySentenceAudio()
@wrong="wrong"
@next="next"
@nextWord="nextWord"
@play="e => playSentenceAudio(e,audioRef,articleData.article)"
@play="play2"
:article="articleData.article"
/>
</template>

View File

@@ -35,7 +35,10 @@ const props = withDefaults(defineProps<IProps>(), {
const emit = defineEmits<{
ignore: [],
wrong: [val: Word],
play: [val: Sentence],
play: [val: {
sentence: Sentence,
handle: boolean
}],
nextWord: [val: ArticleWord],
complete: [],
next: [],
@@ -180,10 +183,10 @@ function nextSentence() {
isEnd = true
emit('complete')
} else {
emit('play', props.article.sections[sectionIndex][0])
emit('play', {sentence: props.article.sections[sectionIndex][0], handle: false})
}
} else {
emit('play', currentSection[sentenceIndex])
emit('play', {sentence: currentSection[sentenceIndex], handle: false})
}
lockNextSentence = false
}
@@ -224,7 +227,7 @@ function onTyping(e: KeyboardEvent) {
playKeyboardAudio()
} else {
if (sectionIndex === 0 && sentenceIndex === 0 && wordIndex === 0 && stringIndex === 0) {
emit('play', currentSection[sentenceIndex])
emit('play', {sentence: currentSection[sentenceIndex], handle: false})
}
let letter = e.key
@@ -239,7 +242,7 @@ function onTyping(e: KeyboardEvent) {
isRight = key === letter
}
if (!isRight) {
if (!currentWord.isSymbol){
if (!currentWord.isSymbol) {
emit('wrong', currentWord)
}
playBeep()
@@ -273,7 +276,7 @@ function onTyping(e: KeyboardEvent) {
function play() {
let currentSection = props.article.sections[sectionIndex]
emit('play', currentSection[sentenceIndex])
emit('play', {sentence: currentSection[sentenceIndex], handle: true})
}
function del() {
@@ -347,13 +350,13 @@ function onContextMenu(e: MouseEvent, sentence: Sentence, i, j) {
sentenceIndex = j
wordIndex = 0
stringIndex = 0
emit('play', sentence)
emit('play', {sentence: sentence, handle: false})
}
},
{
label: "播放",
onClick: () => {
emit('play', sentence)
emit('play', {sentence: sentence, handle: false})
}
},
{