ttk-app-core
Version:
@ttk/recat enterprise develop framework
33 lines (28 loc) • 1.09 kB
JavaScript
import { config as metaConfig, componentFactory } from '@ttk/meta-engine'
import config from './config'
import * as CustomComponent from '../components'
import { declareDepartcatted } from './departcated'
const init = (option) => {
declareDepartcatted()
const newConfig = config(option);
metaConfig(newConfig);
// 项目自定义组件
Object.entries(CustomComponent).forEach(([name, component]) => {
componentFactory.registerComponent(name, component)
})
return newConfig;
}
let apps = {}
// 搜索加载所有app
const files = require.context('./', true, /\.\/.+\/index\.js$/)
// 搜索加载指定目录(模块)下app, 如搜索edf和gl目录所有app
// const files = require.context('./', true, /\.\/(edf|gl)\/.+\/index\.js$/)
files.keys().forEach((path, index) => {
const value = files(path)
if (!value.default || !value.default.name) {
console.warn(`app必须要有name属性: ${path} ,若该文件确非app,请忽略`)
return false
}
apps[value.default.name] = value.default
}, {})
export { apps, init }