From a3133a7f1598e02e455351554c108f09cddb3b67 Mon Sep 17 00:00:00 2001 From: Zyronon Date: Wed, 1 Oct 2025 23:00:32 +0800 Subject: [PATCH] feat:keep a record of historical practice --- src/hooks/article.ts | 2 +- src/pages/article/ArticlesPage.vue | 27 ++- src/pages/article/PracticeArticles.vue | 184 ++++++++++----- .../article/components/TypingArticle.vue | 220 +++++------------- src/pages/setting/Setting.vue | 39 +++- src/pages/word/WordsPage.vue | 2 +- src/utils/const.ts | 2 +- 7 files changed, 248 insertions(+), 228 deletions(-) diff --git a/src/hooks/article.ts b/src/hooks/article.ts index 707d6954..f84fd8f2 100644 --- a/src/hooks/article.ts +++ b/src/hooks/article.ts @@ -114,6 +114,7 @@ export function genArticleSectionData(article: Article): number { item = item.trim() //如果没有空格,导致修改一行一行的数据时,汇总时全没有空格了,库无法正常断句 //所以要保证最后一个是空格,但防止用户打N个空格,就去掉再加上一个空格,只需要一个即可 + //2025/10/1:最后一句不需要空格 if (i < arr.length - 1) item += ' ' let sentence: Sentence = cloneDeep({ text: item, @@ -127,7 +128,6 @@ export function genArticleSectionData(article: Article): number { sections = sections.filter(v => v.length) article.sections = sections - console.log(sections) let failCount = 0 let translateList = article.textTranslate?.split('\n\n') || [] diff --git a/src/pages/article/ArticlesPage.vue b/src/pages/article/ArticlesPage.vue index 60576b05..7483abf0 100644 --- a/src/pages/article/ArticlesPage.vue +++ b/src/pages/article/ArticlesPage.vue @@ -17,6 +17,7 @@ import DeleteIcon from "@/components/icon/DeleteIcon.vue"; import recommendBookList from "@/assets/book-list.json"; import dayjs from "dayjs"; import isBetween from "dayjs/plugin/isBetween"; +import { PracticeSaveArticleKey } from "@/utils/const.ts"; dayjs.extend(isBetween); @@ -25,9 +26,11 @@ const base = useBaseStore() const store = useBaseStore() const router = useRouter() const runtimeStore = useRuntimeStore() +let isSaveData = $ref(false) -onMounted(init) -watch(() => store.load, init) +watch(() => store.load, n => { + if (n) init() +}, {immediate: true}) async function init() { if (store.article.studyIndex >= 1) { @@ -35,6 +38,24 @@ async function init() { store.article.bookList[store.article.studyIndex] = await _getDictDataByUrl(store.sbook, DictType.article) } } + let d = localStorage.getItem(PracticeSaveArticleKey.key) + if (d) { + try { + let obj = JSON.parse(d) + let data = obj.val + //如果全是0,说明未进行练习,直接重置 + if ( + data.practiceData.sectionIndex === 0 && + data.practiceData.sentenceIndex === 0 && + data.practiceData.wordIndex === 0 + ) { + throw new Error() + } + isSaveData = true + } catch (e) { + localStorage.removeItem(PracticeSaveArticleKey.key) + } + } } function startStudy() { @@ -187,7 +208,7 @@ const weekList = $computed(() => { @click="startStudy" :disabled="!base.currentBook.name">
- 开始学习 + {{ isSaveData ? '继续学习' : '开始学习' }}
diff --git a/src/pages/article/PracticeArticles.vue b/src/pages/article/PracticeArticles.vue index 7a2fef36..f7110060 100644 --- a/src/pages/article/PracticeArticles.vue +++ b/src/pages/article/PracticeArticles.vue @@ -1,18 +1,18 @@