Skip to main content

消息组件

消息展示相关组件:ConversationListConversationSubtitle

ConversationList

对话历史列表组件,自动订阅对话变化。

基本用法

<script setup lang="ts">
import {PilotKit, ConversationList} from '@bdky/aaas-pilot-kit-vue3-widget';
</script>

<template>
<PilotKit v-bind="props">
<ConversationList />
</PilotKit>
</template>

响应式适配

📱 详见 响应式适配指南

特性PC 端移动端
对话显示显示全部历史仅显示最新一条
关闭按钮显示隐藏
滚动跟随按钮显示隐藏
位置绝对定位左侧相对定位

Props

属性类型默认值说明
variant'auto' | 'mobile' | 'desktop''auto'显示模式
classstring-自定义类名
styleCSSProperties-自定义样式
autoScrollbooleantrue是否自动滚动到底部
closablebooleantrue是否显示关闭按钮

事件

事件类型说明
@close() => void关闭回调

Slots

插槽Props说明
default{conversations, latestConversation}自定义渲染
closeIcon-自定义关闭图标

自定义渲染

<template>
<ConversationList v-slot="{conversations, latestConversation}">
<div class="my-conversation-list">
<div
v-for="conv in conversations"
:key="conv.id"
class="my-conversation-item"
>
{{ conv.type === 'client' ? '用户' : 'AI' }}
</div>
</div>
</ConversationList>
</template>

样式定制

类名说明
.apk-conversation-list根容器
.apk-conversation-list--mobile移动端样式
.apk-conversation-list--desktop桌面端样式
.apk-conversation-list__inner内层滚动容器
.apk-conversation-list__follow-button滚动跟随按钮
.apk-conversation-list__icons-wrapper关闭按钮容器

Conversation

单条消息组件,展示消息内容。

基本用法

通常配合 ConversationList 使用,也可单独使用:

<script setup lang="ts">
import {Conversation} from '@bdky/aaas-pilot-kit-vue3-widget';

defineProps<{
conversations: any[];
}>();
</script>

<template>
<div>
<Conversation
v-for="(conv, index) in conversations"
:key="conv.id"
:conversation="conv"
:isLatest="index === conversations.length - 1"
/>
</div>
</template>

响应式适配

特性PC 端移动端
圆角20px不同方向不同圆角
边距左右 30px左右 39px
背景半透明更深的半透明

Props

属性类型默认值说明
conversationAnyConversation必填对话对象
isLatestbooleanfalse是否是最新一条
variant'auto' | 'mobile' | 'desktop''auto'显示模式
classstring-自定义类名
styleCSSProperties-自定义样式

事件

事件类型说明
@complete(payload) => void对话完成回调

Slots

插槽Props说明
default{contents, fullText, type, isCompleted}自定义渲染

自定义渲染

<template>
<Conversation
:conversation="conv"
v-slot="{contents, fullText, type, isCompleted}"
>
<div :class="['my-message', `my-message--${type}`]">
<p>{{ fullText }}</p>
<span v-if="!isCompleted" class="typing">...</span>
</div>
</Conversation>
</template>

样式定制

类名说明
.apk-conversation根容器
.apk-conversation--client用户消息
.apk-conversation--aiAI 消息
.apk-conversation--mobile移动端样式
.apk-conversation--desktop桌面端样式
.apk-conversation__content-item内容项
.apk-conversation__content-text文字内容
.apk-conversation__content-image图片内容
.apk-conversation__content-video视频内容

Subtitle

实时字幕组件,显示最新一条对话的内容。

基本用法

<script setup lang="ts">
import {PilotKit, Subtitle} from '@bdky/aaas-pilot-kit-vue3-widget';
</script>

<template>
<PilotKit v-bind="props">
<Subtitle showSpeaker />
</PilotKit>
</template>

可展开字幕

<script setup lang="ts">
import {ref} from 'vue';
import {Subtitle} from '@bdky/aaas-pilot-kit-vue3-widget';

const expanded = ref(false);
</script>

<template>
<Subtitle
expandable
:expanded="expanded"
@expand="expanded = true"
/>
</template>

Props

属性类型默认值说明
classstring-自定义类名
styleCSSProperties-自定义样式
showSpeakerbooleantrue是否显示说话人
aiSpeakerNamestring'AI'AI 说话人名称
userSpeakerNamestring'我'用户说话人名称
expandablebooleanfalse是否可展开
expandedbooleanfalse是否已展开

事件

事件类型说明
@expand() => void展开回调

Slots

插槽Props说明
default{speakerName, fullText, conversation, isExpanded, toggleExpand}自定义渲染

自定义渲染

<template>
<Subtitle v-slot="{speakerName, fullText, isExpanded, toggleExpand}">
<div class="my-subtitle">
<span class="speaker">{{ speakerName }}</span>
<p class="text">{{ fullText }}</p>
<button @click="toggleExpand">
{{ isExpanded ? '收起' : '展开' }}
</button>
</div>
</Subtitle>
</template>

样式定制

类名说明
.apk-subtitle根容器
.apk-subtitle__wrapper内容包装器
.apk-subtitle__expand-btn展开按钮
.apk-subtitle__text文本区域
.apk-subtitle__scroll-view滚动视图

相关