import Vue from 'vue' import Router from 'vue-router' Vue.use(Router) /* Layout */ import Layout from '@/layout' /* Router Modules */ import memberRouter from '@/router/modules/member' import configRouter from '@/router/modules/config' /** * Note: sub-menu only appear when route children.length >= 1 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html * * hidden: true if set true, item will not show in the sidebar(default is false) * alwaysShow: true if set true, will always show the root menu * if not set alwaysShow, when item has more than one children route, * it will becomes nested mode, otherwise not show the root menu * redirect: noRedirect if set noRedirect will no redirect in the breadcrumb * name:'router-name' the name is used by (must set!!!) * meta : { roles: ['admin','editor'] control the page roles (you can set multiple roles) title: 'title' the name show in sidebar and breadcrumb (recommend set) icon: 'svg-name'/'el-icon-x' the icon show in the sidebar noCache: true if set true, the page will no be cached(default is false) affix: true if set true, the tag will affix in the tags-view breadcrumb: false if set false, the item will hidden in breadcrumb(default is true) activeMenu: '/example/list' if set path, the sidebar will highlight the path you set } */ /** * constantRoutes * a base page that does not have permission requirements * all roles can be accessed */ export const constantRoutes = [ { path: '/redirect', component: Layout, hidden: true, children: [ { path: '/redirect/:path(.*)', component: () => import('@/views/redirect/index') } ] }, { path: '/admin', component: Layout, hidden: true, children: [ { path: '/admin/role', component: () => import('@/views/admin/role') // 管理员角色列表 }, { path: '/admin/role-add', component: () => import('@/views/admin/role-add') // 添加角色 }, { path: '/admin/role-edit/:id', name: 'admin_role-edit', component: () => import('@/views/admin/role-add') // 编辑角色 }, { path: '/admin/role-permission/:id', name: 'admin_role-permission', component: () => import('@/views/admin/role-permission') // 角色权限 }, { path: '/admin/change-password', name: 'admin_change-password', component: () => import('@/views/admin/edit') // 重置密码 }, { path: '/admin/index', name: 'admin_index', component: () => import('@/views/admin/index') // 管理员列表 }, { path: '/admin/add', name: 'admin_add', component: () => import('@/views/admin/edit') // 添加管理员 }, { path: '/admin/edit/:id', name: 'admin_edit', component: () => import('@/views/admin/edit') // 编辑管理员 } ] }, { path: '/finance', component: Layout, hidden: true, children: [ { path: '/finance/balance-audit-list', // 会员余额调整列表 component: () => import('@/views/finance/balance-audit-list'), name: 'finance_balance-audit-list', }, { path: '/finance/change-balance-opt', // 申请调整会员余额 component: () => import('@/views/finance/change-balance-opt'), name: 'finance_change-balance-opt', }, { path: '/finance/transfer-list', // 转账记录列表 component: () => import('@/views/finance/transfer-list'), name: 'finance_transfer-list', }, { path: '/finance/recharge', // 充值管理 component: () => import('@/views/finance/recharge'), name: 'finance_recharge', }, { path: '/finance/recharge-status', // 状态管理 component: () => import('@/views/finance/recharge-status'), name: 'finance_recharge-status', }, ] }, { path: '/login', component: () => import('@/views/login/index'), hidden: true }, { path: '/auth-redirect', component: () => import('@/views/login/auth-redirect'), hidden: true }, { path: '/404', component: () => import('@/views/error-page/404'), hidden: true }, { path: '/401', component: () => import('@/views/error-page/401'), hidden: true }, { path: '/', component: Layout, redirect: '/dashboard', children: [ { path: 'dashboard', component: () => import('@/views/dashboard/index'), name: 'Dashboard', meta: { title: 'dashboard', icon: 'dashboard', affix: true } } ] }, { path: '/profile', component: Layout, redirect: '/profile/index', hidden: true, children: [ { path: 'index', component: () => import('@/views/profile/index'), name: 'Profile', meta: { title: 'profile', icon: 'user', noCache: true } } ] } ] /** * asyncRoutes * the routes that need to be dynamically loaded based on user roles */ export const asyncRoutes = [ /** when your routing map is too long, you can split it into small modules **/ // 会员 memberRouter, // 设置 configRouter, { path: '/error', component: Layout, redirect: 'noRedirect', name: 'ErrorPages', meta: { title: 'errorPages', icon: '404' }, children: [ { path: '401', component: () => import('@/views/error-page/401'), name: 'Page401', meta: { title: 'page401', noCache: true } }, { path: '404', component: () => import('@/views/error-page/404'), name: 'Page404', meta: { title: 'page404', noCache: true } } ] }, { path: '/error-log', component: Layout, children: [ { path: 'log', component: () => import('@/views/error-log/index'), name: 'ErrorLog', meta: { title: 'errorLog', icon: 'bug' } } ] }, // 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.concat(asyncRoutes) }) 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 function selfAddRoutes(params) { const newRouter = createRouter() router.matcher = newRouter.matcher router.addRoutes(params) } export default router