From 411052b08d779cefe1dcc1f9ab207d69867b3a94 Mon Sep 17 00:00:00 2001 From: zyronon Date: Thu, 28 Aug 2025 00:56:07 +0800 Subject: [PATCH] fix:add an article deletion function --- src/pages/pc/article/BatchEditArticlePage.vue | 2 +- src/pages/pc/article/StudyArticle.vue | 13 +++++- .../pc/article/components/TypingArticle.vue | 41 ++++++++++++++++++- 3 files changed, 53 insertions(+), 3 deletions(-) diff --git a/src/pages/pc/article/BatchEditArticlePage.vue b/src/pages/pc/article/BatchEditArticlePage.vue index fedcd2a2..b2ac9d05 100644 --- a/src/pages/pc/article/BatchEditArticlePage.vue +++ b/src/pages/pc/article/BatchEditArticlePage.vue @@ -16,7 +16,7 @@ import Toast from '@/pages/pc/components/base/toast/Toast.ts' import {getDefaultArticle} from "@/types/func.ts"; import BackIcon from "@/pages/pc/components/BackIcon.vue"; -const emit = defineEmits<{ +defineEmits<{ importData: [val: Event] exportData: [val: string] }>() diff --git a/src/pages/pc/article/StudyArticle.vue b/src/pages/pc/article/StudyArticle.vue index 826735d9..1b1282a0 100644 --- a/src/pages/pc/article/StudyArticle.vue +++ b/src/pages/pc/article/StudyArticle.vue @@ -335,7 +335,18 @@ const {playSentenceAudio} = usePlaySentenceAudio()
时间
-
{{ statisticsStore.total }}
+
+ {{ statisticsStore.total }} + + + + +
单词总数
diff --git a/src/pages/pc/article/components/TypingArticle.vue b/src/pages/pc/article/components/TypingArticle.vue index 0649b438..8a5b265c 100644 --- a/src/pages/pc/article/components/TypingArticle.vue +++ b/src/pages/pc/article/components/TypingArticle.vue @@ -271,8 +271,47 @@ function del() { if (wrong) { wrong = '' } else { - input = input.slice(0, -1) + if (isEnd) return; + if (isSpace) { + isSpace = false + } + let endSentence = false + let endWord = false + let endString = false + if (stringIndex === 0) { + if (wordIndex === 0) { + if (sentenceIndex === 0) { + if (sectionIndex === 0) { + return + } else { + endSentence = endString = endWord = true + sectionIndex-- + } + } else { + endString = endWord = true + sentenceIndex-- + } + } else { + endString = true + wordIndex-- + } + } else stringIndex-- + let currentSection = props.article.sections[sectionIndex] + if (endSentence) sentenceIndex = currentSection.length - 1 + let currentSentence = currentSection[sentenceIndex] + if (endWord) wordIndex = currentSentence.words.length - 1 + let currentWord: ArticleWord = currentSentence.words[wordIndex] + if (endString) { + if (currentWord.nextSpace) { + isSpace = true + stringIndex = currentWord.word.length + }else { + stringIndex = currentWord.word.length - 1 + } + } + input = currentWord.word.slice(0, stringIndex) } + checkCursorPosition() } function indexWord(word: ArticleWord) {