Skip to content

Chat App ​

Vue 已实现 · 还原验收 0/1 · 上游演示 · 固定版本源码

预览 ​

How can I help with your project?

用法 ​

vue
<script setup lang="ts">
import { AISidebar, ChatApp, Message, MessageBubble, MessageBubbleContent, MessageGroup, MessageScroller, PromptInput, type SidebarResource } from 'beui-vue'
import { ref } from 'vue'
const items: SidebarResource[] = [{ id:'design', label:'Design review', kind:'project' }, { id:'release', label:'Release notes', kind:'file' }]
const messages = ref([{ from:'assistant' as 'user' | 'assistant', text:'How can I help with your project?' }])
function send(text: string) { messages.value.push({from:'user',text}, {from:'assistant',text:`Added to the conversation: ${text}`}) }
</script>
<template><ChatApp sidebar-width="11rem"><template #sidebar><AISidebar :default-items="items" /></template><template #default="{ open, toggle }"><div><button type="button" class="be-agent-button" :aria-expanded="open" @click="toggle">Resources</button></div><MessageScroller style="height:12rem"><MessageGroup><Message v-for="(message,index) in messages" :key="index" :from="message.from"><MessageBubble :variant="message.from === 'user' ? 'solid' : 'soft'"><MessageBubbleContent>{{ message.text }}</MessageBubbleContent></MessageBubble></Message></MessageGroup></MessageScroller><PromptInput @submit="send" /></template></ChatApp></template>

API ​

#sidebar 与默认插槽组成聊天外壳。插槽提供 open、setOpen,主内容另有 toggle。sidebarWidth、collapseSidebarBelow 控制停靠宽度,v-model:open 交给调用方管理。

还原验收 ​

基于 beUI 的独立 Vue 移植,依 MIT 许可证分发。