feat: 文件列表上传组件

This commit is contained in:
2023-08-16 18:25:21 +08:00
parent a241be7b00
commit 777bafbb7d
3 changed files with 119 additions and 0 deletions

View File

@ -0,0 +1,46 @@
import type { Meta, StoryObj } from '@storybook/vue3'
import ThUploadList from '../packages/upload-list/index.vue'
import avatar from './assets/avatar.jpeg'
// 模拟2秒钟的接口请求
function request(formData: FormData) {
let name = '佚名文件'
let url = avatar
const fileName = formData.get('name')
const file = formData.get('file')
if (typeof fileName === 'string') {
name = fileName
}
else if (typeof file !== 'string' && file) {
name = file.name
url = URL.createObjectURL(file)
}
return new Promise<FileVO>((resolve) => {
setTimeout(() => {
resolve({
id: Date.now(),
name,
url,
createdBy: 'user',
})
}, 2000)
})
}
const meta = {
title: '表单组件/UploadList',
component: ThUploadList,
args: {
accept: '*',
fileList: [],
request,
filePath: '/',
},
tags: ['autodocs'],
} satisfies Meta<typeof ThUploadList>
export default meta
type Story = StoryObj<typeof meta>
export const Base: Story = {
name: '基本使用',
}