From 6c09b695a5c4e2af1f49b9deb45a3dc1df260bc9 Mon Sep 17 00:00:00 2001 From: zyronon Date: Sat, 23 Sep 2023 01:02:37 +0800 Subject: [PATCH] save --- public/articles/NCE_2.json | 21 +++-- src/components/Modal/Modal.vue | 3 + src/components/Practice/Footer.vue | 8 +- src/components/Practice/Practice.vue | 20 ++-- src/components/Practice/Statistics.vue | 19 +++- src/components/Practice/TypeArticle.vue | 80 ++++++++++++---- src/components/Practice/TypeWord.vue | 35 ++++--- src/hooks/article.ts | 15 ++- src/stores/practice.ts | 8 +- src/stores/setting.ts | 2 +- src/utils/MessageBox.tsx | 120 ++++++++++++------------ 11 files changed, 197 insertions(+), 134 deletions(-) diff --git a/public/articles/NCE_2.json b/public/articles/NCE_2.json index 6df8d7ea..6e51c981 100644 --- a/public/articles/NCE_2.json +++ b/public/articles/NCE_2.json @@ -1,14 +1,5 @@ [ - { - "title": "A private conversation!", - "titleTranslate": "私人谈话!", - "text": "Last week I went to the theatre. I had a very good seat. The play was very interesting. I did not enjoy it. A young man and a young woman were sitting behind me. They were talking loudly. I got very angry. I could not hear the actors. I turned round. I looked at the man and the woman angrily. They did not pay any attention. In the end, I could not bear it. I turned round again. 'I can't hear a word!' I said angrily.\n 'It's none of your business,' the young man said rudely. 'This is a private conversation!'", - "textCustomTranslate": "上星期我去看戏。我的座位很好,戏很有意思,但我却无法欣赏。一青年男子与一青年女子坐在我的身后,大声地说着话。我非常生气,因为我听不见演员在说什么。我回过头去怒视着那一男一女,他们却毫不理会。最后,我忍不住了,又一次回过头去,生气地说:“我一个字也听不见了!”\n “不关你的事,”那男的毫不客气地说,“这是私人间的谈话!”", - "textNetworkTranslate": "", - "newWords": [], - "textCustomTranslateIsFormat": false, - "useTranslateType": "custom" - }, + { "title": "Breakfast or lunch?", "titleTranslate": "早餐还是午餐?", @@ -19,6 +10,16 @@ "useTranslateType": "custom", "newWords": [] }, + { + "title": "A private conversation!", + "titleTranslate": "私人谈话!", + "text": "Last week I went to the theatre. I had a very good seat. The play was very interesting. I did not enjoy it. A young man and a young woman were sitting behind me. They were talking loudly. I got very angry. I could not hear the actors. I turned round. I looked at the man and the woman angrily. They did not pay any attention. In the end, I could not bear it. I turned round again. 'I can't hear a word!' I said angrily.\n 'It's none of your business,' the young man said rudely. 'This is a private conversation!'", + "textCustomTranslate": "上星期我去看戏。我的座位很好,戏很有意思,但我却无法欣赏。一青年男子与一青年女子坐在我的身后,大声地说着话。我非常生气,因为我听不见演员在说什么。我回过头去怒视着那一男一女,他们却毫不理会。最后,我忍不住了,又一次回过头去,生气地说:“我一个字也听不见了!”\n “不关你的事,”那男的毫不客气地说,“这是私人间的谈话!”", + "textNetworkTranslate": "", + "newWords": [], + "textCustomTranslateIsFormat": false, + "useTranslateType": "custom" + }, { "title": "Please send me a card", "titleTranslate": "请给我寄一张明信片", diff --git a/src/components/Modal/Modal.vue b/src/components/Modal/Modal.vue index bc8a1489..2b9da8a9 100644 --- a/src/components/Modal/Modal.vue +++ b/src/components/Modal/Modal.vue @@ -42,6 +42,9 @@ let maskRef = $ref(null) let modalRef = $ref(null) function close() { + if (!visible) { + return + } //记录停留时间,避免时间太短,弹框闪烁 let stayTime = Date.now() - openTime; let closeTime = 300; diff --git a/src/components/Practice/Footer.vue b/src/components/Practice/Footer.vue index dda7e6c0..04292fbc 100644 --- a/src/components/Practice/Footer.vue +++ b/src/components/Practice/Footer.vue @@ -18,8 +18,8 @@ function format(val: number, suffix: string = '', check: number = -1) { const progress = $computed(() => { if (!practiceStore.total) return 0 - if (practiceStore.inputNumber > practiceStore.total) return 100 - return ((practiceStore.inputNumber / practiceStore.total) * 100) + if (practiceStore.inputWordNumber > practiceStore.total) return 100 + return ((practiceStore.inputWordNumber / practiceStore.total) * 100) }) let speedMinute = $ref(0) @@ -54,12 +54,12 @@ onUnmounted(() => {
单词总数
-
{{ format(practiceStore.inputNumber, '', 0) }}
+
{{ format(practiceStore.inputWordNumber, '', 0) }}
输入数
-
{{ format(practiceStore.wrongNumber, '', 0) }}
+
{{ format(practiceStore.wrongWordNumber, '', 0) }}
错误数
diff --git a/src/components/Practice/Practice.vue b/src/components/Practice/Practice.vue index c8938256..b9030c8f 100644 --- a/src/components/Practice/Practice.vue +++ b/src/components/Practice/Practice.vue @@ -29,13 +29,13 @@ let showEditArticle = $ref(false) let editArticle = $ref
(cloneDeep(DefaultArticle)) watch(practiceStore, () => { - if (practiceStore.inputNumber < 1) { + if (practiceStore.inputWordNumber < 1) { return practiceStore.correctRate = -1 } - if (practiceStore.wrongNumber > practiceStore.inputNumber) { + if (practiceStore.wrongWordNumber > practiceStore.inputWordNumber) { return practiceStore.correctRate = 0 } - practiceStore.correctRate = 100 - Math.trunc(((practiceStore.wrongNumber) / (practiceStore.inputNumber)) * 100) + practiceStore.correctRate = 100 - Math.trunc(((practiceStore.wrongWordNumber) / (practiceStore.inputWordNumber)) * 100) }) let wordData = $ref({ @@ -58,10 +58,11 @@ watch(() => store.load, n => { }) function getCurrentPractice() { - console.log('store.currentDict',store.currentDict) + // console.log('store.currentDict',store.currentDict) if (store.isArticle) { // return - let tempArticle = {...DefaultArticle, ...store.currentDict.articles[store.currentDict.chapterIndex]} + let currentArticle = store.currentDict.articles[store.currentDict.chapterIndex] + let tempArticle = {...DefaultArticle, ...currentArticle} console.log('article', tempArticle) if (tempArticle.sections.length) { articleData.article = tempArticle @@ -87,7 +88,7 @@ function getCurrentPractice() { () => { updateSections(tempArticle) tempArticle.useTranslateType = TranslateType.none - articleData.article = tempArticle + store.currentDict.articles[store.currentDict.chapterIndex] = articleData.article = tempArticle }, { confirmButtonText: '去编辑', @@ -106,7 +107,7 @@ function getCurrentPractice() { () => { updateSections(tempArticle) tempArticle.useTranslateType = TranslateType.none - articleData.article = tempArticle + store.currentDict.articles[store.currentDict.chapterIndex] = articleData.article = tempArticle }, { confirmButtonText: '去编辑', @@ -118,7 +119,7 @@ function getCurrentPractice() { if (tempArticle.useTranslateType === TranslateType.network) { updateSections(tempArticle) updateLocalSentenceTranslate(tempArticle, tempArticle.textNetworkTranslate) - articleData.article = tempArticle + store.currentDict.articles[store.currentDict.chapterIndex] = articleData.article = tempArticle } } } @@ -132,7 +133,6 @@ onMounted(() => { }) - function write() { console.log('write') settingStore.dictation = true @@ -175,7 +175,7 @@ function test() {