UNPKG

ttk-app-core

Version:
56 lines (48 loc) 1.66 kB
import React from 'react'; import { action as MetaAction, AppLoader } from 'edf-meta-engine'; import extend from './extend'; import config from './config'; class action { constructor(option) { this.metaAction = option.metaAction; this.extendAction = option.extendAction; this.config = config.current; this.webapi = this.config.webapi; } onInit = ({ component, injections }) => { this.extendAction.gridAction.onInit({ component, injections }); this.component = component; this.injections = injections; this.url = this.component.props.url injections.reduce('init'); // console.log('参数',this.component.props) // window.addEventListener('message', function(event) { // // // IMPORTANT: Check the origin of the data! // if (~event.origin.indexOf(this.url)) { // // The data has been sent from your site // // // The data sent with postMessage is stored in event.data // console.log('数据线',event.data); // } else { // // The data hasn't been sent from your site! // // Be careful! Do not use it. // return; // } // }); // this.load() }; load = () => { let frame = document.getElementById('your-frame-id'); frame && frame.contentWindow.postMessage(this.url, '*'); } urlRes = () => this.url } export default function creator(option) { const metaAction = new MetaAction(option), extendAction = extend.actionCreator({ ...option, metaAction }), o = new action({ ...option, metaAction, extendAction }), ret = { ...metaAction, ...extendAction.gridAction, ...o }; metaAction.config({ metaHandlers: ret }); return ret; }