|
@@ -1,10 +1,10 @@
|
|
|
-import Vue from 'vue'
|
|
|
-import Router from 'vue-router'
|
|
|
+import Vue from 'vue';
|
|
|
+import Router from 'vue-router';
|
|
|
|
|
|
-Vue.use(Router)
|
|
|
+Vue.use(Router);
|
|
|
|
|
|
/* Layout */
|
|
|
-import Layout from '@/layout'
|
|
|
+import Layout from '@/layout';
|
|
|
|
|
|
/**
|
|
|
* Note: sub-menu only appear when route children.length >= 1
|
|
@@ -47,12 +47,17 @@ export const constantRoutes = [
|
|
|
path: '/',
|
|
|
component: Layout,
|
|
|
redirect: '/dashboard',
|
|
|
- children: [{
|
|
|
- path: 'dashboard',
|
|
|
- name: 'Dashboard',
|
|
|
- component: () => import('@/views/dashboard/index'),
|
|
|
- meta: { title: 'Dashboard', icon: 'dashboard' }
|
|
|
- }]
|
|
|
+ children: [
|
|
|
+ {
|
|
|
+ path: 'dashboard',
|
|
|
+ name: 'Dashboard',
|
|
|
+ component: () => import('@/views/dashboard/index'),
|
|
|
+ meta: {
|
|
|
+ title: 'Dashboard',
|
|
|
+ icon: 'dashboard'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
},
|
|
|
|
|
|
{
|
|
@@ -60,19 +65,28 @@ export const constantRoutes = [
|
|
|
component: Layout,
|
|
|
redirect: '/example/table',
|
|
|
name: 'Example',
|
|
|
- meta: { title: 'Example', icon: 'el-icon-s-help' },
|
|
|
+ meta: {
|
|
|
+ title: 'Example',
|
|
|
+ icon: 'el-icon-s-help'
|
|
|
+ },
|
|
|
children: [
|
|
|
{
|
|
|
path: 'table',
|
|
|
name: 'Table',
|
|
|
component: () => import('@/views/table/index'),
|
|
|
- meta: { title: 'Table', icon: 'table' }
|
|
|
+ meta: {
|
|
|
+ title: 'Table',
|
|
|
+ icon: 'table'
|
|
|
+ }
|
|
|
},
|
|
|
{
|
|
|
path: 'tree',
|
|
|
name: 'Tree',
|
|
|
component: () => import('@/views/tree/index'),
|
|
|
- meta: { title: 'Tree', icon: 'tree' }
|
|
|
+ meta: {
|
|
|
+ title: 'Tree',
|
|
|
+ icon: 'tree'
|
|
|
+ }
|
|
|
}
|
|
|
]
|
|
|
},
|
|
@@ -85,11 +99,27 @@ export const constantRoutes = [
|
|
|
path: 'index',
|
|
|
name: 'Form',
|
|
|
component: () => import('@/views/form/index'),
|
|
|
- meta: { title: 'Form', icon: 'form' }
|
|
|
+ meta: {
|
|
|
+ title: 'Form',
|
|
|
+ icon: 'form'
|
|
|
+ }
|
|
|
}
|
|
|
]
|
|
|
},
|
|
|
|
|
|
+ // 404 page must be placed at the end !!!
|
|
|
+ {
|
|
|
+ path: '*',
|
|
|
+ redirect: '/404',
|
|
|
+ hidden: true
|
|
|
+ }
|
|
|
+];
|
|
|
+
|
|
|
+/**
|
|
|
+ * asyncRoutes
|
|
|
+ * the routes that need to be dynamically loaded based on user roles
|
|
|
+ */
|
|
|
+export const asyncRoutes = [
|
|
|
{
|
|
|
path: '/nested',
|
|
|
component: Layout,
|
|
@@ -104,31 +134,43 @@ export const constantRoutes = [
|
|
|
path: 'menu1',
|
|
|
component: () => import('@/views/nested/menu1/index'), // Parent router-view
|
|
|
name: 'Menu1',
|
|
|
- meta: { title: 'Menu1' },
|
|
|
+ meta: {
|
|
|
+ title: 'Menu1'
|
|
|
+ },
|
|
|
children: [
|
|
|
{
|
|
|
path: 'menu1-1',
|
|
|
component: () => import('@/views/nested/menu1/menu1-1'),
|
|
|
name: 'Menu1-1',
|
|
|
- meta: { title: 'Menu1-1' }
|
|
|
+ meta: {
|
|
|
+ title: 'Menu1-1'
|
|
|
+ }
|
|
|
},
|
|
|
{
|
|
|
path: 'menu1-2',
|
|
|
component: () => import('@/views/nested/menu1/menu1-2'),
|
|
|
name: 'Menu1-2',
|
|
|
- meta: { title: 'Menu1-2' },
|
|
|
+ meta: {
|
|
|
+ title: 'Menu1-2'
|
|
|
+ },
|
|
|
children: [
|
|
|
{
|
|
|
path: 'menu1-2-1',
|
|
|
- component: () => import('@/views/nested/menu1/menu1-2/menu1-2-1'),
|
|
|
+ component: () =>
|
|
|
+ import('@/views/nested/menu1/menu1-2/menu1-2-1'),
|
|
|
name: 'Menu1-2-1',
|
|
|
- meta: { title: 'Menu1-2-1' }
|
|
|
+ meta: {
|
|
|
+ title: 'Menu1-2-1'
|
|
|
+ }
|
|
|
},
|
|
|
{
|
|
|
path: 'menu1-2-2',
|
|
|
- component: () => import('@/views/nested/menu1/menu1-2/menu1-2-2'),
|
|
|
+ component: () =>
|
|
|
+ import('@/views/nested/menu1/menu1-2/menu1-2-2'),
|
|
|
name: 'Menu1-2-2',
|
|
|
- meta: { title: 'Menu1-2-2' }
|
|
|
+ meta: {
|
|
|
+ title: 'Menu1-2-2'
|
|
|
+ }
|
|
|
}
|
|
|
]
|
|
|
},
|
|
@@ -136,7 +178,9 @@ export const constantRoutes = [
|
|
|
path: 'menu1-3',
|
|
|
component: () => import('@/views/nested/menu1/menu1-3'),
|
|
|
name: 'Menu1-3',
|
|
|
- meta: { title: 'Menu1-3' }
|
|
|
+ meta: {
|
|
|
+ title: 'Menu1-3'
|
|
|
+ }
|
|
|
}
|
|
|
]
|
|
|
},
|
|
@@ -144,7 +188,9 @@ export const constantRoutes = [
|
|
|
path: 'menu2',
|
|
|
component: () => import('@/views/nested/menu2/index'),
|
|
|
name: 'Menu2',
|
|
|
- meta: { title: 'menu2' }
|
|
|
+ meta: {
|
|
|
+ title: 'menu2'
|
|
|
+ }
|
|
|
}
|
|
|
]
|
|
|
},
|
|
@@ -155,27 +201,30 @@ export const constantRoutes = [
|
|
|
children: [
|
|
|
{
|
|
|
path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
|
|
|
- meta: { title: 'External Link', icon: 'link' }
|
|
|
+ meta: {
|
|
|
+ title: 'External Link',
|
|
|
+ icon: 'link'
|
|
|
+ }
|
|
|
}
|
|
|
]
|
|
|
- },
|
|
|
-
|
|
|
- // 404 page must be placed at the end !!!
|
|
|
- { path: '*', redirect: '/404', hidden: true }
|
|
|
-]
|
|
|
+ }
|
|
|
+];
|
|
|
|
|
|
-const createRouter = () => new Router({
|
|
|
- // mode: 'history', // require service support
|
|
|
- scrollBehavior: () => ({ y: 0 }),
|
|
|
- routes: constantRoutes
|
|
|
-})
|
|
|
+const createRouter = () =>
|
|
|
+ new Router({
|
|
|
+ // mode: 'history', // require service support
|
|
|
+ scrollBehavior: () => ({
|
|
|
+ y: 0
|
|
|
+ }),
|
|
|
+ routes: constantRoutes
|
|
|
+ });
|
|
|
|
|
|
-const router = createRouter()
|
|
|
+const router = createRouter();
|
|
|
|
|
|
// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
|
|
|
export function resetRouter() {
|
|
|
- const newRouter = createRouter()
|
|
|
- router.matcher = newRouter.matcher // reset router
|
|
|
+ const newRouter = createRouter();
|
|
|
+ router.matcher = newRouter.matcher; // reset router
|
|
|
}
|
|
|
|
|
|
-export default router
|
|
|
+export default router;
|