UNPKG

tsp-component

Version:

提供多端和react版本的UI组件

58 lines (57 loc) 2.37 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); import * as React from 'react'; import { hashHistory, browserHistory } from 'react-router'; import assign from 'object-assign'; import EventTracking from '../event-tracking'; import init from './init'; import config from './config'; import Global from './global'; import Request from './request'; import WeiXin from './weixin'; import * as router from './router'; var Framework = (function (_super) { __extends(Framework, _super); function Framework(props, state) { var _this = _super.call(this, props, state) || this; _this.router = { goBack: router.goBack, push: _this.historyPush }; _this.eventTracking = EventTracking.api && EventTracking.host && EventTracking.request ? new EventTracking() : undefined; _this.historyPush = _this.historyPush.bind(_this); return _this; } Framework.init = function (options) { Framework.config = assign({}, config, options.config); Framework.request = new Request(options.request); if (options.router && options.router.history) { Framework.history = options.router.history === 'browserHistory' ? browserHistory : hashHistory; } Framework.routes = router.init(options.router); if (options.wx) { Framework.wx = new WeiXin(options.wx); } init(options, Framework.request); }; Framework.prototype.historyPush = function (route) { if (this.eventTracking) { this.eventTracking.setRecordEventTracking(true); } EventTracking.isRecordEventTracking = true; Framework.history.push(route); }; Framework.history = hashHistory; Framework.config = config; Framework.global = new Global(); return Framework; }(React.Component)); export default Framework;