diff --git a/components.d.ts b/components.d.ts index 8eff84d8..d480b586 100644 --- a/components.d.ts +++ b/components.d.ts @@ -65,7 +65,6 @@ declare module 'vue' { 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'] - WordChapterList: typeof import('./src/components/list2/WordChapterList.vue')['default'] WordItem: typeof import('./src/components/list/WordItem.vue')['default'] WordList: typeof import('./src/components/list2/WordList.vue')['default'] WordListDialog: typeof import('./src/components/dialog/WordListDialog.vue')['default'] diff --git a/src/components/dialog/DictDiglog.vue b/src/components/dialog/DictDiglog.vue index 85f2f2ca..c1a509de 100644 --- a/src/components/dialog/DictDiglog.vue +++ b/src/components/dialog/DictDiglog.vue @@ -8,7 +8,6 @@ import BaseButton from "@/components/BaseButton.vue"; import {Icon} from '@iconify/vue'; import {ActivityCalendar} from "vue-activity-calendar"; import "vue-activity-calendar/style.css"; -import ChapterList from "@/components/list/ChapterList.vue"; import WordListDialog from "@/components/dialog/WordListDialog.vue"; import {isArticle} from "@/hooks/article.ts"; import {useRuntimeStore} from "@/stores/runtime.ts"; @@ -23,7 +22,7 @@ import {nanoid} from "nanoid"; import DictListPanel from "@/components/DictListPanel.vue"; import {useRouter} from "vue-router"; import ArticleList4 from "@/components/list2/ArticleList4.vue"; -import WordChapterList from "@/components/list2/WordChapterList.vue"; +import BaseList from "@/components/list2/BaseList.vue"; const store = useBaseStore() const settingStore = useSettingStore() @@ -78,7 +77,7 @@ async function selectDict(val: { dict: DictResource | Dict, index: number }) { } } } - chapterList2 = Array.from({length: runtimeStore.editDict.chapterWords.length}).map((v, i) => ({id: i})) + chapterList2 = runtimeStore.editDict.chapterWords.map((v, i) => ({id: i})) loading = false } @@ -341,18 +340,24 @@ function showWordListModal(val: { item: Word, index: number }) { - runtimeStore.editDict.chapterIndex = val.index" :active-index="runtimeStore.editDict.chapterIndex" > - - + + - + + + 第{{ item.id + 1 }}章 + {{ runtimeStore.editDict.chapterWords[item.id]?.length }}词 + + + diff --git a/src/components/list2/BaseList.vue b/src/components/list2/BaseList.vue index 7fd83cf4..af4d2f4e 100644 --- a/src/components/list2/BaseList.vue +++ b/src/components/list2/BaseList.vue @@ -9,12 +9,14 @@ const props = withDefaults(defineProps<{ activeId?: string, isActive?: boolean showBorder?: boolean + static?: boolean }>(), { list: [], activeIndex: -1, activeId: '', isActive: false, - showBorder: false + showBorder: false, + static: true }) const emit = defineEmits<{ @@ -25,8 +27,7 @@ const emit = defineEmits<{ }>() //虚拟列表长度限制 -const limit = 1 - +const limit = 0 const settingStore = useSettingStore() const listRef: any = $ref() @@ -47,18 +48,21 @@ function scrollViewToCenter(index: number) { } watch(() => localActiveIndex, (n: any) => { + if (props.static) return if (settingStore.showPanel) { scrollViewToCenter(n) } }) watch(() => props.isActive, (n: boolean) => { - setTimeout(() => { - if (n) scrollViewToCenter(localActiveIndex) - }, 300) + if (props.static) return + if (n) { + setTimeout(() => scrollViewToCenter(localActiveIndex), 300) + } }) watch(() => props.list, () => { + if (props.static) return if (props.list.length > limit) { listRef?.scrollToItem(0) } else { diff --git a/src/components/list2/WordChapterList.vue b/src/components/list2/WordChapterList.vue deleted file mode 100644 index 4a420440..00000000 --- a/src/components/list2/WordChapterList.vue +++ /dev/null @@ -1,59 +0,0 @@ - - - - emit('click',e)" - :list="list" - v-bind="$attrs"> - - - - - - 第{{ index + 1 }}章 {{ item.length }}词 - - - - - - - - - \ No newline at end of file diff --git a/src/pages/dict/components/ArticleDictDetail.vue b/src/pages/dict/components/ArticleDictDetail.vue index 99ce936e..114283e2 100644 --- a/src/pages/dict/components/ArticleDictDetail.vue +++ b/src/pages/dict/components/ArticleDictDetail.vue @@ -47,11 +47,16 @@ function delArticle(index: number) { runtimeStore.editDict.articles.splice(index, 1) if (runtimeStore.editDict.articles.length) { + if (chapterIndex >= runtimeStore.editDict.articles.length - 1) { + chapterIndex = runtimeStore.editDict.articles.length - 1 + article = runtimeStore.editDict.articles[chapterIndex] + } if (chapterIndex === index) { - article = runtimeStore.editDict.articles[index] + article = runtimeStore.editDict.articles[chapterIndex] } } else { article = cloneDeep(DefaultArticle) + chapterIndex = -1 } syncMyDictList(runtimeStore.editDict) ElMessage.success('删除成功!') @@ -61,7 +66,10 @@ const emit = defineEmits<{ back: [] }>() -async function getDictDetail(val: { dict: DictResource | Dict, index: number }) { +async function getDictDetail(val: { + dict: DictResource | Dict, + index: number +}) { let item = val.dict // console.log('word-getDictDetail', item) chapterIndex = -1 @@ -189,7 +197,10 @@ function importData(e: any) { reader.readAsBinaryString(file); } -function exportData(val: { type: string, data?: Article }) { +function exportData(val: { + type: string, + data?: Article +}) { const {type, data} = val let list = [] let filename = '' @@ -309,7 +320,7 @@ defineExpose({getDictDetail, add, editDict}) - + props.list, (n) => { checkStatus() }) -function handleCheckedChange({word: source}: any) { +function handleCheckedChange({item: source}: any) { source.checked = !source.checked checkStatus() } @@ -89,6 +92,7 @@ defineExpose({scrollToBottom, scrollToItem}) let show = $ref(false) useWindowClick(() => show = false) +const playWordAudio = usePlayWordAudio() @@ -140,30 +144,41 @@ useWindowClick(() => show = false) - + - - + - + + + {{ item.name }} + {{ item.usphone }} + + + + {{ tran }} + + + - + @@ -200,6 +215,7 @@ useWindowClick(() => show = false) } .wrapper { + display: flex; flex: 1; overflow: hidden; } diff --git a/src/pages/dict/components/WordDictDetail.vue b/src/pages/dict/components/WordDictDetail.vue index be9222c9..ea93c538 100644 --- a/src/pages/dict/components/WordDictDetail.vue +++ b/src/pages/dict/components/WordDictDetail.vue @@ -1,7 +1,6 @@