modify:split article

This commit is contained in:
Zyronon
2025-10-02 02:11:35 +08:00
parent 051bf367c9
commit 9128bbec54
8 changed files with 160 additions and 257 deletions

View File

@@ -4,14 +4,24 @@ import { computed, onMounted, onUnmounted, provide, watch } from "vue";
import { useBaseStore } from "@/stores/base.ts";
import { emitter, EventKey, useEvents } from "@/utils/eventBus.ts";
import { useSettingStore } from "@/stores/setting.ts";
import { Article, ArticleItem, ArticleWord, Dict, DictType, ShortcutKey, Statistics, Word } from "@/types/types.ts";
import {
Article,
ArticleItem,
ArticleWord,
Dict,
DictType,
PracticeArticleWordType,
ShortcutKey,
Statistics,
Word
} from "@/types/types.ts";
import { useDisableEventListener, useOnKeyboardEventListener, useStartKeyboardEventListener } from "@/hooks/event.ts";
import useTheme from "@/hooks/theme.ts";
import Toast from '@/components/base/toast/Toast.ts'
import { _getDictDataByUrl, _nextTick, cloneDeep, msToHourMinute, msToMinute, total } from "@/utils";
import { _getDictDataByUrl, _nextTick, cloneDeep, msToMinute, total } from "@/utils";
import { usePracticeStore } from "@/stores/practice.ts";
import { useArticleOptions } from "@/hooks/dict.ts";
import { genArticleSectionData, syncBookInMyStudyList, usePlaySentenceAudio } from "@/hooks/article.ts";
import { genArticleSectionData, usePlaySentenceAudio } from "@/hooks/article.ts";
import { getDefaultArticle, getDefaultDict, getDefaultWord } from "@/types/func.ts";
import TypingArticle from "@/pages/article/components/TypingArticle.vue";
import BaseIcon from "@/components/BaseIcon.vue";
@@ -24,9 +34,7 @@ import { useRoute, useRouter } from "vue-router";
import book_list from "@/assets/book-list.json";
import PracticeLayout from "@/components/PracticeLayout.vue";
import Switch from "@/components/base/Switch.vue";
import Audio from "@/components/base/Audio.vue";
import ArticleAudio from "@/pages/article/components/ArticleAudio.vue";
import dayjs from "dayjs";
import { PracticeSaveArticleKey } from "@/utils/const.ts";
const store = useBaseStore()
@@ -209,7 +217,7 @@ function setArticle(val: Article) {
articleData.article.sections.map((v, i) => {
v.map((w) => {
w.words.map(s => {
if (!ignoreList.includes(s.word.toLowerCase()) && !s.isSymbol) {
if (!ignoreList.includes(s.word.toLowerCase()) && s.type === PracticeArticleWordType.Word) {
statStore.total++
}
})
@@ -307,7 +315,7 @@ function wrong(word: Word) {
}
function nextWord(word: ArticleWord) {
if (!store.allIgnoreWords.includes(word.word.toLowerCase()) && !word.isSymbol) {
if (!store.allIgnoreWords.includes(word.word.toLowerCase()) && word.type === PracticeArticleWordType.Word) {
statStore.inputWordNumber++
}
}

View File

@@ -79,7 +79,7 @@ function apply(isHandle: boolean = true) {
//分句原文
function splitText() {
editArticle.text = splitEnArticle2(editArticle.text.trim())
editArticle.text = splitEnArticle2(editArticle.text)
}
//分句翻译

View File

@@ -1,6 +1,6 @@
<script setup lang="ts">
import { inject, onMounted, onUnmounted, provide, watch } from "vue"
import { Article, ArticleWord, Sentence, Word } from "@/types/types.ts";
import { inject, onMounted, onUnmounted, watch } from "vue"
import { Article, ArticleWord, PracticeArticleWordType, Sentence, Word } from "@/types/types.ts";
import { useBaseStore } from "@/stores/base.ts";
import { useSettingStore } from "@/stores/setting.ts";
import { usePlayBeep, usePlayCorrect, usePlayKeyboardAudio } from "@/hooks/sound.ts";
@@ -18,7 +18,7 @@ import Space from "@/pages/article/components/Space.vue";
import { useWordOptions } from "@/hooks/dict.ts";
import nlp from "compromise/three";
import { nanoid } from "nanoid";
import { PracticeSaveArticleKey, PracticeSaveWordKey } from "@/utils/const.ts";
import { PracticeSaveArticleKey } from "@/utils/const.ts";
import { usePracticeStore } from "@/stores/practice.ts";
interface IProps {
@@ -221,7 +221,7 @@ function nextSentence() {
})
//todo 计得把略过的单词加上统计里面去
// if (!store.allIgnoreWords.includes(currentWord.word.toLowerCase()) && !currentWord.isSymbol) {
// if (!store.allIgnoreWords.includes(currentWord.word.toLowerCase()) && currentWord.type === PracticeArticleWordType.Word) {
// statisticsStore.inputNumber++
// }
isSpace = false;
@@ -295,7 +295,7 @@ function onTyping(e: KeyboardEvent) {
isRight = key === letter
}
if (!isRight) {
if (!currentWord.isSymbol) {
if (currentWord.type === PracticeArticleWordType.Word) {
emit('wrong', currentWord)
}
playBeep()
@@ -308,7 +308,7 @@ function onTyping(e: KeyboardEvent) {
if (!currentWord.word[stringIndex]) {
input = ''
//如果不是符号,播放完成音效
if (!currentWord.isSymbol) playCorrect()
if (currentWord.type === PracticeArticleWordType.Word) playCorrect()
if (currentWord.nextSpace) {
isSpace = true
} else {
@@ -562,7 +562,8 @@ const currentPractice = inject('currentPractice', [])
@mouseleave="hideSentence"
:class="[
hoverIndex.sectionIndex === indexI && hoverIndex.sentenceIndex === indexJ && hoverIndex.wordIndex === indexW
&&'hover-show'
&&'hover-show',
word.type === PracticeArticleWordType.Number && 'font-family text-xl'
]"
>
<TypingWord :word="word"

View File

@@ -1,6 +1,7 @@
<script setup lang="tsx">
import {useSettingStore} from "@/stores/setting.ts";
import Space from "@/pages/article/components/Space.vue";
import { PracticeArticleWordType } from "@/types/types.ts";
//引入这个编译就报错
// import {ArticleWord} from "@/types/types.ts";
@@ -15,7 +16,7 @@ function compare(a: string, b: string) {
}
const isHide = $computed(() => {
if (settingStore.dictation && !props.word.isSymbol) return 'hide'
if (settingStore.dictation && props.word.type === PracticeArticleWordType.Word) return 'hide'
return ''
})