From 84d4b82850ca1a8624fe59cac9439d07ffb76f97 Mon Sep 17 00:00:00 2001 From: zyronon Date: Tue, 19 Sep 2023 23:29:08 +0800 Subject: [PATCH] save --- src/components/Practice/Footer.vue | 2 +- src/components/Practice/Practice.vue | 36 ++++++++++-- src/components/Practice/Statistics.vue | 55 ++++++------------- src/components/Practice/TypeArticle.vue | 2 +- src/components/Practice/TypeWord.vue | 17 +++--- .../{usePracticeStore.ts => practice.ts} | 3 +- src/components/Toolbar/SettingModal.vue | 8 +-- src/stores/base.ts | 11 +--- src/stores/setting.ts | 16 ++++-- src/types.ts | 9 ++- 10 files changed, 89 insertions(+), 70 deletions(-) rename src/components/Practice/{usePracticeStore.ts => practice.ts} (92%) diff --git a/src/components/Practice/Footer.vue b/src/components/Practice/Footer.vue index bc5260cd..47bf707d 100644 --- a/src/components/Practice/Footer.vue +++ b/src/components/Practice/Footer.vue @@ -4,7 +4,7 @@ import {$computed, $ref} from "vue/macros" import {onMounted, onUnmounted} from "vue" import {useBaseStore} from "@/stores/base.ts" import Tooltip from "@/components/Tooltip.vue" -import {usePracticeStore} from "@/components/Practice/usePracticeStore.ts"; +import {usePracticeStore} from "@/components/Practice/practice.ts"; import {Icon} from "@iconify/vue"; import {useSettingStore} from "@/stores/setting.ts"; diff --git a/src/components/Practice/Practice.vue b/src/components/Practice/Practice.vue index 2c271efa..f44b7446 100644 --- a/src/components/Practice/Practice.vue +++ b/src/components/Practice/Practice.vue @@ -2,16 +2,19 @@ import Toolbar from "@/components/Toolbar/Toolbar.vue" import {onMounted, watch} from "vue"; -import {usePracticeStore} from "@/components/Practice/usePracticeStore.ts"; +import {usePracticeStore} from "@/components/Practice/practice.ts"; import Footer from "@/components/Practice/Footer.vue"; import TypeWord from "@/components/Practice/TypeWord.vue"; import TypeArticle from "@/components/Practice/TypeArticle.vue"; import {useBaseStore} from "@/stores/base.ts"; import {$ref} from "vue/macros"; import Statistics from "@/components/Practice/Statistics.vue"; +import {emitter, EventKey} from "@/utils/eventBus"; +import {useSettingStore} from "@/stores/setting"; const practiceStore = usePracticeStore() const store = useBaseStore() +const settingStore = useSettingStore() watch(practiceStore, () => { if (practiceStore.inputNumber < 1) { @@ -1135,15 +1138,36 @@ let articleData = $ref({ watch(() => store.load, n => { if (n) { - wordData.words = store.chapter - wordData.index = 0 + getCurrentWords() } }) +function getCurrentWords() { + wordData.words = store.chapter + wordData.index = 0 +} + onMounted(() => { }) +function write() { + settingStore.dictation = true + repeat() +} + +//TODO 需要判断是否已忽略 +function repeat() { + getCurrentWords() + emitter.emit(EventKey.resetWord) +} + +//TODO 能否下一章 +function next() { + store.currentDict.chapterIndex++ + repeat() +} +