2022-08-19 13:39:28 +08:00
|
|
|
|
//本地仓库外部组件
|
|
|
|
|
|
|
|
|
|
|
|
// 存储组件列表
|
|
|
|
|
|
let components = [];
|
|
|
|
|
|
// 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册
|
|
|
|
|
|
const install = function (Vue) {
|
|
|
|
|
|
if (install.installed) return;
|
2022-10-24 11:58:47 +08:00
|
|
|
|
// 声明全局业务对象类
|
|
|
|
|
|
const models = require.context('./model', true, /\.js$/)
|
|
|
|
|
|
if (models) {
|
|
|
|
|
|
const model = {}
|
|
|
|
|
|
models.keys().map(e => {
|
|
|
|
|
|
model[e.replace(/\.[\/\\]([^\\\/]+)\.js$/, '$1')] = models(e).default
|
|
|
|
|
|
})
|
|
|
|
|
|
Vue.prototype.MODEL = model
|
|
|
|
|
|
}
|
2022-08-19 13:39:28 +08:00
|
|
|
|
// 遍历注册全局组件
|
|
|
|
|
|
let contexts = require.context('.', true, /[\\\/]Ai([^\\\/]+)\.vue$/);
|
|
|
|
|
|
if (contexts) {
|
|
|
|
|
|
contexts.keys().map((e) => {
|
|
|
|
|
|
components.push(contexts(e).default);
|
|
|
|
|
|
Vue.component(contexts(e).default.name, contexts(e).default);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 判断是否是直接引入文件
|
|
|
|
|
|
if (typeof window !== 'undefined' && window.Vue) {
|
|
|
|
|
|
install(window.Vue);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
|
// 导出的对象必须具有 install,才能被 Vue.use() 方法安装
|
|
|
|
|
|
install,
|
|
|
|
|
|
// 以下组件列表
|
|
|
|
|
|
...components
|
|
|
|
|
|
};
|