UNPKG

1.21 kBJavaScriptView Raw
1import { config as appLoaderConfig, AppLoader } from 'edf-app-loader'
2import cf from './componentFactory'
3
4
5var toast, notification, modal, errorBox, apps, popconfirm, alert
6
7function config(option) {
8 const components = option.components
9
10 toast = option.toast
11 notification = option.notification
12 modal = option.modal
13 errorBox = option.errorBox
14 apps = option.apps
15 popconfirm = option.popconfirm
16 alert = option.alert
17
18 appLoaderConfig(option)
19
20 cf.registerComponent('AppLoader', AppLoader)
21
22 if (components && components.length > 0) {
23 components.forEach(c => {
24 if (c.appName)
25 cf.registerAppComponent(c.appName, c.name, c.component)
26
27 else
28 cf.registerComponent(c.name, c.component)
29 })
30 }
31
32 if (apps) {
33 Object.keys(apps).forEach(k => {
34 let a = apps[k]
35 if (a.components && a.components.length > 0) {
36 a.components.forEach(c => {
37 cf.registerAppComponent(a.name, c.name, c.component)
38 })
39 }
40 })
41 }
42}
43
44config.getToast = () => toast
45config.getNotification = () => notification
46config.getModal = () => modal
47config.getApps = () => apps
48config.getPopconfirm = () => popconfirm
49config.getAlert = () => alert
50
51export default config
\No newline at end of file