@matechat/core
Version:
前端智能化场景解决方案UI库,轻松构建你的AI应用。
104 lines (103 loc) • 3.44 kB
TypeScript
import type { ExtractPropTypes, InjectionKey, PropType, Ref, VNode } from "vue";
export type FileStatus = "uploading" | "downloading" | "success" | "uploadError" | "downloadError";
export interface FileItem<T = unknown, E = unknown> {
uid: number;
name: string;
size: number;
type?: string;
status?: FileStatus;
percentage?: number;
id?: string | number;
response?: T;
error?: E;
thumbUrl?: string;
url?: string;
}
export interface UploadOptions {
uri: string | URL;
method?: "POST" | "PUT" | "PATCH";
headers?: {
[key: string]: string;
};
authToken?: string;
authTokenHeader?: string;
additionalParameter?: {
[key: string]: string | Blob;
};
fileFieldName?: string;
withCredentials?: boolean;
responseType?: "arraybuffer" | "blob" | "json" | "text";
}
export declare const AttachmentProps: {
readonly uploadOptions: {
readonly type: PropType<UploadOptions>;
readonly default: () => {};
};
readonly disabled: {
readonly type: BooleanConstructor;
readonly default: false;
};
readonly accept: {
readonly type: StringConstructor;
readonly default: "";
};
readonly dropPlaceholder: {
readonly type: StringConstructor;
};
readonly maxCount: {
readonly type: NumberConstructor;
readonly default: number;
};
readonly maxSize: {
readonly type: NumberConstructor;
readonly default: number;
};
readonly multiple: {
readonly type: BooleanConstructor;
readonly default: true;
};
readonly draggable: {
readonly type: BooleanConstructor;
readonly default: true;
};
readonly beforeUpload: {
readonly type: PropType<(file: File) => boolean | Promise<boolean>>;
readonly default: null;
};
readonly getDropContainer: {
readonly type: PropType<() => HTMLElement>;
};
};
export type AttachmentProps = ExtractPropTypes<typeof AttachmentProps>;
export type ValidResultType = "exceedCount" | "unsupportedFileType" | "exceedSizeLimit" | "beforeUploadRejected";
export interface IValidResult {
type: ValidResultType;
file?: File;
}
export declare const AttachmentEmits: {
change: (file: File, fileList: FileItem[]) => boolean;
success: (file: File, response: FileItem["response"], fileList: FileItem[]) => boolean;
error: (file: File, error: FileItem["error"], fileList: FileItem[]) => boolean;
progress: (file: File, fileList: FileItem[]) => boolean;
drop: (files: File[]) => boolean;
validChange: (e: IValidResult[]) => boolean;
};
export type AttachmentEmits = {
(e: "change", file: File, fileList: FileItem[]): void;
(e: "success", file: File, response: FileItem["response"], fileList: FileItem[]): void;
(e: "error", file: File, error: FileItem["error"], fileList: FileItem[]): void;
(e: "progress", file: File, fileList: FileItem[]): void;
(e: "drop", files: File[]): void;
(e: "validChange", validResult: IValidResult[]): void;
};
export interface AttachmentSlots {
default(): VNode;
dropPlaceholder(): VNode;
}
export interface IAttachmentCtx {
rootProps: AttachmentProps;
rootEmits: AttachmentEmits;
isDisabled: Ref<boolean>;
uploadFiles: (files: File[]) => Promise<void>;
}
export declare const AttachmentInjectKey: InjectionKey<IAttachmentCtx>;