Fix the bug that went wrong when completing the last chapter
This commit is contained in:
@@ -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>
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -165,10 +165,6 @@ export const useBaseStore = defineStore('base', {
|
||||
chapter(state: State): Word[] {
|
||||
return this.currentDict.chapterWords[this.currentDict.chapterIndex] ?? []
|
||||
},
|
||||
//TODO 废弃
|
||||
word(state: State): Word {
|
||||
return {trans: [], name: '', usphone: '', ukphone: '',}
|
||||
},
|
||||
dictTitle(state: State) {
|
||||
let title = this.currentDict.name
|
||||
switch (state.current.dictType) {
|
||||
|
||||
@@ -38,6 +38,7 @@ export interface SettingState {
|
||||
shortcutKeyMap: Record<string, string>
|
||||
}
|
||||
|
||||
|
||||
export const useSettingStore = defineStore('setting', {
|
||||
state: (): SettingState => {
|
||||
return {
|
||||
@@ -85,11 +86,25 @@ export const useSettingStore = defineStore('setting', {
|
||||
}
|
||||
},
|
||||
init() {
|
||||
const setDefaultConfig = () => {
|
||||
localStorage.setItem(SaveConfig.key, JSON.stringify({val: this.$state, version: SaveConfig.version}))
|
||||
}
|
||||
let configStr = localStorage.getItem(SaveConfig.key)
|
||||
if (configStr) {
|
||||
let obj = JSON.parse(configStr)
|
||||
// this.setState(obj)
|
||||
this.setState(obj.val)
|
||||
try {
|
||||
let obj: any = JSON.parse(configStr)
|
||||
if (!obj.version) {
|
||||
setDefaultConfig()
|
||||
} else {
|
||||
if (obj.version !== SaveConfig.version) {
|
||||
setDefaultConfig()
|
||||
} else {
|
||||
this.setState(obj.val)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
setDefaultConfig()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user