feat: 文件列表上传组件
This commit is contained in:
46
stories/UploadList.stories.ts
Normal file
46
stories/UploadList.stories.ts
Normal 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: '基本使用',
|
||||
}
|
Reference in New Issue
Block a user