@kjts20/tool-react-h5
Version:
164 lines (156 loc) • 4.08 kB
TypeScript
import * as react from 'react';
import { IHttpServerOptions, IStorageApi } from '@kjts20/tool';
declare class RefsManager {
private refInsStore;
constructor();
get(refName: any): any;
getAll(refName: any): any;
linkRef(refName: any): react.RefObject<unknown>;
removeRef(refName: any): boolean;
clearNullRefs(): void;
}
/**
* 使用axios转换为httpServer格式
* 1、系统统一使用httpServer
*/
declare const axios2HttpServer: {
request: IHttpServerOptions['request'];
uploadFile: IHttpServerOptions['uploadFile'];
};
/**
* 生成仓库实现类
* @param storage 仓库
* @returns
*/
declare const toStorageImpl: (storage: Storage) => IStorageApi;
/**
* localStorage实现
*/
declare const localStorageImpl: IStorageApi;
/**
* sessionStorage实现
*/
declare const sessionStorageImpl: IStorageApi;
/**
* 读取上传的文件
* @param file 上传的文件
* @returns
*/
declare const readUploadFile: (file: Blob) => Promise<string>;
/**
* 读取json文件
* @param file 上传文件
* @returns
*/
declare const readUploadJsonFile: <R = any>(file: Blob) => Promise<R>;
/**
* 文件路径
*/
interface IFilepath {
paths: string;
name: string;
ext: string;
content: string;
}
interface ITreeNode {
key: string;
title: string;
children?: Array<ITreeNode>;
isLeaf?: boolean;
}
interface IFileAndTreeData<T> {
fileDict: {
[key: string]: T;
};
treeNode: Array<ITreeNode>;
}
declare const pathSeparator = "/";
/**
* 文件内容转树形结构
* @param fileData 文件内容列表
* @returns
*/
declare const fileData2TreeNode: <T extends IFilepath>(fileData: T[]) => IFileAndTreeData<T>;
/**
* 下载zip文件子项
*/
interface IDownloadZipFileItem {
paths: string;
name: string;
ext: string;
content: string;
}
/**
* 下载zip文件
* @param fileList 文件列表
* @param zipName zip文件名字
* @returns
*/
declare const downloadZip: <T extends IDownloadZipFileItem>(fileList: T[], downloadName?: any) => Promise<unknown>;
/**
* 下载文件
* @param downloadFileName 文件名字
* @param fileContent 文件内容
* @returns
*/
declare const downloadFile: (downloadFileName: any, fileContent: any) => Promise<unknown>;
/**
* arrayBuffer 转图片base64
* @param buffer
* @returns
*/
declare const arrayBufferToBase64Img: (buffer: any, imgExtension?: string) => string;
/**
* gzip 解码
* @param gzipStr
* @returns
*/
declare const unGzip: (gzipStr: any) => any;
/**
* gzip 编码
* @param data
* @returns
*/
declare const gzip: (data: object) => string;
/**
* base64转文件对象
* @param base64Data
* @returns
*/
declare const base64ToBlob: (base64Data: any) => Blob;
/**
* 获取文件base64编码
* @param blob 读取文件base64的字节码文件
*/
declare const getBase64: <File_1 extends Blob>(file: File_1) => Promise<string>;
/**
* CSV字段
*/
interface ICsvColumn {
title: string;
column: string;
}
/**
* 下载CSV文件
* @param downloadFileName 文件名称
* @param columnList 字段列表
* @param dataSource 数据源
* @returns
*/
declare const downloadCsv: (downloadFileName: any, columnList: Array<ICsvColumn>, dataSource?: Array<any>) => Promise<unknown>;
/**
* 下载json文件
* @param downloadFileName 文件名称
* @param json json对象
* @param spaceNum 空格数量
* @returns
*/
declare const downloadJson: (downloadFileName: any, json: object, spaceNum?: number) => Promise<unknown>;
/**
* 文件下载
* @param content 字节码文件内容
* @param fileName 下载名字
* @return 下载文件的名字
*/
declare const download: (content: Blob, fileName: string) => string;
export { ICsvColumn, IDownloadZipFileItem, IFileAndTreeData, IFilepath, ITreeNode, RefsManager, arrayBufferToBase64Img, axios2HttpServer, base64ToBlob, download, downloadCsv, downloadFile, downloadJson, downloadZip, fileData2TreeNode, getBase64, gzip, localStorageImpl, pathSeparator, readUploadFile, readUploadJsonFile, sessionStorageImpl, toStorageImpl, unGzip };