Files
vue3/stories/UploadAvatar.stories.ts
2023-08-22 14:12:18 +08:00

71 lines
1.5 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* @Author: zhaojinfeng 121016171@qq.com
* @Date: 2023-07-18 12:28:36
* @LastEditors: zhaojinfeng 121016171@qq.com
* @LastEditTime: 2023-07-21 22:43:52
* @FilePath: \vue3\stories\UploadAvatar.stories.ts
* @Description:
*
*/
import type { Meta, StoryObj } from '@storybook/vue3'
import ThUploadAvatar from '../packages/upload-avatar/index.vue'
import avatar from './assets/avatar.jpeg'
const meta = {
title: '表单组件/UploadAvatar',
component: ThUploadAvatar,
tags: ['autodocs'],
args: {
fileId: '',
fileUrl: '',
accpet: '.jpeg,.jpg,.png,.bmp',
disabled: false,
fileSize: 2,
autoCropHeight: 200,
autoCropWidth: 200,
title: '上传头像',
uploadFunction() {
return Promise.resolve({
id: 0,
url: avatar,
name: '头像',
})
},
onOnSuccess() {
ElMessage.success('模拟上传成功')
},
},
} satisfies Meta<typeof ThUploadAvatar>
export default meta
type Story = StoryObj<typeof meta>
export const Base: Story = {
name: '基本使用',
args: {
fileUrl: avatar,
disabled: true,
fileFunction() {
return Promise.resolve({
id: 1,
url: avatar,
name: '头像',
})
},
},
}
export const Preview: Story = {
name: '启用disabled当做预览组件',
args: {
fileUrl: avatar,
disabled: true,
fileFunction() {
return Promise.resolve({
id: 2,
url: avatar,
name: '头像',
})
},
},
}