This commit is contained in:
Zyronon
2025-11-17 23:44:45 +08:00
parent 697db5f975
commit 135ae13b6f
5 changed files with 118 additions and 56 deletions

View File

@@ -7,13 +7,11 @@ import BaseInput from "@/components/base/BaseInput.vue";
interface IProps {
list: Article[];
showTranslate?: boolean;
activeId: string | number;
}
const props = withDefaults(defineProps<IProps>(), {
list: () => [] as Article[],
showTranslate: true,
activeId: ""
})
const emit = defineEmits<{
@@ -79,7 +77,10 @@ defineExpose({ scrollToBottom, scrollToItem })
</template>
</BaseInput>
</div>
<BaseList ref="listRef" @click="(e: any) => emit('click', e)" :list="localList" v-bind="$attrs">
<BaseList ref="listRef"
@click="(e: any) => emit('click', e)"
:list="localList"
v-bind="$attrs">
<template v-slot:prefix="{ item, index }">
<slot name="prefix" :item="item" :index="index"></slot>
</template>

View File

@@ -5,13 +5,13 @@ import { nextTick, watch } from 'vue'
const props = withDefaults(defineProps<{
list?: any[],
activeIndex?: number,
activeId?: number,
activeId?: number | string,
isActive?: boolean
static?: boolean
}>(), {
list: [],
activeIndex: -1,
activeId: null,
activeId: '',
isActive: false,
static: true
})
@@ -94,7 +94,7 @@ function scrollToItem(index: number) {
function itemIsActive(item: any, index: number) {
return props.activeId ?
props.activeId === item.id
props.activeId == item.id
: props.activeIndex === index
}