tsp-component
Version:
提供多端和react版本的UI组件
48 lines (42 loc) • 1.51 kB
text/typescript
import Exception from '../exception';
import Promise from 'promise-polyfill';
import WebApi from '../ajax/webapi';
import Request from './request';
import View from '../view';
import ListView from '../list-view';
import EventTracking from '../event-tracking';
declare const process: {
env: {
NODE_ENV: string;
}
};
export default function init(options: TspFrameworkInitOptions, request: Request): void {
/** View默认请求发送函数 */
View.defaultProps.request = request.send;
/** ListView默认请求发送函数 */
ListView.defaultProps.request = request.send;
/** 请求成功后执行的响应函数 */
WebApi.response = options.request.response;
/** 默认请求参数 */
WebApi.defaultParams = options.request.defaultParams;
/** Promise polyfill */
if (!window['Promise']) {
window['Promise'] = Promise;
}
/** 初始化异常监控 */
if (options.component.Exception) {
if (options.component.Exception.apiname) {
Exception.apiname = options.component.Exception.apiname;
}
Exception.productCode = 1;
Exception.version = options.config.version;
Exception.webapi = new WebApi('https://fed.summersky.cn', undefined);
Exception.listen();
}
if (options.component.EventTracking) {
EventTracking.request = request.send;
EventTracking.api = options.component.EventTracking.api;
EventTracking.host = options.component.EventTracking.host;
EventTracking.onUnload();
}
}