diff --git a/admin/src/router/article.js b/admin/src/router/article.js new file mode 100644 index 0000000..e517d02 --- /dev/null +++ b/admin/src/router/article.js @@ -0,0 +1,12 @@ +export default [ + { + path: '/article', + name: '/article', + component: () => import('../components/artice/main'), + }, + { + path: '/article/add', + name: '/article/add', + component: () => import('../components/artice/add'), + } +]; diff --git a/admin/src/router/home.js b/admin/src/router/home.js new file mode 100644 index 0000000..f6d370b --- /dev/null +++ b/admin/src/router/home.js @@ -0,0 +1,7 @@ +export default [ + { + path: '/', + name: 'home', + component: () => import('../components/home'), + }, +]; diff --git a/admin/src/router/index.js b/admin/src/router/index.js index 2515ca9..f849a19 100644 --- a/admin/src/router/index.js +++ b/admin/src/router/index.js @@ -1,21 +1,20 @@ -export default new VueRouter({ - // mode: 'history', - base: `${process.env.VUE_APP_ADMIN_BASE_URL}`, - routes: [ - { - path: '/', - name: 'home', - component: () => import('../components/home'), - }, - { - path: '/article', - name: '/article', - component: () => import('../components/artice/main'), - }, - { - path: '/article/add', - name: '/article/add', - component: () => import('../components/artice/add'), +import article from "./article"; +import home from "./home"; + +const routes = (() => { + let routes = []; + [ + home, + article + ].forEach(item => { + if (Array.isArray(item)) { + routes = routes.concat(item); } - ] + }); + return routes; +})(); + +export default new VueRouter({ + base: `${process.env.VUE_APP_ADMIN_BASE_URL}`, + routes: routes });