From 8330d32b8f026472921528f9917d5deab1435f57 Mon Sep 17 00:00:00 2001 From: zyronon Date: Sat, 25 Nov 2023 01:17:37 +0800 Subject: [PATCH] Develop dictionary management function --- components.d.ts | 2 + src/assets/css/style.scss | 16 ++- src/components/list/VirtualWordList2.vue | 117 ++++++++++++++++++++++ src/components/list/WordItem.vue | 11 +++ src/main.ts | 3 + src/pages/dict/DictManage.vue | 119 +++++++++++++++-------- src/pages/dict/Test.vue | 35 +++++++ src/stores/base.ts | 4 +- 8 files changed, 259 insertions(+), 48 deletions(-) create mode 100644 src/components/list/VirtualWordList2.vue create mode 100644 src/components/list/WordItem.vue create mode 100644 src/pages/dict/Test.vue diff --git a/components.d.ts b/components.d.ts index d7fd3c12..72990be6 100644 --- a/components.d.ts +++ b/components.d.ts @@ -60,8 +60,10 @@ declare module 'vue' { Tooltip: typeof import('./src/components/Tooltip.vue')['default'] TranslateSetting: typeof import('./src/components/toolbar/TranslateSetting.vue')['default'] VirtualWordList: typeof import('./src/components/list/VirtualWordList.vue')['default'] + VirtualWordList2: typeof import('./src/components/list/VirtualWordList2.vue')['default'] VolumeIcon: typeof import('./src/components/icon/VolumeIcon.vue')['default'] VolumeSetting: typeof import('./src/components/toolbar/VolumeSetting.vue')['default'] + WordItem: typeof import('./src/components/list/WordItem.vue')['default'] WordListDialog: typeof import('./src/components/dialog/WordListDialog.vue')['default'] } export interface ComponentCustomProperties { diff --git a/src/assets/css/style.scss b/src/assets/css/style.scss index a79011f8..ab0d1f09 100644 --- a/src/assets/css/style.scss +++ b/src/assets/css/style.scss @@ -294,6 +294,10 @@ footer { padding: 0 var(--space); } +.list-item-wrapper{ + padding-bottom: 15rem; +} + .common-list-item { width: 100%; box-sizing: border-box; @@ -310,9 +314,14 @@ footer { .left { display: flex; - gap: 3rem; - flex-direction: column; - word-break: break-word; + gap: 10rem; + + .title-wrapper{ + display: flex; + flex-direction: column; + gap: 3rem; + word-break: break-word; + } } .right { @@ -326,7 +335,6 @@ footer { opacity: 0; } - &:hover { background: var(--color-item-hover); diff --git a/src/components/list/VirtualWordList2.vue b/src/components/list/VirtualWordList2.vue new file mode 100644 index 00000000..586c97c8 --- /dev/null +++ b/src/components/list/VirtualWordList2.vue @@ -0,0 +1,117 @@ + + + + + diff --git a/src/components/list/WordItem.vue b/src/components/list/WordItem.vue new file mode 100644 index 00000000..89b1f330 --- /dev/null +++ b/src/components/list/WordItem.vue @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 0c368691..d2b6c3fd 100644 --- a/src/main.ts +++ b/src/main.ts @@ -8,6 +8,8 @@ import VirtualList from 'vue-virtual-list-v3'; import ZH from "@/locales/zh-CN.ts"; import {createI18n} from 'vue-i18n' import router from "@/router.ts"; +import VueVirtualScroller from 'vue-virtual-scroller' +import 'vue-virtual-scroller/dist/vue-virtual-scroller.css' const i18n = createI18n({ locale: 'zh-CN', @@ -21,6 +23,7 @@ const pinia = createPinia() // const app = createApp(Mobile) const app = createApp(App) +app.use(VueVirtualScroller) // app.use(ElementPlus) app.use(pinia) app.use(VirtualList); diff --git a/src/pages/dict/DictManage.vue b/src/pages/dict/DictManage.vue index 4bfa0c0d..65730a02 100644 --- a/src/pages/dict/DictManage.vue +++ b/src/pages/dict/DictManage.vue @@ -27,6 +27,8 @@ import VirtualWordList from "@/components/list/VirtualWordList.vue"; import Dialog from "@/components/dialog/Dialog.vue"; import {nanoid} from "nanoid"; import {no} from "@/utils"; +import Test from "@/pages/dict/Test.vue"; +import VirtualWordList2 from "@/components/list/VirtualWordList2.vue"; const store = useBaseStore() const settingStore = useSettingStore() @@ -80,7 +82,9 @@ async function selectDict(val: { if (!runtimeStore.editDict.originWords.length) { let r = await fetch(url) let v = await r.json() - v.map(s => s.id = nanoid(6)) + v.map(s => { + s.id = nanoid(6) + }) runtimeStore.editDict.originWords = cloneDeep(v) changeSort(runtimeStore.editDict.sort) } @@ -550,8 +554,13 @@ function resetChapterList() { chapterList2 = Array.from({length: runtimeStore.editDict.chapterWords.length}).map((v, i) => ({id: i})) } -function handleCheckedChapterWordListChange(source: any) { - source.checked = !source.checked +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 @@ -657,7 +666,7 @@ const isPinDict = $computed(() => { 导出 -
{{runtimeStore.editDict.description}}
+
{{ runtimeStore.editDict.description }}
总词汇: {{ runtimeStore.editDict.originWords.length }}词
@@ -742,48 +751,72 @@ const isPinDict = $computed(() => {
- -
diff --git a/src/pages/dict/Test.vue b/src/pages/dict/Test.vue new file mode 100644 index 00000000..eafc3ea2 --- /dev/null +++ b/src/pages/dict/Test.vue @@ -0,0 +1,35 @@ + + + + + \ No newline at end of file diff --git a/src/stores/base.ts b/src/stores/base.ts index dca559f5..1d3cfcd4 100644 --- a/src/stores/base.ts +++ b/src/stores/base.ts @@ -220,7 +220,9 @@ export const useBaseStore = defineStore('base', { let r = await fetch(dictResourceUrl) // let r = await fetch(`.${this.currentDict.url}`) let v = await r.json() - v.map(s => s.id = nanoid(6)) + v.map(s => { + s.id = nanoid(6) + }) if (this.currentDict.translateLanguage === 'common') { const runtimeStore = useRuntimeStore() let r2 = await fetch('./translate/en2zh_CN-min.json')