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

@@ -32,7 +32,7 @@
{
"title": "An exciting trip",
"titleTranslate": "激动人心的旅行",
"text": "I have just received a letter from my brother, Tim. \nHe is in Australia. \nHe has been there for six months. \nTim is an engineer. \nHe is working for a big firm and he has already visited a great number of different places in Australia. \nHe has just bought an Australian car and has gone to Alice springs, a small town in the centre of Australia. \nHe will soon visit Darwin. \nFrom there, he will fly to Perth. \nMy brother has never been abroad before, so he is fending this trip very exciting.",
"text": "I have just received a letter from my brother, Tim. \nHe is in Australia. \nHe has been there for six months. \nTim is an engineer. \nHe is working for a big firm and he has already visited a great number of different places in Australia. \nHe has just bought an Australian car and has gone to Alice springs, a small town in the centre of Australia. \nHe will soon visit Darwin. \nFrom there, he will fly to Perth. \nMy brother has never been abroad before, so he is finding this trip very exciting.",
"textTranslate": "我刚刚收到弟弟蒂姆的来信, \n他正在澳大利亚。 \n他在那儿已经住了6个月了。 \n蒂姆是个工程师 \n正在一家大公司工作并且已经去过澳大利亚的不少地方了。 \n他刚买了一辆澳大利亚小汽车现在去了澳大利亚中部的小镇艾利斯斯普林斯。 \n他不久还将到达达尔文去 \n从那里他再飞往珀斯。 \n我弟弟以前从未出过国因此他觉得这次旅行非常激动人心。",
"newWords": [],
"audioSrc": "/sound/article/nce2-1/An exciting trip.mp3",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 87 KiB

View File

@@ -4,6 +4,7 @@ import nlp from "compromise/one";
import {usePlayWordAudio} from "@/hooks/sound.ts";
import {getSentenceAllText, getSentenceAllTranslateText} from "@/hooks/translate.ts";
import {getDefaultArticleWord} from "@/types/func.ts";
import {useSettingStore} from "@/stores/setting.ts";
interface KeyboardMap {
Period: string,
@@ -534,6 +535,7 @@ export function getTranslateText(article: Article) {
export function usePlaySentenceAudio() {
const playWordAudio = usePlayWordAudio()
const settingStore = useSettingStore()
let timer = $ref(0)
function playSentenceAudio(sentence: Sentence, ref?: HTMLAudioElement, article?: Article) {
@@ -543,6 +545,7 @@ export function usePlaySentenceAudio() {
ref.pause()
}
let start = sentence.audioPosition[0];
ref.volume = settingStore.wordSoundVolume / 100
ref.currentTime = start
ref.play()
let end = sentence.audioPosition?.[1]

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})
}
},
{