Attachment 附件卡片
用于 PromptInput 待发送文件预览与 ChatMessage 历史附件展示,支持图片缩略图、上传进度与失败重试。
基础用法
architecture.png
240.0 KB
api-spec.pdf
500.0 KB
schema.sql
上传超时
<script setup>
import { ref } from 'vue'
import Attachment from '@/vue/components/Attachment.vue'
const files = ref([
{ id: '1', name: 'architecture.png', size: 245760, type: 'image/png', status: 'done' },
{ id: '2', name: 'api-spec.pdf', size: 512000, status: 'uploading', progress: 65 },
{ id: '3', name: 'schema.sql', status: 'error', errorMessage: '上传超时' }
])
function removeFile(item) {
files.value = files.value.filter(f => f.id !== item.id)
}
</script>
<template>
<Attachment :items="files" @remove="removeFile" />
</template>API
| 属性名 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| items | 附件列表 | AttachmentItem[] | [] |
| layout | 布局方式 | 'horizontal' | 'grid' | 'horizontal' |
| removable | 是否显示移除按钮 | boolean | true |
| clickable | 卡片是否可点击 | boolean | false |
