export interface UploadFile {
  /** 原始文件对象 */
  originFileObj?: File;
  /** 文件URL */
  filePath?: string;
  /** 文件ID */
  id?: string;
  [key: string]: any;
}

export interface BaseParams {
  /** 文件类型 */
  type: number;
  /** 企业id */
  corpinfoId?: string;
}

export interface SingleParams extends BaseParams {
  /** 外键id - 单文件上传时可选 */
  foreignKey?: string;
}

export interface MultipleParams extends BaseParams {
  /** 外键id - 多文件上传时必填 */
  foreignKey: string;
}

export interface SingleUploadFileOptions {
  /** 要上传的文件 */
  files: UploadFile[];
  /** 是否单文件上传 */
  single?: true;
  /** 上传的参数 */
  params: SingleParams;
}

export interface MultipleUploadFileOptions {
  /** 要上传的文件 */
  files: UploadFile[];
  /** 是否单文件上传 */
  single: false;
  /** 上传的参数 */
  params: MultipleParams;
}

export interface SingleFileResponse {
  /** 文件路径 */
  filePath: string;
  [key: string]: any;
}

export interface MultipleFileResponse {
  /** 文件ID */
  id: string;
  [key: string]: any;
}

export interface UploadFileFunction {
  (options: SingleUploadFileOptions): Promise<SingleFileResponse>;
  (options: MultipleUploadFileOptions): Promise<MultipleFileResponse>;
}

/**
 * 上传文件
 */
export default function useUploadFile(returnType: "array"): [boolean, UploadFileFunction];
export default function useUploadFile(returnType?: "object"): { loading: boolean; uploadFile: UploadFileFunction };
