有奖捉虫:行业应用 & 管理与支持文档专题 HOT
前端 API 集中使用全局命名空间 cloudapp实现,参考下面的类型定义。
interface Window {
cloudapp: GlobalCloudappAPI;
}
?
interface GlobalCloudappAPI {
/**
* 应用 ID
*/
cloudappId: string;
?
/**
* 应用包 ID
*/
packageId: string;
?
/**
* 应用运行模式
*/
mode: 'console';
?
/**
* 获取文件 CDN URL
*/
toCdnUrl: (filename: string) => string;
?
/**
* 运行应用
*/
run: (fn: RunFunction) => void;
?
/**
* 调用应用 API
*/
callAPI: <R = any>(apiName: string, apiPayload?: object) => Promise<CloudappAPIResult<R>>;
/**
* 获取当前云应用实例详情,包含应用对应的云资源清单信息
*/
describeInstanceDetail: () => Promise<any>;
}
?
type RunFunction = (container: Element) => DestroyFunction;
type DestroyFunction = () => void;
interface CloudappAPIResult<R = any> {
ResponseBody: R;
ResponseCode: string; // "Success" 为成功
ResponseMessage: string;
}
?


http://www.vxiaotou.com