Skip to content

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是否显示移除按钮booleantrue
clickable卡片是否可点击booleanfalse

基于 MIT 许可发布