Commit 111e5cb6 by 姜雷

改造打包方式

parent d139cc6c
......@@ -35,6 +35,7 @@
"popmotion": "^8.1.22",
"qiniu-js": "^2.2.0",
"rym-element-ui": "^0.1.63",
"systemjs": "^4.0.0",
"vue-qr": "^1.2.8",
"vuedraggable": "^2.16.0",
"wangeditor": "^3.1.1"
......
......@@ -9,6 +9,7 @@
<meta http-equiv="Expires" content="0" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link rel="icon" href="<%= BASE_URL %>ic_logo.ico" />
<script src="<%= BASE_URL %>system.js"></script>
<script src="https://unpkg.com/vue@2.6.10/dist/vue.js"></script>
<script src="https://unpkg.com/vuex@3.1.0/dist/vuex.js"></script>
<script src="https://unpkg.com/vue-router@3.0.1/dist/vue-router.js"></script>
......@@ -24,21 +25,6 @@
<div id="app"></div>
<script src="https://webapi.amap.com/maps?v=1.4.12&key=dd6103c90f2f17310a8711f2d330a0a6"></script>
<script src="https://webapi.amap.com/ui/1.0/main.js?v=1.0.11"></script>
<script src="<%= VUE_APP_DEV_LIB_URL %>/lib/manageShell.umd.min.js?<%= VUE_APP_SYSTEM_VERSION %>"></script>
<script
src="<%= VUE_APP_SUBSYSTEM %>/customerManage/lib/customerManage.umd.min.js?<%= VUE_APP_SYSTEM_VERSION %>"></script>
<script src="<%= VUE_APP_SUBSYSTEM %>/baseManage/lib/baseManage.umd.min.js?<%= VUE_APP_SYSTEM_VERSION %>"></script>
<script
src="<%= VUE_APP_SUBSYSTEM %>/systemManage/lib/systemManage.umd.min.js?<%= VUE_APP_SYSTEM_VERSION %>"></script>
<script
src="<%= VUE_APP_SUBSYSTEM %>/operateManage/lib/operateManage.umd.min.js?<%= VUE_APP_SYSTEM_VERSION %>"></script>
<script
src="<%= VUE_APP_SUBSYSTEM %>/statisticsManage/lib/statisticsManage.umd.min.js?<%= VUE_APP_SYSTEM_VERSION %>"></script>
<script
src="<%= VUE_APP_SUBSYSTEM %>/deviceManage/lib/deviceManage.umd.min.js?<%= VUE_APP_SYSTEM_VERSION %>"></script>
<script
src="<%= VUE_APP_SUBSYSTEM %>/smaproManage/lib/smaproManage.umd.min.js?<%= VUE_APP_SYSTEM_VERSION %>"></script>
<!-- built files will be auto injected -->
</body>
......
......@@ -9,6 +9,7 @@
<meta http-equiv="Expires" content="0" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link rel="icon" href="<%= BASE_URL %>ic_logo.ico" />
<script src="<%= BASE_URL %>system.js"></script>
<script src="https://unpkg.com/vue@2.6.10/dist/vue.js"></script>
<script src="https://unpkg.com/vuex@3.1.0/dist/vuex.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue-router@3.0.1/dist/vue-router.js"></script>
......@@ -23,14 +24,6 @@
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
<script src="<%= VUE_APP_SUBSYSTEM %>/customerManage/lib/customerManage.umd.min.js"></script>
<script src="<%= VUE_APP_SUBSYSTEM %>/baseManage/lib/baseManage.umd.min.js"></script>
<script src="<%= VUE_APP_SUBSYSTEM %>/systemManage/lib/systemManage.umd.min.js"></script>
<script src="<%= VUE_APP_SUBSYSTEM %>/operateManage/lib/operateManage.umd.min.js"></script>
<script src="<%= VUE_APP_SUBSYSTEM %>/statisticsManage/lib/statisticsManage.umd.min.js"></script>
<script src="<%= VUE_APP_SUBSYSTEM %>/deviceManage/lib/deviceManage.umd.min.js"></script>
<script src="<%= VUE_APP_SUBSYSTEM %>/smaproManage/lib/smaproManage.umd.min.js"></script>
<script src="https://webapi.amap.com/maps?v=1.4.12&key=dd6103c90f2f17310a8711f2d330a0a6"></script>
<script src="https://webapi.amap.com/ui/1.0/main.js?v=1.0.11"></script>
<script src="https://unpkg.com/@antv/data-set"></script>
......
import System from '../lib/main';
import CreatSystem from '../lib/main';
import asyncRouterMap from '../router/asyncRoutes';
window.manageShell = { default: System };
window.manageShell = { default: CreatSystem };
window.allAasyncRouterMap = [...asyncRouterMap];
setTimeout(() => {
let allAasyncRouterMap = [...asyncRouterMap];
let routeNameList = [
let constantRouter = [
{
path: '/asd',
name: 'asd',
component: {
render(h) {
return <div>asdasdasd</div>;
},
},
},
];
const routeFilter = (routes, allRoute) => {
if (allRoute && allRoute.length) {
let addRoute = manageShell.default.utils.route.formatRouteLink(allRoute);
for (let index = 0; index < addRoute.length; index++) {
const element = addRoute[index];
if (element.children) {
routes = routes.concat(element.children);
} else if (
element.menuCode === process.env.VUE_APP_REGISTER_DASHBOARD_CODE
) {
routes.unshift(element);
}
}
}
return {
allRoute,
routes,
};
};
const script = document.createElement('script');
script.text = `
var routeNameList = [
'customerManage',
'baseManage',
'systemManage',
......@@ -14,48 +45,20 @@ setTimeout(() => {
'deviceManage',
'smaproManage',
];
routeNameList.map(name => {
try {
allAasyncRouterMap = allAasyncRouterMap.concat(window[name].default);
} catch (error) {
console.error(name + ': ', error);
Promise.all(routeNameList.map(name => System.import('${
process.env.VUE_APP_SUBSYSTEM
}/' + name + '/lib/' + name + '.umd.min.js?t=${new Date().getTime()}'))).then(res => {
for (let index = 0; index < res.length; index++) {
const element = res[index];
allAasyncRouterMap = allAasyncRouterMap.concat(element.default.default);
}
return name;
});
System.createSystem({
basePath: process.env.VUE_APP_BASE_URL,
routers: allAasyncRouterMap,
constantRouter: [
{
path: '/asd',
name: 'asd',
component: {
render(h) {
return <div>asdasdasd</div>;
},
},
},
],
whiteList: '/asd',
routeFilter: (routes, allRoute) => {
if (allRoute && allRoute.length) {
let addRoute = System.utils.route.formatRouteLink(allRoute);
for (let index = 0; index < addRoute.length; index++) {
const element = addRoute[index];
if (element.children) {
routes = routes.concat(element.children);
} else if (
element.menuCode === process.env.VUE_APP_REGISTER_DASHBOARD_CODE
) {
routes.unshift(element);
}
}
}
return {
allRoute,
routes,
};
},
});
}, 1000);
manageShell.default.createSystem({
basePath: '${process.env.VUE_APP_BASE_URL}',
routers: allAasyncRouterMap,
constantRouter: ${JSON.stringify(constantRouter)},
whiteList: '/asd',
routeFilter: ${routeFilter.toString()},
})
})
`;
document.body.appendChild(script);
import asyncRouterMap from './router/asyncRoutes';
let allAasyncRouterMap = [...asyncRouterMap];
let routeNameList = [
'customerManage',
'baseManage',
'systemManage',
'operateManage',
'statisticsManage',
'deviceManage',
'smaproManage',
];
routeNameList.map(name => {
try {
allAasyncRouterMap = allAasyncRouterMap.concat(window[name].default);
} catch (error) {
console.error(name + ': ', error);
}
return name;
});
const System = manageShell.default;
window.allAasyncRouterMap = [...asyncRouterMap];
export default System.createSystem({
basePath: process.env.VUE_APP_BASE_URL,
routers: allAasyncRouterMap,
routeFilter: (routes, allRoute) => {
if (allRoute && allRoute.length) {
let addRoute = System.utils.route.formatRouteLink(allRoute);
for (let index = 0; index < addRoute.length; index++) {
const element = addRoute[index];
if (element.children) {
routes = routes.concat(element.children);
} else if (
element.menuCode === process.env.VUE_APP_REGISTER_DASHBOARD_CODE
) {
routes.unshift(element);
}
const routeFilter = (routes, allRoute) => {
if (allRoute && allRoute.length) {
let addRoute = System.utils.route.formatRouteLink(allRoute);
for (let index = 0; index < addRoute.length; index++) {
const element = addRoute[index];
if (element.children) {
routes = routes.concat(element.children);
} else if (
element.menuCode === process.env.VUE_APP_REGISTER_DASHBOARD_CODE
) {
routes.unshift(element);
}
}
return {
allRoute,
routes,
};
},
});
}
return {
allRoute,
routes,
};
};
const script = document.createElement('script');
script.text = `
var routeNameList = [
'customerManage',
'baseManage',
'systemManage',
'operateManage',
'statisticsManage',
'deviceManage',
'smaproManage',
];
System.import(
'${process.env.VUE_APP_DEV_LIB_URL}/lib/manageShell.umd.min.js'
).then(function(module) {
var manageShell = module.default;
return Promise.all(
routeNameList.map(function(name) {
return System.import('${process.env.VUE_APP_SUBSYSTEM}/' + name + '/lib/' + name + '.umd.min.js?t=${new Date().getTime()}');
})
).then(function(res) {
for (let index = 0; index < res.length; index++) {
const element = res[index];
allAasyncRouterMap = allAasyncRouterMap.concat(element.default.default);
}
manageShell.default.createSystem({
basePath: '${process.env.VUE_APP_BASE_URL}',
routers: allAasyncRouterMap,
routeFilter: function(routes, allRoute) {
if (allRoute && allRoute.length) {
let addRoute = manageShell.default.utils.route.formatRouteLink(
allRoute
);
for (let index = 0; index < addRoute.length; index++) {
const element = addRoute[index];
if (element.children) {
routes = routes.concat(element.children);
} else if (
element.menuCode === ${
process.env.VUE_APP_REGISTER_DASHBOARD_CODE
}
) {
routes.unshift(element);
}
}
}
return {
allRoute,
routes,
};
},
});
});
});
`;
document.body.appendChild(script);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment