2.1.9 • Published 3 years ago

@hbtv/media-upload-3x v2.1.9

Weekly downloads
14
License
MIT
Repository
-
Last release
3 years ago

@hbtv/media-upload-3x 文件上传组件

安装

npm install @hbtv/media-upload-3x --save

ChangeLog

更新记录

使用方法

import { MediaUpload } from '@hbtv/media-upload-3x';

<MediaUpload
    services={services}
    fileSize="2m"
    rectSize="300*300"
    fileType={['image','video']}
    maxLength={1}
/>

API

参数说明类型默认值
preview是否显示预览booleantrue
multiple是否允许选择多个booleanfalse
returnUrlOnly是否进返回url, 否则返回整个media对象booleantrue
services上传的接口详见下方定义
fileSize文件大小string,例如:512k, 1Mb等2mb
rectSize图片裁剪大小string,例如: 300*300undefined
fileType文件类型array: ['image', 'file', 'video', 'audio', 'document']['image']
maxLength允许上传的文件个数number1
buttonText上传按钮文章string上传
datakey-value 结构的数据,用于 servicesobject{}
value初始值[]stringundefined
onChange选中后的事件( string或[] ) => voidundefined
showButton是否显示上传按钮booleantrue
visible是的显示对话框booleanfalse
onCancel对话框关闭后的回调() => voidundefined
showTips是否显示上传提示信息booleanfalse
showTips是否显示上传提示信息booleanfalse
uploadVideoByServer是否直接上传视频到服务器booleanfalse
uploadAudioByServer是否直接上传音频到服务器booleanfalse

services 的定义

services 必须实现5个方法,并返回 Promise

interface ServicesType {
    search: (params?: ParamsType) => Promise<any>; // 查询列表 ParamsType 见下方
    destroy: ({ id }: { id: number }) => Promise<any>; // 删除
    upload: (data: FormData) => Promise<any>; // 上传
    token: (disk: string, data: TokenDataType) => Promise<any>; // 获取上传七牛的token  disk=qiniu
    find: ({ id }: { id: number | string }) => Promise<any>; // 查询单个上传文件, 主要用来查询状态
}

interface ParamsType  {
    page?: string;
    pageSize?: string;
    fileSize?: string;
    fileType?: string;
    rectSize?: string;
}

interface TokenDataType {
    fileType: string;
    fileName: string;
    [k:string]: any; // 父组件传来的数据
}
2.1.9

3 years ago

2.1.6

3 years ago

2.1.4

3 years ago

2.1.5

3 years ago

2.1.3

3 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago