|
@@ -55,139 +55,78 @@ export const constantRoutes = [
|
|
|
}]
|
|
|
},
|
|
|
|
|
|
- {
|
|
|
- path: '/system',
|
|
|
- component: Layout,
|
|
|
- redirect: '/system/menu',
|
|
|
- name: '系统管理',
|
|
|
- meta: {title: 'Example', icon: 'el-icon-s-help'},
|
|
|
- children: [
|
|
|
- {
|
|
|
- path: 'menu',
|
|
|
- name: '菜单管理',
|
|
|
- component: () => import('@/views/system/menu'),
|
|
|
- meta: {title: '菜单管理', icon: 'table'}
|
|
|
- },
|
|
|
- {
|
|
|
- path: 'dept',
|
|
|
- name: '部门管理',
|
|
|
- component: () => import('@/views/system/dept'),
|
|
|
- meta: {title: '部门管理', icon: 'tree'}
|
|
|
- },
|
|
|
- {
|
|
|
- path: 'role',
|
|
|
- name: '角色管理',
|
|
|
- component: () => import('@/views/system/role'),
|
|
|
- meta: {title: '角色管理', icon: 'tree'}
|
|
|
- },
|
|
|
- {
|
|
|
- path: 'user',
|
|
|
- name: '员工管理',
|
|
|
- component: () => import('@/views/system/user'),
|
|
|
- meta: {title: '员工管理', icon: 'tree'}
|
|
|
- }
|
|
|
- ]
|
|
|
- },
|
|
|
-
|
|
|
- {
|
|
|
- path: '/form',
|
|
|
- component: Layout,
|
|
|
- children: [
|
|
|
- {
|
|
|
- path: 'index',
|
|
|
- name: 'Form',
|
|
|
- component: () => import('@/views/form/index'),
|
|
|
- meta: {title: 'Form', icon: 'form'}
|
|
|
- }
|
|
|
- ]
|
|
|
- },
|
|
|
-
|
|
|
- {
|
|
|
- path: '/nested',
|
|
|
- component: Layout,
|
|
|
- redirect: '/nested/menu1',
|
|
|
- name: 'Nested',
|
|
|
- meta: {
|
|
|
- title: 'Nested',
|
|
|
- icon: 'nested'
|
|
|
- },
|
|
|
- children: [
|
|
|
- {
|
|
|
- path: 'menu1',
|
|
|
- component: () => import('@/views/nested/menu1/index'), // Parent router-view
|
|
|
- name: 'Menu1',
|
|
|
- meta: {title: 'Menu1'},
|
|
|
- children: [
|
|
|
- {
|
|
|
- path: 'menu1-1',
|
|
|
- component: () => import('@/views/nested/menu1/menu1-1'),
|
|
|
- name: 'Menu1-1',
|
|
|
- meta: {title: 'Menu1-1'}
|
|
|
- },
|
|
|
- {
|
|
|
- path: 'menu1-2',
|
|
|
- component: () => import('@/views/nested/menu1/menu1-2'),
|
|
|
- name: 'Menu1-2',
|
|
|
- meta: {title: 'Menu1-2'},
|
|
|
- children: [
|
|
|
- {
|
|
|
- path: 'menu1-2-1',
|
|
|
- component: () => import('@/views/nested/menu1/menu1-2/menu1-2-1'),
|
|
|
- name: 'Menu1-2-1',
|
|
|
- meta: {title: 'Menu1-2-1'}
|
|
|
- },
|
|
|
- {
|
|
|
- path: 'menu1-2-2',
|
|
|
- component: () => import('@/views/nested/menu1/menu1-2/menu1-2-2'),
|
|
|
- name: 'Menu1-2-2',
|
|
|
- meta: {title: 'Menu1-2-2'}
|
|
|
- }
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- path: 'menu1-3',
|
|
|
- component: () => import('@/views/nested/menu1/menu1-3'),
|
|
|
- name: 'Menu1-3',
|
|
|
- meta: {title: 'Menu1-3'}
|
|
|
- }
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- path: 'menu2',
|
|
|
- component: () => import('@/views/nested/menu2/index'),
|
|
|
- name: 'Menu2',
|
|
|
- meta: {title: 'menu2'}
|
|
|
- }
|
|
|
- ]
|
|
|
- },
|
|
|
-
|
|
|
- {
|
|
|
- path: 'external-link',
|
|
|
- component: Layout,
|
|
|
- children: [
|
|
|
- {
|
|
|
- path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
|
|
|
- meta: {title: 'External Link', icon: 'link'}
|
|
|
- }
|
|
|
- ]
|
|
|
- },
|
|
|
+ // {
|
|
|
+ // path: '/system',
|
|
|
+ // component: Layout,
|
|
|
+ // redirect: '/system/menu',
|
|
|
+ // name: '系统管理',
|
|
|
+ // meta: {title: 'Example', icon: 'el-icon-s-help'},
|
|
|
+ // children: [
|
|
|
+ // {
|
|
|
+ // path: 'menu',
|
|
|
+ // name: '菜单管理',
|
|
|
+ // component: () => import('@/views/system/menu'),
|
|
|
+ // meta: {title: '菜单管理', icon: 'table'}
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // path: 'dept',
|
|
|
+ // name: '部门管理',
|
|
|
+ // component: () => import('@/views/system/dept'),
|
|
|
+ // meta: {title: '部门管理', icon: 'tree'}
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // path: 'role',
|
|
|
+ // name: '角色管理',
|
|
|
+ // component: () => import('@/views/system/role'),
|
|
|
+ // meta: {title: '角色管理', icon: 'tree'}
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // path: 'user',
|
|
|
+ // name: '员工管理',
|
|
|
+ // component: () => import('@/views/system/user'),
|
|
|
+ // meta: {title: '员工管理', icon: 'tree'}
|
|
|
+ // }
|
|
|
+ // ]
|
|
|
+ // },
|
|
|
|
|
|
// 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
|
|
|
-})
|
|
|
+// 动态路由,基于用户权限动态去加载
|
|
|
+export const dynamicRoutes = []
|
|
|
|
|
|
-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
|
|
|
+// 防止连续点击多次路由报错
|
|
|
+let routerPush = Router.prototype.push;
|
|
|
+let routerReplace = Router.prototype.replace;
|
|
|
+// push
|
|
|
+Router.prototype.push = function push(location) {
|
|
|
+ return routerPush.call(this, location).catch(err => err)
|
|
|
+}
|
|
|
+// replace
|
|
|
+Router.prototype.replace = function push(location) {
|
|
|
+ return routerReplace.call(this, location).catch(err => err)
|
|
|
}
|
|
|
|
|
|
-export default router
|
|
|
+export default new Router({
|
|
|
+ base: process.env.VUE_APP_CONTEXT_PATH,
|
|
|
+ mode: 'history', // 去掉url中的#
|
|
|
+ scrollBehavior: () => ({ y: 0 }),
|
|
|
+ routes: constantRoutes
|
|
|
+})
|
|
|
+
|
|
|
+// const createRouter = () => new Router({
|
|
|
+// // mode: 'history', // require service support
|
|
|
+// scrollBehavior: () => ({y: 0}),
|
|
|
+// routes: constantRoutes
|
|
|
+// })
|
|
|
+//
|
|
|
+// 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
|
|
|
+// }
|
|
|
+//
|
|
|
+// export default router
|