@aplus-frontend/ui
Version:
125 lines (124 loc) • 2.78 kB
TypeScript
import { ComputedRef, VNode } from 'vue';
export type FileUploadType = 'picture' | 'singleFile' | 'multipleFile';
/**
* 是否需要返回图片名称
*/
export type NeedNameModel = boolean | {
nameKey?: string;
pathKey?: string;
};
/**
* 是否需要返回图片名称 - 默认值
*/
export declare enum NeedNameKeyDefault {
nameKey = "name",
pathKey = "path"
}
export type FileUploadProps = {
/**
* oss DirName 必填
*/
dirName: string;
/**
* 组件类型
* singlePicture - 单图片
* multiplePicture - 多图片
* singleFile - 单文件
* multipleFile - 多文件
* 默认单文件
*/
type?: FileUploadType;
/**
* 文件大小限制,单位(MB)
* 默认500MB
*/
maxSize?: number;
/**
* 接受上传的文件类型
* 默认不限制
*/
accept?: string;
/**
* 是否需要返回图片名称
* 默认false
* 可以传配置项nameKey,pathKey
* 默认为name,path
*/
needName?: NeedNameModel;
/**
* 超出文件大小错误提示
*/
maxSizeErrorMsg?: string;
/**
* 超出文件数量错误提示
*/
maxCountErrorMsg?: string;
/**
* 文件类型错误提示
*/
acceptErrorMsg?: string;
};
export type SingleFileProps = FileUploadProps & {
/**
* 主标题
*/
title?: string;
/**
* 副标题
*/
subTitle?: string;
};
export type MultipleFileProps = FileUploadProps & {
/**
* 主标题
*/
title?: string;
/**
* 副标题
*/
subTitle?: string | VNode;
/**
* 限制上传数量
*/
maxCount?: number;
};
export type PictureProps = FileUploadProps & {
/**
* 标题
*/
title?: string;
/**
* 限制上传数量
*/
maxCount?: number;
};
export type BeforeUpload = (file: File) => boolean | Promise<boolean>;
export type CustomRequest = (cb: {
onProgress: (p: number) => void;
onError: (msg: string) => void;
onSuccess: (saveUrl: string) => void;
file: File;
}) => void;
export interface ApUploadExpose<SetValueType = any> {
done?: ComputedRef<boolean>;
clear?: () => void;
setValue?: (value: SetValueType) => void;
}
interface ApPictureUploadFile extends File {
uid: string;
thumbUrl?: string;
status: 'error' | 'success' | 'done' | 'uploading' | 'removed';
percent: number;
path?: string;
oss?: {
pauseUpload?: () => Promise<any>;
};
[key: string | number | symbol]: any;
}
export interface ApUploadSlots {
pictureContext: ({ fileList, remove }: {
fileList: ApPictureUploadFile[];
remove: (file: ApPictureUploadFile) => void;
}) => VNode;
}
export {};