产品库升级,不用再改加载路径了
This commit is contained in:
@@ -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
|
|
||||||
};
|
|
||||||
@@ -2,7 +2,6 @@ import Vue from 'vue';
|
|||||||
import App from './App.vue';
|
import App from './App.vue';
|
||||||
import ui from 'element-ui';
|
import ui from 'element-ui';
|
||||||
import router from './router/router';
|
import router from './router/router';
|
||||||
import apps from './entries';
|
|
||||||
import axios from './router/axios';
|
import axios from './router/axios';
|
||||||
import utils from './utils';
|
import utils from './utils';
|
||||||
import vcUI from 'dvcp-ui';
|
import vcUI from 'dvcp-ui';
|
||||||
@@ -14,7 +13,6 @@ import dataV from '@jiaminghi/data-view';
|
|||||||
|
|
||||||
Vue.use(dataV);
|
Vue.use(dataV);
|
||||||
|
|
||||||
Vue.use(apps);
|
|
||||||
Vue.use(ui);
|
Vue.use(ui);
|
||||||
Vue.use(vcUI);
|
Vue.use(vcUI);
|
||||||
Vue.use(dvUI);
|
Vue.use(dvUI);
|
||||||
@@ -25,7 +23,7 @@ Vue.prototype.formatContent = (val) => val.replace(/(\r\n)|(\n)/g, '<br>');
|
|||||||
Object.keys(utils).map((e) => (Vue.prototype[e] = utils[e]));
|
Object.keys(utils).map((e) => (Vue.prototype[e] = utils[e]));
|
||||||
utils.$store.init(store);
|
utils.$store.init(store);
|
||||||
new Vue({
|
new Vue({
|
||||||
router,
|
router,
|
||||||
store,
|
store,
|
||||||
render: (h) => h(App)
|
render: (h) => h(App)
|
||||||
}).$mount('#app');
|
}).$mount('#app');
|
||||||
|
|||||||
@@ -21,8 +21,9 @@ export default {
|
|||||||
let {name, label} = files(path).default,
|
let {name, label} = files(path).default,
|
||||||
addApp = {
|
addApp = {
|
||||||
name, label: label || name,
|
name, label: label || name,
|
||||||
path: path.replace(/\.(\/.+\/App.+)\.vue$/, '$1'),
|
path: path.replace(/\.(\/.+\/App.+)\.vue$/, '/packages$1'),
|
||||||
entry: 'appEntry'
|
entry: 'appEntry',
|
||||||
|
module: files(path).default
|
||||||
}
|
}
|
||||||
//命名规范入口文件必须以App开头
|
//命名规范入口文件必须以App开头
|
||||||
store.commit("addApp", addApp)
|
store.commit("addApp", addApp)
|
||||||
@@ -34,8 +35,9 @@ export default {
|
|||||||
let {name, label} = cores(path).default,
|
let {name, label} = cores(path).default,
|
||||||
addApp = {
|
addApp = {
|
||||||
name, label: label || name,
|
name, label: label || name,
|
||||||
path: path.replace(/\.(\/.+\/App.+)\.vue$/, '$1'),
|
path: path.replace(/\.(\/.+\/App.+)\.vue$/, '/core$1'),
|
||||||
entry: 'appEntry'
|
entry: 'appEntry',
|
||||||
|
module: cores(path).default
|
||||||
}
|
}
|
||||||
//命名规范入口文件必须以App开头
|
//命名规范入口文件必须以App开头
|
||||||
store.commit("addApp", addApp)
|
store.commit("addApp", addApp)
|
||||||
@@ -46,9 +48,10 @@ export default {
|
|||||||
if (project(path).default) {
|
if (project(path).default) {
|
||||||
let {name, label} = project(path).default,
|
let {name, label} = project(path).default,
|
||||||
addApp = {
|
addApp = {
|
||||||
name, label: label || name,
|
name: [path.replace(/\.\/([^\/]+)\/.*/, '$1'), name].join("_"), label: label || name,
|
||||||
path: path.replace(/\.(\/.+\/App.+)\.vue$/, '$1'),
|
path: path.replace(/\.(\/.+\/App.+)\.vue$/, '/project$1'),
|
||||||
entry: 'appEntry'
|
entry: 'appEntry',
|
||||||
|
module: project(path).default
|
||||||
}
|
}
|
||||||
//命名规范入口文件必须以App开头
|
//命名规范入口文件必须以App开头
|
||||||
store.commit("addApp", addApp)
|
store.commit("addApp", addApp)
|
||||||
|
|||||||
@@ -7,12 +7,16 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
import {mapState} from "vuex";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "appEntry",
|
name: "appEntry",
|
||||||
label: "应用库-应用",
|
label: "应用库-应用",
|
||||||
computed: {
|
computed: {
|
||||||
|
...mapState(['apps']),
|
||||||
app() {
|
app() {
|
||||||
return this.$route.name
|
let app = this.apps.find(e => e.name == this.$route.name)
|
||||||
|
return app ? app.module : ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
"main": "lib/cw-webapps.common.js",
|
"main": "lib/cw-webapps.common.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"serve": "vue-cli-service serve",
|
"serve": "vue-cli-service serve",
|
||||||
"serve:oms": "npx cross-env NODE_ENV=oms vue-cli-service serve",
|
|
||||||
"build": "vue-cli-service build",
|
"build": "vue-cli-service build",
|
||||||
"lib": "vue-cli-service build --no-clean --target lib --dest lib packages/index.js&&npm unpublish --force&&npm publish",
|
"lib": "vue-cli-service build --no-clean --target lib --dest lib packages/index.js&&npm unpublish --force&&npm publish",
|
||||||
"lib:core": "vue-cli-service build --target lib --dest core/dist core/index.js --name vc-app-core&&npm unpublish --force&&npm publish",
|
"lib:core": "vue-cli-service build --target lib --dest core/dist core/index.js --name vc-app-core&&npm unpublish --force&&npm publish",
|
||||||
@@ -55,6 +54,7 @@
|
|||||||
"image-webpack-loader": "^6.0.0",
|
"image-webpack-loader": "^6.0.0",
|
||||||
"inquirer": "^6.5.2",
|
"inquirer": "^6.5.2",
|
||||||
"node-sass": "npm:sass@^1.43.4",
|
"node-sass": "npm:sass@^1.43.4",
|
||||||
|
"readline": "^1.3.0",
|
||||||
"sass-loader": "^7.1.0",
|
"sass-loader": "^7.1.0",
|
||||||
"uglifyjs-webpack-plugin": "^2.2.0",
|
"uglifyjs-webpack-plugin": "^2.2.0",
|
||||||
"v-viewer": "^1.6.4",
|
"v-viewer": "^1.6.4",
|
||||||
|
|||||||
Reference in New Issue
Block a user