Fix the bug that went wrong when completing the last chapter

This commit is contained in:
zyronon
2023-11-02 00:24:12 +08:00
parent 3f913c831f
commit a20b49a85e
4 changed files with 57 additions and 21 deletions

View File

@@ -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"
/>
</template>

View File

@@ -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<DisplayStatistics>(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 = ''
}
</script>
<template>
@@ -95,15 +103,28 @@ function onClose() {
</div>
</div>
<div class="footer">
<BaseButton keyboard="Ctrl + Enter" @click="options('write')">
默写本章
</BaseButton>
<BaseButton keyboard="Alt + Enter" @click="options('repeat')">
重复本章
</BaseButton>
<BaseButton keyboard="Tab" @click="options('next')">
下一章
</BaseButton>
<template v-if="isEnd">
<BaseButton keyboard="Ctrl + Enter" @click="options('write')">
默写本章
</BaseButton>
<BaseButton keyboard="Alt + Enter" @click="options('repeat')">
重复本章
</BaseButton>
<BaseButton keyboard="Tab" @click="options('restart')">
重新练习
</BaseButton>
</template>
<template v-else>
<BaseButton keyboard="Ctrl + Enter" @click="options('write')">
默写本章
</BaseButton>
<BaseButton keyboard="Alt + Enter" @click="options('repeat')">
重复本章
</BaseButton>
<BaseButton keyboard="Tab" @click="options('next')">
下一章
</BaseButton>
</template>
</div>
</div>
</Modal>