From 7940cffc3cf9bac8eeb4ba0dcbf2c68fdf70b1a8 Mon Sep 17 00:00:00 2001 From: aixianling Date: Wed, 9 Mar 2022 11:58:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=A7=E5=93=81=E5=BA=93=E5=8D=87=E7=BA=A7,?= =?UTF-8?q?=E4=B8=8D=E7=94=A8=E5=86=8D=E6=94=B9=E5=8A=A0=E8=BD=BD=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/entries.js | 22 ---------------------- examples/main.js | 8 +++----- examples/router/autoRoutes.js | 17 ++++++++++------- examples/views/apps/appEntry.vue | 6 +++++- package.json | 2 +- 5 files changed, 19 insertions(+), 36 deletions(-) delete mode 100644 examples/entries.js diff --git a/examples/entries.js b/examples/entries.js deleted file mode 100644 index 3d7290b4..00000000 --- a/examples/entries.js +++ /dev/null @@ -1,22 +0,0 @@ -//引入当前工程所有的应用 -const install = function(Vue) { - if (install.installed) return Promise.resolve(); - else { - let contexts = require.context('../packages', true, /(\/.+)\/App[^\/]+\.vue$/); - if (contexts) { - contexts.keys().map((e) => { - if (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 -}; diff --git a/examples/main.js b/examples/main.js index 5640e853..de8ecf47 100644 --- a/examples/main.js +++ b/examples/main.js @@ -2,7 +2,6 @@ import Vue from 'vue'; import App from './App.vue'; import ui from 'element-ui'; import router from './router/router'; -import apps from './entries'; import axios from './router/axios'; import utils from './utils'; import vcUI from 'dvcp-ui'; @@ -14,7 +13,6 @@ import dataV from '@jiaminghi/data-view'; Vue.use(dataV); -Vue.use(apps); Vue.use(ui); Vue.use(vcUI); Vue.use(dvUI); @@ -25,7 +23,7 @@ Vue.prototype.formatContent = (val) => val.replace(/(\r\n)|(\n)/g, '
'); Object.keys(utils).map((e) => (Vue.prototype[e] = utils[e])); utils.$store.init(store); new Vue({ - router, - store, - render: (h) => h(App) + router, + store, + render: (h) => h(App) }).$mount('#app'); diff --git a/examples/router/autoRoutes.js b/examples/router/autoRoutes.js index 2d75b50c..009c2e02 100644 --- a/examples/router/autoRoutes.js +++ b/examples/router/autoRoutes.js @@ -21,8 +21,9 @@ export default { let {name, label} = files(path).default, addApp = { name, label: label || name, - path: path.replace(/\.(\/.+\/App.+)\.vue$/, '$1'), - entry: 'appEntry' + path: path.replace(/\.(\/.+\/App.+)\.vue$/, '/packages$1'), + entry: 'appEntry', + module: files(path).default } //命名规范入口文件必须以App开头 store.commit("addApp", addApp) @@ -34,8 +35,9 @@ export default { let {name, label} = cores(path).default, addApp = { name, label: label || name, - path: path.replace(/\.(\/.+\/App.+)\.vue$/, '$1'), - entry: 'appEntry' + path: path.replace(/\.(\/.+\/App.+)\.vue$/, '/core$1'), + entry: 'appEntry', + module: cores(path).default } //命名规范入口文件必须以App开头 store.commit("addApp", addApp) @@ -46,9 +48,10 @@ export default { if (project(path).default) { let {name, label} = project(path).default, addApp = { - name, label: label || name, - path: path.replace(/\.(\/.+\/App.+)\.vue$/, '$1'), - entry: 'appEntry' + name: [path.replace(/\.\/([^\/]+)\/.*/, '$1'), name].join("_"), label: label || name, + path: path.replace(/\.(\/.+\/App.+)\.vue$/, '/project$1'), + entry: 'appEntry', + module: project(path).default } //命名规范入口文件必须以App开头 store.commit("addApp", addApp) diff --git a/examples/views/apps/appEntry.vue b/examples/views/apps/appEntry.vue index 81d1ca38..542235cf 100644 --- a/examples/views/apps/appEntry.vue +++ b/examples/views/apps/appEntry.vue @@ -7,12 +7,16 @@