2021-11-19 10:39:30 +08:00
|
|
|
|
const install = function (Vue) {
|
2021-11-19 10:33:29 +08:00
|
|
|
|
if (install.installed) return
|
|
|
|
|
|
// 遍历注册全局组件
|
|
|
|
|
|
let apps = []
|
|
|
|
|
|
let contexts = require.context('.', true, /\.(\/.+)\/App[^\/]+\.vue$/)
|
|
|
|
|
|
if (contexts) {
|
|
|
|
|
|
contexts.keys().map(e => {
|
|
|
|
|
|
if (contexts(e).default) {
|
2021-11-19 10:39:30 +08:00
|
|
|
|
apps.push(contexts(e).default)
|
|
|
|
|
|
Vue.component(contexts(e).default.name, contexts(e).default)
|
2021-11-19 10:33:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
return Promise.resolve(apps)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 判断是否是直接引入文件
|
|
|
|
|
|
if (typeof window !== 'undefined' && window.Vue) {
|
|
|
|
|
|
install(window.Vue)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
|
// 导出的对象必须具有 install,才能被 Vue.use() 方法安装
|
|
|
|
|
|
install
|
|
|
|
|
|
}
|