From 4e1cf8a81450ce30945df52372e1faa6afed7028 Mon Sep 17 00:00:00 2001 From: aixianling Date: Mon, 15 Aug 2022 13:51:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/index.js | 42 ------------------------------------------ 1 file changed, 42 deletions(-) delete mode 100644 packages/index.js diff --git a/packages/index.js b/packages/index.js deleted file mode 100644 index 192f2098..00000000 --- a/packages/index.js +++ /dev/null @@ -1,42 +0,0 @@ -// 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册 -/** - * - * @param Vue 外部接入Vue - * @param params showList:打印加载的应用;apps:加载的应用文件名数组 - */ -import dvui from '../project/dvui/entries' - -const install = function (Vue, params) { - if (install.installed) return - // 遍历注册全局组件 - let apps = [] - let contexts = require.context('.', true, /\.(\/.+)\/App[^\/]+\.vue$/) - if (contexts) { - contexts.keys().map(e => { - if (contexts(e).default) { - if (params?.apps) { - if (params?.apps.includes(contexts(e).default.name)) { - apps.push(contexts(e).default) - Vue.component(contexts(e).default.name, contexts(e).default) - } - } else { - apps.push(contexts(e).default) - Vue.component(contexts(e).default.name, contexts(e).default) - } - } - }) - !!params?.showList && console.log(apps.map(e => e.name)) - } - Vue.use(dvui) - return Promise.resolve(apps) -} - -// 判断是否是直接引入文件 -if (typeof window !== 'undefined' && window.Vue) { - install(window.Vue) -} - -export default { - // 导出的对象必须具有 install,才能被 Vue.use() 方法安装 - install -}