This commit is contained in:
zyronon
2023-11-19 01:56:43 +08:00
parent 79b4ed679f
commit 979713d1a9
2 changed files with 28 additions and 15 deletions

View File

@@ -50,6 +50,7 @@ async function selectDict(val: { dict: DictResource | Dict, index: number }) {
detailListTabIndex = 0
wordFormMode = FormMode.None
loading = true
wordList = []
let find: Dict = store.myDictList.find((v: Dict) => v.id === item.id)
if (find) {
runtimeStore.editDict = cloneDeep(find)
@@ -100,7 +101,6 @@ function changeDict() {
close()
}
function groupByDictTags(dictList: DictResource[]) {
return dictList.reduce<Record<string, DictResource[]>>((result, dict) => {
dict.tags.forEach((tag) => {
@@ -152,6 +152,10 @@ const dictIsArticle = $computed(() => {
return isArticle(runtimeStore.editDict.type)
})
const chapterList = $computed(() => {
return dictIsArticle ? runtimeStore.editDict.articles : runtimeStore.editDict.chapterWords
})
function showAllWordModal() {
emitter.emit(EventKey.openWordListModal, {
title: runtimeStore.editDict.name,
@@ -420,6 +424,14 @@ function addWord() {
wordForm = cloneDeep(DefaultFormWord)
}
function add() {
if (dictIsArticle) {
} else {
addWord()
}
}
/**/
/* 单词修改相关*/
/**/
@@ -691,6 +703,7 @@ onMounted(() => {
<span>{{ dictIsArticle ? '文章' : '章节' }}列表</span>
</div>
<div class="tab"
v-if="!dictIsArticle"
@click="detailListTabIndex = 1"
:class="detailListTabIndex === 1 && 'active'">
<span>单词列表</span>
@@ -700,12 +713,12 @@ onMounted(() => {
v-if="detailListTabIndex === 0"
>
<ChapterList
v-if="runtimeStore.editDict.chapterWords.length"
v-if="chapterList"
v-loading="loading"
:is-article="dictIsArticle"
v-model:active-index="runtimeStore.editDict.chapterIndex"
:dict="runtimeStore.editDict"/>
<Empty v-else :show-add="true" @add="addWord"/>
<Empty v-else :show-add="true" @add="add"/>
</template>
<div class="scroll" v-else>

View File

@@ -88,18 +88,18 @@ export const useBaseStore = defineStore('base', {
type: DictType.wrong,
category: '自带字典'
},
// {
// ...cloneDeep(DefaultDict),
// id: 'article_nce2',
// name: "新概念英语2-课文",
// description: '新概念英语2-课文',
// category: '英语学习',
// tags: ['新概念英语'],
// url: 'NCE_2.json',
// translateLanguage: 'common',
// language: 'en',
// type: DictType.article
// },
{
...cloneDeep(DefaultDict),
id: 'article_nce2',
name: "新概念英语2-课文",
description: '新概念英语2-课文',
category: '英语学习',
tags: ['新概念英语'],
url: 'NCE_2.json',
translateLanguage: 'common',
language: 'en',
type: DictType.article
},
{
...cloneDeep(DefaultDict),
id: 'nce-new-2',