Commit 3b4d2c11 by 姜雷

修改处理路由方式并添加处理方法

parent 2ea0ddae
...@@ -36,7 +36,6 @@ class SystemShell { ...@@ -36,7 +36,6 @@ class SystemShell {
extendCom(Vue); extendCom(Vue);
configRoutePermission(router, store, routers); configRoutePermission(router, store, routers);
Vue.config.productionTip = false; Vue.config.productionTip = false;
console.log(router);
let app = new Vue({ let app = new Vue({
el: '#app', el: '#app',
...@@ -46,16 +45,9 @@ class SystemShell { ...@@ -46,16 +45,9 @@ class SystemShell {
let routes = [...constantRouterMap]; let routes = [...constantRouterMap];
let allRoute = store.getters.asyncRoutes; let allRoute = store.getters.asyncRoutes;
if (typeof routeFilter === 'function') { if (typeof routeFilter === 'function') {
allRoute = routeFilter(allRoute); const data = routeFilter(routes, allRoute);
} routes = data.routes;
if (allRoute && allRoute.length) { allRoute = data.allRoute;
let addRoute = formatRouteLink(allRoute);
for (let index = 0; index < addRoute.length; index++) {
const element = addRoute[index];
if (element.children) {
routes = routes.concat(element.children);
}
}
} }
return <App route={routes} allRoutes={allRoute} />; return <App route={routes} allRoutes={allRoute} />;
}, },
......
import * as main from '../utils/index'; import * as main from '../utils/index';
import * as auth from '../utils/auth'; import * as auth from '../utils/auth';
import * as route from '../utils/route';
import downloadUrl from '../utils/download'; import downloadUrl from '../utils/download';
import { getYourIP } from '../utils/getIp'; import { getYourIP } from '../utils/getIp';
import * as validate from '../utils/validate'; import * as validate from '../utils/validate';
...@@ -7,6 +8,7 @@ import * as validate from '../utils/validate'; ...@@ -7,6 +8,7 @@ import * as validate from '../utils/validate';
export default { export default {
...main, ...main,
auth, auth,
route,
downloadFiles: downloadUrl, downloadFiles: downloadUrl,
getIp: getYourIP, getIp: getYourIP,
validate, validate,
......
import System from './lib/main'; import System from './lib/main';
console.log(System);
let allAasyncRouterMap = [ let allAasyncRouterMap = [
...customerManage.default, ...customerManage.default,
...baseManage.default, ...baseManage.default,
...@@ -11,4 +9,19 @@ let allAasyncRouterMap = [ ...@@ -11,4 +9,19 @@ let allAasyncRouterMap = [
System.createSystem({ System.createSystem({
basePath: process.env.VUE_APP_BASE_URL, basePath: process.env.VUE_APP_BASE_URL,
routers: allAasyncRouterMap, 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);
}
}
}
return {
allRoute,
routes,
};
},
}); });
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