Files
FiDA_Front/src/views/home/agent/components/List.vue

42 lines
851 B
Vue
Raw Normal View History

2026-02-10 13:05:24 +08:00
<template>
2026-02-11 16:32:38 +08:00
<div class="agent-list flex flex-col flex-1" ref="listContainer">
2026-02-10 13:05:24 +08:00
<Item v-for="message in messageList" :key="message.id" :content="message" />
</div>
</template>
<script setup lang="ts">
2026-02-11 16:32:38 +08:00
import { ref, nextTick, watch } from 'vue'
2026-02-10 13:05:24 +08:00
import Item from './Item.vue'
2026-02-10 17:22:40 +08:00
const props = defineProps<{
messageList: Array<any>
}>()
2026-02-11 16:32:38 +08:00
const listContainer = ref<HTMLDivElement>()
const scrollToBottom = () => {
nextTick(() => {
if (listContainer.value) {
listContainer.value.scrollTop = listContainer.value.scrollHeight
}
})
}
watch(() => props.messageList, () => {
scrollToBottom()
}, { deep: true })
defineExpose({ scrollToBottom })
2026-02-10 13:05:24 +08:00
</script>
<style lang="less" scoped>
.agent-list {
row-gap: 3.2rem;
2026-02-11 16:32:38 +08:00
overflow-y: auto;
// 隐藏滚动条
&::-webkit-scrollbar {
display: none;
}
2026-02-10 13:05:24 +08:00
}
</style>