Files
2022-07-07 22:16:39 +08:00

22 lines
609 B
JavaScript

/**
* 通用组件
* 加载components文件夹下的函数
*/
const config = require("./config")
module.exports = async (app) => {
const list = await app.load(config.path)
Object.assign(list, await app.load(config.app_path))
app.components = {}
list.forEach(item => {
if (!app.components[item.parse.file_father]) {
app.components[item.parse.file_father] = {}
}
if (item.parse.name==='index') {
Object.assign(app.components[item.parse.file_father],item.res)
}else {
app.components[item.parse.file_father][item.parse.name] = item.res
}
})
app.alias["$components"] = app.components
}