diff --git a/components.d.ts b/components.d.ts index 72990be6..f845343c 100644 --- a/components.d.ts +++ b/components.d.ts @@ -52,8 +52,6 @@ declare module 'vue' { PopConfirm: typeof import('./src/components/PopConfirm.vue')['default'] RepeatSetting: typeof import('./src/components/toolbar/RepeatSetting.vue')['default'] Ring: typeof import('./src/components/Ring.vue')['default'] - RouterLink: typeof import('vue-router')['RouterLink'] - RouterView: typeof import('vue-router')['RouterView'] SettingDialog: typeof import('./src/components/dialog/SettingDialog.vue')['default'] Slide: typeof import('./src/components/Slide.vue')['default'] Toolbar: typeof import('./src/components/toolbar/index.vue')['default'] diff --git a/src/components/list/VirtualWordList2.vue b/src/components/list/VirtualWordList2.vue index 586c97c8..6b22987f 100644 --- a/src/components/list/VirtualWordList2.vue +++ b/src/components/list/VirtualWordList2.vue @@ -91,7 +91,7 @@ defineExpose({scrollToBottom})
-
{{ item }}
+
{{ tran }}
diff --git a/src/pages/dict/ChapterWordList.vue b/src/pages/dict/ChapterWordList.vue new file mode 100644 index 00000000..1e3746c8 --- /dev/null +++ b/src/pages/dict/ChapterWordList.vue @@ -0,0 +1,169 @@ + + + + + \ No newline at end of file diff --git a/src/pages/dict/DictManage.vue b/src/pages/dict/DictManage.vue index 65730a02..7c5fa8da 100644 --- a/src/pages/dict/DictManage.vue +++ b/src/pages/dict/DictManage.vue @@ -29,6 +29,7 @@ import {nanoid} from "nanoid"; import {no} from "@/utils"; import Test from "@/pages/dict/Test.vue"; import VirtualWordList2 from "@/components/list/VirtualWordList2.vue"; +import ChapterWordList from "@/pages/dict/ChapterWordList.vue"; const store = useBaseStore() const settingStore = useSettingStore() @@ -37,7 +38,6 @@ let currentLanguage = $ref('my') let currentTranslateLanguage = $ref('common') let groupByLanguage = groupBy(dictionaryResources, 'language') let translateLanguageList = $ref([]) -let wordList = $ref([]) let step = $ref(1) let loading = $ref(false) @@ -47,12 +47,6 @@ let chapterWordNumber = $ref(settingStore.chapterWordNumber) let chapterIndex = $ref(-1) let residueWordList = $ref([]) -let currentChapterWordListCheckAll = $ref(false) -let currentChapterWordListIsIndeterminate = $ref(false) -let residueWordListCheckAll = $ref(false) -let residueWordListIsIndeterminate = $ref(false) - - async function selectDict(val: { dict: DictResource | Dict, index: number @@ -61,9 +55,8 @@ async function selectDict(val: { console.log('item', item) step = 1 isAddDict = false - wordFormMode = FormMode.None + wordFormData.type = FormMode.None loading = true - wordList = [] let find: Dict = store.myDictList.find((v: Dict) => v.id === item.id) if (find) { runtimeStore.editDict = cloneDeep(find) @@ -75,7 +68,6 @@ async function selectDict(val: { } if ([DictType.collect, DictType.simple, DictType.wrong].includes(runtimeStore.editDict.type)) { - wordList = cloneDeep(runtimeStore.editDict.words) } else { let url = `./dicts/${runtimeStore.editDict.language}/${runtimeStore.editDict.type}/${runtimeStore.editDict.translateLanguage}/${runtimeStore.editDict.url}`; if (runtimeStore.editDict.type === DictType.word) { @@ -290,7 +282,6 @@ const DefaultFormWord = { trans: '', } -let wordFormMode = $ref(FormMode.None) let wordForm = $ref(cloneDeep(DefaultFormWord)) const wordFormRef = $ref() const wordRules = reactive({ @@ -381,23 +372,17 @@ function addWord(where: string) { wordForm = cloneDeep(DefaultFormWord) } -function delWord(word: Word, index: number, where: string) { - let rIndex = runtimeStore.editDict.originWords.findIndex(v => v.id === word.id) +function delWord(val: { word: Word }) { + let rIndex = runtimeStore.editDict.originWords.findIndex(v => v.id === val.word.id) if (rIndex > -1) { runtimeStore.editDict.originWords.splice(rIndex, 1) } - let rIndex2 = runtimeStore.editDict.words.findIndex(v => v.id === word.id) + let rIndex2 = runtimeStore.editDict.words.findIndex(v => v.id === val.word.id) if (rIndex2 > -1) { runtimeStore.editDict.words.splice(rIndex2, 1) } - if (where === 'chapter') { - currentChapterWordList.splice(index, 1) - } else { - residueWordList.splice(index, 1) - } - - if (wordFormData.type === FormMode.Edit && wordForm.name === word.name) { + if (wordFormData.type === FormMode.Edit && wordForm.name === val.word.name) { closeWordForm() } syncMyDictList() @@ -471,16 +456,14 @@ onMounted(() => { } if (type === "collect") { selectDict({dict: store.collect, index: 0}) - wordFormMode = FormMode.Add - addWord() + addWord('residue') } if (type === "simple") { selectDict({dict: store.simple, index: 0}) - addWord() + addWord('residue') } }) - // console.log('categoryList', categoryList) // console.log('tagList', tagList) }) @@ -499,7 +482,6 @@ let residueWordListCheckedTotal = $computed(() => { function handleChangeCurrentChapter(index: number) { currentChapterWordList.map(v => v.checked = false) - currentChapterWordListCheckAll = currentChapterWordListIsIndeterminate = false chapterIndex = index closeWordForm() } @@ -514,10 +496,10 @@ function toResidueWordList() { runtimeStore.editDict.chapterWords[chapterIndex] = currentChapterWordList.filter(v => !v.checked) list.map(v => v.checked = false) residueWordList = residueWordList.concat(list) - currentChapterWordListIsIndeterminate = currentChapterWordListCheckAll = false } function toChapterWordList() { + if (chapterIndex == -1) return ElMessage.warning('请选择章节') let list = residueWordList.filter(v => v.checked) if (wordFormData.type === FormMode.Edit && wordFormData.where !== 'chapter') { if (list.find(v => v.name === wordForm.name)) { @@ -526,8 +508,7 @@ function toChapterWordList() { } residueWordList = residueWordList.filter(v => !v.checked) list.map(v => v.checked = false) - runtimeStore.editDict.chapterWords[chapterIndex] = runtimeStore.editDict.chapterWords[chapterIndex].concat(list) - residueWordListCheckAll = residueWordListIsIndeterminate = false + runtimeStore.editDict.chapterWords[chapterIndex] = currentChapterWordList.concat(list) } function addNewChapter() { @@ -540,6 +521,8 @@ function delWordChapter(index: number) { list.map(v => v.checked = false) residueWordList = residueWordList.concat(list) runtimeStore.editDict.chapterWords.splice(index, 1) + chapterList2 = Array.from({length: runtimeStore.editDict.chapterWords.length}).map((v, i) => ({id: i})) + if (chapterIndex >= index) chapterIndex-- if (chapterIndex < 0) chapterIndex = 0 @@ -552,41 +535,8 @@ function resetChapterList() { runtimeStore.editDict.words.map(v => v.checked = false) runtimeStore.editDict.chapterWords = chunk(runtimeStore.editDict.words, chapterWordNumber) chapterList2 = Array.from({length: runtimeStore.editDict.chapterWords.length}).map((v, i) => ({id: i})) -} - -function handleCheckedChapterWordListChange({word: source}: any) { - // source.checked = !source.checked - let rIndex = currentChapterWordList.findIndex(v => v.id === source.id) - console.log('handleCheckedChapterWordListChange', currentChapterWordList[rIndex].checked) - if (rIndex > -1) { - currentChapterWordList[rIndex].checked = !currentChapterWordList[rIndex].checked - } - currentChapterWordListCheckAll = currentChapterWordList.every(v => v.checked) - if (currentChapterWordListCheckAll) { - currentChapterWordListIsIndeterminate = false - } else { - currentChapterWordListIsIndeterminate = currentChapterWordList.some(v => v.checked) - } -} - -function handleCurrentChapterWordListCheckAll() { - currentChapterWordList.map(v => v.checked = currentChapterWordListCheckAll) - currentChapterWordListIsIndeterminate = false -} - -function handleCheckedResidueWordListChange(source: any) { - source.checked = !source.checked - residueWordListCheckAll = residueWordList.every(v => v.checked) - if (residueWordListCheckAll) { - residueWordListIsIndeterminate = false - } else { - residueWordListIsIndeterminate = residueWordList.some(v => v.checked) - } -} - -function handleCurrentResidueWordListCheckAll() { - residueWordList.map(v => v.checked = residueWordListCheckAll) - residueWordListIsIndeterminate = false + console.log('runtimeStore.editDict.chapterWords',runtimeStore.editDict.chapterWords) + console.log('chapterList2',chapterList2) } function exportData() { @@ -689,221 +639,62 @@ const isPinDict = $computed(() => {
- - - +
+ -
-
-
- {{ chapterIndex > -1 ? `第${chapterIndex + 1}章` : '' }} 单词列表 -
- - -
-
-
-
- - 全选 -
-
{{ currentChapterWordListCheckedTotal }}/{{ currentChapterWordList.length }}
-
-
-
- - - - - -
-
+
+ :disabled="residueWordListCheckedTotal === 0"> < + :disabled="currentChapterWordListCheckedTotal === 0"> >
-
-
-
- 未分配单词列表 -
- - -
-
-
-
- - 全选 -
-
{{ residueWordListCheckedTotal }}/{{ residueWordList.length }}
-
-
-
- - - - -
-
+