forked from ziaochina/mk-app-devtools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.js
57 lines (44 loc) · 1.21 KB
/
action.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import React from 'react'
import { action as MetaAction, AppLoader } from 'mk-meta-engine'
import config from './config'
import utils from 'mk-utils'
class action {
constructor(option) {
this.metaAction = option.metaAction
this.config = config.current
}
onInit = ({ component, injections }) => {
console.log('init')
this.component = component
this.injections = injections
injections.reduce('init')
}
getApps = () => {
const keys = Object.keys(this.config.apps)
var ret = {}
keys.forEach(k=>{
if(k != 'config')
ret[k] = this.config.apps[k]
})
return ret
}
tabChange = (key) =>{
this.metaAction.sf('data.tabKey', key)
}
getState = () =>{
return window.reduxStore.getState().toJS()
}
getMockData = () => {
return utils.fetch.mockData
}
getAPIs = () => {
return utils.fetch.mockApi
}
}
export default function creator(option) {
const metaAction = new MetaAction(option),
o = new action({ ...option, metaAction }),
ret = { ...metaAction, ...o }
metaAction.config({ metaHandlers: ret })
return ret
}