feat:save
This commit is contained in:
@@ -40,10 +40,9 @@ watch(() => settingStore.showPanel, n => {
|
||||
}
|
||||
})
|
||||
|
||||
let practiceType = $ref(DictType.word)
|
||||
|
||||
function changeIndex(dict: Dict) {
|
||||
store.changeDict(dict, practiceType)
|
||||
store.changeDict(dict)
|
||||
emitter.emit(EventKey.changeDict)
|
||||
}
|
||||
|
||||
useEvent(EventKey.changeDict, () => {
|
||||
@@ -69,7 +68,7 @@ const showCollectToggleButton = $computed(() => {
|
||||
|
||||
function changeCollect() {
|
||||
if (props.type === DictType.word) {
|
||||
store.currentStudy.word.dictIndex = -store.collectWord.index
|
||||
changeIndex(store.collectWord)
|
||||
} else {
|
||||
|
||||
}
|
||||
@@ -125,7 +124,7 @@ function changeCollect() {
|
||||
<template v-slot:suffix="{item,index}">
|
||||
<BaseIcon
|
||||
class="del"
|
||||
@click="toggleWordCollect(item)"
|
||||
@click.stop="toggleWordCollect(item)"
|
||||
title="移除"
|
||||
icon="solar:trash-bin-minimalistic-linear"/>
|
||||
</template>
|
||||
@@ -139,7 +138,7 @@ function changeCollect() {
|
||||
<template v-slot:suffix="{item,index}">
|
||||
<BaseIcon
|
||||
class="del"
|
||||
@click="toggleArticleCollect(item)"
|
||||
@click.stop="toggleArticleCollect(item)"
|
||||
title="移除"
|
||||
icon="solar:trash-bin-minimalistic-linear"/>
|
||||
</template>
|
||||
@@ -166,12 +165,12 @@ function changeCollect() {
|
||||
</div>
|
||||
<WordList
|
||||
v-if="store.known.words.length"
|
||||
class="word-list"
|
||||
class="word-list pl-4"
|
||||
:list="store.known.words">
|
||||
<template v-slot:suffix="{item,index}">
|
||||
<BaseIcon
|
||||
class="del"
|
||||
@click="delSimpleWord(item)"
|
||||
@click.stop="delSimpleWord(item)"
|
||||
title="移除"
|
||||
icon="solar:trash-bin-minimalistic-linear"/>
|
||||
</template>
|
||||
@@ -191,12 +190,12 @@ function changeCollect() {
|
||||
</PopConfirm>
|
||||
</div>
|
||||
<WordList
|
||||
class="word-list"
|
||||
class="word-list pl-4"
|
||||
:list="store.wrong.words">
|
||||
<template v-slot:suffix="{item,index}">
|
||||
<BaseIcon
|
||||
class="del"
|
||||
@click="delWrongWord(item)"
|
||||
@click.stop="delWrongWord(item)"
|
||||
title="移除"
|
||||
icon="solar:trash-bin-minimalistic-linear"/>
|
||||
</template>
|
||||
|
||||
@@ -293,26 +293,7 @@ function formClose() {
|
||||
}
|
||||
|
||||
async function addMyStudyList() {
|
||||
|
||||
//把其他的词典的单词数据都删掉,全保存在内存里太卡了
|
||||
base.word.bookList.slice(3).map(v => {
|
||||
if (!v.custom) {
|
||||
v.words = []
|
||||
}
|
||||
})
|
||||
let rIndex = base.word.bookList.findIndex(v => v.name === runtimeStore.editDict.name)
|
||||
if (runtimeStore.editDict.words.length < runtimeStore.editDict.perDayStudyNumber) {
|
||||
runtimeStore.editDict.perDayStudyNumber = runtimeStore.editDict.words.length
|
||||
}
|
||||
if (rIndex > -1) {
|
||||
base.word.studyIndex = rIndex
|
||||
base.word.bookList[base.word.studyIndex].words = runtimeStore.editDict.words
|
||||
base.word.bookList[base.word.studyIndex].perDayStudyNumber = runtimeStore.editDict.perDayStudyNumber
|
||||
} else {
|
||||
base.word.bookList.push(runtimeStore.editDict)
|
||||
base.word.studyIndex = base.word.bookList.length - 1
|
||||
}
|
||||
|
||||
base.changeDict(runtimeStore.editDict)
|
||||
router.back()
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import {useRuntimeStore} from "@/stores/runtime.ts";
|
||||
import {getDefaultWord, ShortcutKey, StudyData, Word} from "@/types.ts";
|
||||
import {useOnKeyboardEventListener, useStartKeyboardEventListener} from "@/hooks/event.ts";
|
||||
import useTheme from "@/hooks/theme.ts";
|
||||
import {useWordOptions} from "@/hooks/dict.ts";
|
||||
import {getCurrentStudyWord, useWordOptions} from "@/hooks/dict.ts";
|
||||
import {cloneDeep, shuffle} from "lodash-es";
|
||||
import {useRouter} from "vue-router";
|
||||
import {Icon} from "@iconify/vue";
|
||||
@@ -245,6 +245,9 @@ function togglePanel() {
|
||||
useEvents([
|
||||
[EventKey.repeat, repeat],
|
||||
[EventKey.next, next],
|
||||
[EventKey.changeDict, () => {
|
||||
studyData = getCurrentStudyWord()
|
||||
}],
|
||||
|
||||
[ShortcutKey.ShowWord, show],
|
||||
[ShortcutKey.Previous, prev],
|
||||
@@ -324,23 +327,23 @@ useEvents([
|
||||
<BaseIcon
|
||||
v-if="!isWordCollect(item)"
|
||||
class="collect"
|
||||
@click="toggleWordCollect(item)"
|
||||
@click.stop="toggleWordCollect(item)"
|
||||
title="收藏" icon="ph:star"/>
|
||||
<BaseIcon
|
||||
v-else
|
||||
class="fill"
|
||||
@click="toggleWordCollect(item)"
|
||||
@click.stop="toggleWordCollect(item)"
|
||||
title="取消收藏" icon="ph:star-fill"/>
|
||||
<BaseIcon
|
||||
v-if="!isWordSimple(item)"
|
||||
class="easy"
|
||||
@click="toggleWordSimple(item)"
|
||||
@click.stop="toggleWordSimple(item)"
|
||||
title="标记为已掌握"
|
||||
icon="material-symbols:check-circle-outline-rounded"/>
|
||||
<BaseIcon
|
||||
v-else
|
||||
class="fill"
|
||||
@click="toggleWordSimple(item)"
|
||||
@click.stop="toggleWordSimple(item)"
|
||||
title="取消标记已掌握"
|
||||
icon="material-symbols:check-circle-rounded"/>
|
||||
</template>
|
||||
|
||||
@@ -183,7 +183,26 @@ export const useBaseStore = defineStore('base', {
|
||||
resolve(true)
|
||||
})
|
||||
},
|
||||
async changeDict() {
|
||||
//TODO
|
||||
changeDict(val: Dict) {
|
||||
//把其他的词典的单词数据都删掉,全保存在内存里太卡了
|
||||
this.word.bookList.slice(3).map(v => {
|
||||
if (!v.custom) {
|
||||
v.words = []
|
||||
}
|
||||
})
|
||||
let rIndex = this.word.bookList.findIndex(v => v.id === val.id)
|
||||
if (val.words.length < val.perDayStudyNumber) {
|
||||
val.perDayStudyNumber = val.words.length
|
||||
}
|
||||
if (rIndex > -1) {
|
||||
this.word.studyIndex = rIndex
|
||||
this.word.bookList[this.word.studyIndex].words = val.words
|
||||
this.word.bookList[this.word.studyIndex].perDayStudyNumber = val.perDayStudyNumber
|
||||
} else {
|
||||
this.word.bookList.push(cloneDeep(val))
|
||||
this.word.studyIndex = this.word.bookList.length - 1
|
||||
}
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user