From d602d5459a561cc00f5e5f760e8e156f0f6d7d4d Mon Sep 17 00:00:00 2001 From: zyronon Date: Sat, 2 Dec 2023 16:59:03 +0800 Subject: [PATCH] save --- components.d.ts | 3 +- src/components/DictListPanel.vue | 4 +- src/components/dialog/DictDiglog.vue | 2 +- src/components/list/BaseList.vue | 20 +- .../{toolbar => list}/DictGroup.vue | 15 +- src/components/list/DictItem.vue | 29 +- src/components/list/DictList.vue | 4 +- src/pages/dict/components/ChapterWordList.vue | 3 +- src/pages/dict/components/WordDictDetail.vue | 32 +- src/stores/base.ts | 466 +++++++++--------- 10 files changed, 306 insertions(+), 272 deletions(-) rename src/components/{toolbar => list}/DictGroup.vue (82%) diff --git a/components.d.ts b/components.d.ts index e605a338..1af9bca1 100644 --- a/components.d.ts +++ b/components.d.ts @@ -9,7 +9,6 @@ declare module 'vue' { export interface GlobalComponents { Add: typeof import('./src/components/toolbar/Add.vue')['default'] ArticleList: typeof import('./src/components/list/ArticleList.vue')['default'] - ArticleList4: typeof import('./src/components/list/ArticleList4.vue')['default'] Backgorund: typeof import('./src/components/Backgorund.vue')['default'] BaseButton: typeof import('./src/components/BaseButton.vue')['default'] BaseIcon: typeof import('./src/components/BaseIcon.vue')['default'] @@ -18,7 +17,7 @@ declare module 'vue' { Close: typeof import('./src/components/icon/Close.vue')['default'] Dialog: typeof import('./src/components/dialog/Dialog.vue')['default'] DictDiglog: typeof import('./src/components/dialog/DictDiglog.vue')['default'] - DictGroup: typeof import('./src/components/toolbar/DictGroup.vue')['default'] + DictGroup: typeof import('./src/components/list/DictGroup.vue')['default'] DictItem: typeof import('./src/components/list/DictItem.vue')['default'] DictList: typeof import('./src/components/list/DictList.vue')['default'] DictListPanel: typeof import('./src/components/DictListPanel.vue')['default'] diff --git a/src/components/DictListPanel.vue b/src/components/DictListPanel.vue index f47f63bf..3de9da74 100644 --- a/src/components/DictListPanel.vue +++ b/src/components/DictListPanel.vue @@ -8,7 +8,7 @@ import {useBaseStore} from "@/stores/base.ts"; import {useSettingStore} from "@/stores/setting.ts"; import {useRuntimeStore} from "@/stores/runtime.ts"; import DictList from "@/components/list/DictList.vue"; -import DictGroup from "@/components/toolbar/DictGroup.vue"; +import DictGroup from "@/components/list/DictGroup.vue"; const emit = defineEmits<{ add: [], @@ -160,7 +160,7 @@ const groupedByCategoryAndTag = $computed(() => { flex: 1; overflow: auto; height: 100%; - padding-right: var(--space); + padding-right: 10rem; .translate { display: flex; diff --git a/src/components/dialog/DictDiglog.vue b/src/components/dialog/DictDiglog.vue index e0ef43e0..92f54a45 100644 --- a/src/components/dialog/DictDiglog.vue +++ b/src/components/dialog/DictDiglog.vue @@ -412,7 +412,7 @@ $header-height: 60rem; //transform: translate(-50%, -50%); background: var(--color-second-bg); z-index: 99999; - width: 1000rem; + width: 1030rem; height: 75vh; } diff --git a/src/components/list/BaseList.vue b/src/components/list/BaseList.vue index a21a12f8..875c8829 100644 --- a/src/components/list/BaseList.vue +++ b/src/components/list/BaseList.vue @@ -40,7 +40,7 @@ const localActiveIndex = $computed(() => { function scrollViewToCenter(index: number) { if (index === -1) return - nextTick(()=>{ + nextTick(() => { if (props.list.length > limit) { listRef?.scrollToItem(index) } else { @@ -65,7 +65,7 @@ watch(() => props.isActive, (n: boolean) => { watch(() => props.list, () => { if (props.static) return - nextTick(()=>{ + nextTick(() => { if (props.list.length > limit) { listRef?.scrollToItem(0) } else { @@ -75,14 +75,22 @@ watch(() => props.list, () => { }) function scrollToBottom() { - nextTick(()=>{ - listRef.scrollToBottom() + nextTick(() => { + if (props.list.length > limit) { + listRef.scrollToBottom() + } else { + listRef?.scrollTo(0, listRef.scrollHeight) + } }) } function scrollToItem(index: number) { - nextTick(()=>{ - listRef.scrollToItem(index) + nextTick(() => { + if (props.list.length > limit) { + listRef?.scrollToItem(index) + } else { + listRef?.children[index]?.scrollIntoView({block: 'center', behavior: 'smooth'}) + } }) } diff --git a/src/components/toolbar/DictGroup.vue b/src/components/list/DictGroup.vue similarity index 82% rename from src/components/toolbar/DictGroup.vue rename to src/components/list/DictGroup.vue index 92b513bd..905bcdf7 100644 --- a/src/components/toolbar/DictGroup.vue +++ b/src/components/list/DictGroup.vue @@ -3,6 +3,7 @@ import {$computed, $ref} from "vue/macros"; import {watch} from "vue"; import {DictResource} from "@/types.ts"; import DictItem from "@/components/list/DictItem.vue"; +import DictList from "@/components/list/DictList.vue"; const props = defineProps<{ category: string, @@ -34,12 +35,9 @@ watch(() => props.groupByTag, () => { v-for="i in Object.keys(groupByTag)">{{ i }} -
- -
+ @@ -74,9 +72,4 @@ watch(() => props.groupByTag, () => { } } -.dict-list { - display: grid; - grid-template-columns: repeat(4, 1fr); - gap: 15rem; -} \ No newline at end of file diff --git a/src/components/list/DictItem.vue b/src/components/list/DictItem.vue index ec2f0226..f9a58cbd 100644 --- a/src/components/list/DictItem.vue +++ b/src/components/list/DictItem.vue @@ -21,8 +21,10 @@ const emit = defineEmits<{ :class="active && 'active'" >
@@ -35,24 +37,41 @@ const emit = defineEmits<{