68 lines
1.4 KiB
TypeScript
68 lines
1.4 KiB
TypeScript
/*
|
||
* @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,
|
||
})
|
||
},
|
||
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,
|
||
})
|
||
},
|
||
},
|
||
}
|
||
export const Preview: Story = {
|
||
name: '启用disabled,当做预览组件',
|
||
args: {
|
||
fileUrl: avatar,
|
||
disabled: true,
|
||
fileFunction() {
|
||
return Promise.resolve({
|
||
id: 2,
|
||
url: avatar,
|
||
})
|
||
},
|
||
},
|
||
}
|