@tb-app/web-view-api
Version:
实现webview与淘宝小程序之间的通信
88 lines (87 loc) • 1.78 kB
TypeScript
declare type FileTypes = 'image' | 'video' | 'audio' | 'other';
/**
* 文件上传
* @param options
*/
declare function uploadFile(options: {
filePath: string;
fileType: FileTypes;
fileName?: string;
file?: any;
}): Promise<{
fileId: string;
url: string;
}>;
/**
* 删除文件
* @param options
*/
declare function deleteFile(options: {
fileType?: FileTypes;
fileId: string;
}): Promise<boolean>;
/**
* 根据文件id(cloud://)获取授权的url
* @param options
*/
declare function getTempFileURL(options: {
fileType: string;
fileId: string | string[];
}): Promise<{
fileId: string;
status: number;
url: string;
}[]>;
/**
* 调用 top API
* @param options
* @returns
*/
declare function invoke(options: {
api: string;
data?: any;
headers?: any;
authScope?: string;
}): Promise<any>;
declare type Env = 'test' | 'pre' | 'online';
declare type Envs = {
database: Env;
file: Env;
function: Env;
message: Env;
};
/**
* 初始化cloud
* @param options
* @returns
*/
declare function init(options: {
env?: Env | Envs;
appKey?: string;
}): Promise<boolean>;
/**
* http 请求
*/
declare function httpRequest(options: {
path: string;
params?: any;
body?: any;
headers?: any;
method?: string;
exts?: any;
}): Promise<any>;
declare const _default: {
file: {
uploadFile: typeof uploadFile;
deleteFile: typeof deleteFile;
getTempFileURL: typeof getTempFileURL;
};
topApi: {
invoke: typeof invoke;
};
init: typeof init;
application: {
httpRequest: typeof httpRequest;
};
};
export default _default;