控制组件
交互控制相关组件:ControlPanel、Input、RecommendedQuestions。
ControlPanel
语音/文字输入控制面板,支持模式切换。
基本用法
<script setup lang="ts">
import {PilotKit, ControlPanel} from '@bdky/aaas-pilot-kit-vue3-widget';
</script>
<template>
<PilotKit v-bind="props">
<ControlPanel />
</PilotKit>
</template>
响应式适配
📱 详见 响应式适配指南
| 特性 | PC 端 | 移动端 |
|---|---|---|
| 输入框宽度 | 479px 固定 | 100% 自适应 |
| 按钮大小 | 54-55px | 50px |
| 布局 | 居中绝对定位 | 全宽 flex |
| 挂断按钮 | 可选显示 | 始终显示 |
Props
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
variant | 'auto' | 'mobile' | 'desktop' | 'auto' | 显示模式 |
class | string | - | 自定义类名 |
style | CSSProperties | - | 自定义样式 |
mode | 'voice' | 'text' | - | 受控模式 |
defaultMode | 'voice' | 'text' | 'voice' | 默认模式 |
inputValue | string | - | 受控输入值 |
inputPlaceholder | string | '请输入...' | 输入框占位符 |
inputDisabled | boolean | false | 是否禁用输入 |
showHangupButton | boolean | false | 是否显示挂断按钮 |
事件
| 事件 | 类型 | 说明 |
|---|---|---|
@modeChange | (mode) => void | 模式切换回调 |
@inputChange | (value) => void | 输入变化回调 |
@send | (value) => void | 发送回调 |
@muteToggle | (muted) => void | 静音切换回调 |
@hangup | () => void | 挂断回调 |
Slots
| 插槽 | 说明 |
|---|---|
default | 完全自定义渲染 |
muteIcon | 静音状态图标 |
unmuteIcon | 非静音状态图标 |
hangupIcon | 挂断按钮图标 |
asrIcon | ASR 模式图标 |
keyboardIcon | 键盘模式图标 |
sendIcon | 发送按钮图标 |
自定义渲染
<template>
<ControlPanel>
<!-- 完全自定义控制面板 -->
<div class="my-control-panel">
<button>自定义按钮</button>
</div>
</ControlPanel>
</template>
样式定制
| 类名 | 说明 |
|---|---|
.apk-control-panel | 根容器 |
.apk-control-panel--mobile | 移动端样式 |
.apk-control-panel__inner | 内层容器 |
.apk-control-panel__mode-btn | 模式切换按钮 |
.apk-control-panel__input-wrapper | 输入框容器 |
.apk-control-panel__input | 输入框 |
.apk-control-panel__send-btn | 发送按钮 |
.apk-control-panel__mic-btn | 麦克风按钮 |
.apk-control-panel__hangup-btn | 挂断按钮 |
.apk-control-panel__icon | 图标 |
.apk-control-panel__icon-mute | 静音图标 |
Input
独立的文字输入框组件。
基本用法
<script setup lang="ts">
import {PilotKit, Input} from '@bdky/aaas-pilot-kit-vue3-widget';
</script>
<template>
<PilotKit v-bind="props">
<Input placeholder="输入消息..." />
</PilotKit>
</template>
响应式适配
| 特性 | PC 端 | 移动端 |
|---|---|---|
| 宽度 | 479px | 100% |
| 高度 | 55px | 50px |
| 圆角 | 28px | 20px |
| 内边距 | 24px | 16px |
Props
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
variant | 'auto' | 'mobile' | 'desktop' | 'auto' | 显示模式 |
class | string | - | 自定义类名 |
style | CSSProperties | - | 自定义样式 |
modelValue | string | - | v-model 绑定值 |
defaultValue | string | '' | 默认值 |
placeholder | string | '请输入...' | 占位符 |
disabled | boolean | false | 是否禁用 |
maxLength | number | - | 最大长度 |
autoFocus | boolean | false | 是否自动聚焦 |
status | 'default' | 'error' | 'warning' | 'default' | 状态 |
loading | boolean | false | 是否加载中 |
showSendIcon | boolean | true | 是否显示发送图标 |
事件
| 事件 | 类型 | 说明 |
|---|---|---|
@update:modelValue | (value) => void | v-model 更新 |
@textChange | (value) => void | 文本变化回调 |
@send | (value) => void | 发送回调 |
@focus | (e) => void | 聚焦回调 |
@blur | (e) => void | 失焦回调 |
@keydown | (e) => void | 按键回调 |
Slots
| 插槽 | Props | 说明 |
|---|---|---|
default | {value, setValue, handleSend, disabled, loading} | 自定义渲染 |
sendIcon | - | 自定义发送图标 |
自定义渲染
<template>
<Input v-slot="{value, setValue, handleSend, disabled, loading}">
<div class="my-input">
<input
:value="value"
@input="e => setValue(e.target.value)"
:disabled="disabled"
/>
<button @click="handleSend" :disabled="loading">
发送
</button>
</div>
</Input>
</template>
样式定制
| 类名 | 说明 |
|---|---|
.apk-input | 根容器 |
.apk-input--mobile | 移动端样式 |
.apk-input--desktop | 桌面端样式 |
.apk-input__field | 输入框 |
.apk-input__send-icon | 发送图标 |
.apk-input__loader | 加载指示器 |
.apk-input--error | 错误状态 |
.apk-input--warning | 警告状态 |
.apk-input--disabled | 禁用状态 |
.apk-input--loading | 加载状态 |
RecommendedQuestions
推荐问题列表组件。
基本用法
<script setup lang="ts">
import {ref} from 'vue';
import {PilotKit, RecommendedQuestions, type IPilotKitRef} from '@bdky/aaas-pilot-kit-vue3-widget';
const pilotKitRef = ref<IPilotKitRef | null>(null);
function handleQuestionClick(question: string) {
pilotKitRef.value?.input(question);
}
</script>
<template>
<PilotKit ref="pilotKitRef" v-bind="props">
<RecommendedQuestions
:questions="['介绍一下自己', '你能做什么?', '帮我查询订单']"
@questionClick="handleQuestionClick"
/>
</PilotKit>
</template>
响应式适配
| 特性 | PC 端 | 移动端 |
|---|---|---|
| 布局 | 水平排列 | 垂直排列 |
| 背景 | 半透明胶囊 | 透明 |
| 问题项 | 文字 + 箭头 | 卡片样式 |
| 标题 | 显示 | 默认隐藏 |
| 分隔符 | 显示 | 隐藏 |
Props
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
variant | 'auto' | 'mobile' | 'desktop' | 'auto' | 显示模式 |
class | string | - | 自定义类名 |
style | CSSProperties | - | 自定义样式 |
questions | string[] | [] | 问题列表 |
title | string | '试试这样问:' | 标题文本 |
showTitle | boolean | false | 是否显示标题 |
showDivider | boolean | true | 是否显示分隔符 |
expanded | boolean | false | 是否展开状态 |
事件
| 事件 | 类型 | 说明 |
|---|---|---|
@questionClick | (question: string) => void | 点击问题回调 |
Slots
| 插槽 | 说明 |
|---|---|
arrowIcon | 自定义箭头图标 |
样式定制
| 类名 | 说明 |
|---|---|
.apk-recommended-questions | 根容器 |
.apk-recommended-questions--mobile | 移动端样式 |
.apk-recommended-questions__title | 标题 |
.apk-recommended-questions__divider | 分隔符 |
.apk-recommended-questions__list | 问题列表 |
.apk-recommended-questions__item | 问题项 |
.apk-recommended-questions__arrow | 箭头图标 |
.apk-recommended-questions__arrow-icon | 移动端箭头图标 |
相关
- PilotKit - 核心容器组件
- Vue 3 SDK Composables - 底层 Composables