diff --git a/src/components/Practice/Practice.vue b/src/components/Practice/Practice.vue index fd45cc48..080ecd13 100644 --- a/src/components/Practice/Practice.vue +++ b/src/components/Practice/Practice.vue @@ -44,13 +44,16 @@ function repeat() { emitter.emit(EventKey.resetWord) } -//TODO 能否下一章 function next() { // console.log('next') store.currentDict.chapterIndex++ // repeat() } +function restart() { + store.currentDict.chapterIndex = 0 +} + function test() { MessageBox.confirm( '2您选择了“本地翻译”,但译文内容却为空白,是否修改为“不需要翻译”并保存?', @@ -75,6 +78,7 @@ function test() { @write="write" @repeat="repeat" @next="next" + @restart="restart" /> diff --git a/src/components/Practice/Statistics.vue b/src/components/Practice/Statistics.vue index c815d1fa..7ad05dcb 100644 --- a/src/components/Practice/Statistics.vue +++ b/src/components/Practice/Statistics.vue @@ -10,7 +10,7 @@ import {emitter, EventKey} from "@/utils/eventBus.ts"; import {onMounted, reactive} from "vue"; import {cloneDeep} from "lodash-es"; import {Icon} from '@iconify/vue'; -import {$ref} from "vue/macros"; +import {$computed, $ref} from "vue/macros"; const store = useBaseStore() let statModalIsOpen = $ref(false) @@ -19,7 +19,8 @@ let currentStat = reactive(cloneDeep(DefaultDisplayStatistics const emit = defineEmits([ 'repeat', 'next', - 'write' + 'write', + 'restart' ]) onMounted(() => { @@ -32,18 +33,25 @@ onMounted(() => { let optionType = $ref('') -function options(emitType: 'write' | 'repeat' | 'next') { +function options(emitType: 'write' | 'repeat' | 'next' | 'restart') { statModalIsOpen = false optionType = emitType emit(emitType) } +const isEnd = $computed(() => { + return store.isArticle ? + store.currentDict.chapterIndex === store.currentDict.articles.length - 1 : + store.currentDict.chapterIndex === store.currentDict.chapterWords.length - 1 +}) + function onClose() { if (!optionType) { - options('next') + options(isEnd ? 'restart' : 'next') } optionType = '' } +