|
|
|
@ -2,14 +2,10 @@ import store from '@/store' |
|
|
|
|
import router from '@/router' |
|
|
|
|
import generateBtnPermission from '../auth/generateBtnPermission' |
|
|
|
|
|
|
|
|
|
const infoSidebar = ['information','content'] |
|
|
|
|
const matchSidebar = ['matchintro','matchprogress','matchsignup'] |
|
|
|
|
const newRoutes = [] |
|
|
|
|
|
|
|
|
|
function createMeta(item){ |
|
|
|
|
let meta = { title: item.name } |
|
|
|
|
infoSidebar.includes(item.component) && (meta.sidebar = 'info') |
|
|
|
|
matchSidebar.includes(item.component) && (meta.sidebar = 'match') |
|
|
|
|
return meta |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -20,7 +16,7 @@ function createRoute(data){ |
|
|
|
|
newRoutes.push({ |
|
|
|
|
name: e.component, |
|
|
|
|
path: e.component, |
|
|
|
|
component: () => import(`@/pages/${e.component}.vue`), |
|
|
|
|
component: () => import(`@/pages${e.component}`), |
|
|
|
|
meta |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
@ -31,11 +27,11 @@ function createRoute(data){ |
|
|
|
|
export default function(data,path){ |
|
|
|
|
generateBtnPermission(data) |
|
|
|
|
createRoute(data) |
|
|
|
|
let routes = router.options.routes |
|
|
|
|
routes[1].children = [...routes[1].children,...newRoutes] |
|
|
|
|
store.auth.commit("addRoutes", { routes }) |
|
|
|
|
router.addRoutes(routes) |
|
|
|
|
// let routes = router.options.routes
|
|
|
|
|
// routes[1].children = [...routes[1].children,...newRoutes]
|
|
|
|
|
store.dispatch('auth/addRoutes',newRoutes) |
|
|
|
|
// router.addRoutes(routes)
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
!newRoutes.find(n => n.name == 'dashboard') && router.push(newRoutes[0].path) |
|
|
|
|
!newRoutes.find(n => n.name == '/index/list') && router.push(newRoutes[0].path) |
|
|
|
|
},10) |
|
|
|
|
} |