import Vue from 'vue' import Router from 'vue-router' Vue.use(Router) /* Layout */ import Layout from '@/layout' /** * 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' 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: '/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: '首页', icon: 'dashboard', affix: true } } ] }, { path: '/club', component: Layout, redirect: '/club/list', name: 'Club', meta: { title: '会所管理', icon: 'tree' }, children: [ { path: 'list', name: 'List', component: () => import('@/views/club/list'), meta: { title: '会所列表', icon: 'list' } }, { path: 'form', name: 'Form', component: () => import('@/views/club/form'), meta: { title: '上线会所', icon: 'form' } }, { path: 'operateList', component: () => import('@/views/club/operateList'), name: 'OperateList', meta: { title: '查看运营人员', noCache: true, activeMenu: '/club/list' }, hidden: true }, { path: 'editForm', component: () => import('@/views/club/editForm'), name: 'EditForm', meta: { title: '编辑会所', noCache: true, activeMenu: '/club/list' }, hidden: true } ] }, { path: '/goods', component: Layout, redirect: '/goods/list', name: 'Goods', meta: { title: '商品管理', icon: 'shopping' }, children: [ { path: 'category', name: 'Category', component: () => import('@/views/goods/category'), meta: { title: '商品分类', icon: 'component' } }, { path: 'category/edit/:id(\\d+)', name: 'EditCategory', component: () => import('@/views/goods/category-edit'), meta: { title: '编辑分类', noCache: true, activeMenu: '/goods/category' }, hidden: true }, { path: 'category/create', name: 'CreateCategory', component: () => import('@/views/goods/category-create'), meta: { title: '添加分类', noCache: true, activeMenu: '/goods/category' }, hidden: true }, { path: 'list', name: 'List', component: () => import('@/views/goods/list'), meta: { title: '商品列表', icon: 'list' } }, { path: 'list/preferred', name: 'PreferredProduct', component: () => import('@/views/goods/list-preferred'), meta: { title: '星范优惠', noCache: true, activeMenu: '/goods/list' }, hidden: true }, { path: 'list/preferential', name: 'PreferentialProduct', component: () => import('@/views/goods/list-preferential'), meta: { title: '星范精品', noCache: true, activeMenu: '/goods/list' }, hidden: true }, { path: 'list/commonly', name: 'CommonlyProduct', component: () => import('@/views/goods/list-commonly'), meta: { title: '常用商品', noCache: true, activeMenu: '/goods/list' }, hidden: true }, { path: 'list/select/:type(\\d+)', name: 'SelectProduct', component: () => import('@/views/goods/list-select'), meta: { title: '添加商品', noCache: true, activeMenu: '/goods/list' }, hidden: true } ] }, { path: '/order', component: Layout, redirect: '/order/list', name: 'Order', meta: { title: '订单管理', icon: 'documentation' }, children: [ { path: 'list', name: 'List', component: () => import('@/views/order/list'), meta: { title: '订单列表', icon: 'list' } }, { path: 'refund', name: 'Refund', component: () => import('@/views/order/refund'), meta: { title: '用户退款列表', icon: 'skill' } }, { path: 'refund/detail/:id(\\d+)', name: 'RefundDeatil', component: () => import('@/views/order/refund-detail'), meta: { title: '用户退款详情', noCache: true, activeMenu: '/order/refund' }, hidden: true }, { path: 'detail/:id(\\d+)', name: 'Detail', component: () => import('@/views/order/detail'), meta: { title: '订单详情', noCache: true, activeMenu: '/order/list' }, hidden: true }, { path: 'logistics/:id(\\d+)', name: 'logistics', component: () => import('@/views/order/logistics'), meta: { title: '发货记录', noCache: true, activeMenu: '/order/list' }, hidden: true }, { path: 'refund-record/:id(\\d+)', name: 'RefundRecord', component: () => import('@/views/order/refund-record'), meta: { title: '收退款记录', noCache: true, activeMenu: '/order/list' }, hidden: true }, { path: 'refund-return/:id(\\d+)', name: 'RefundRreturn', component: () => import('@/views/order/refund-return'), meta: { title: '退款(退货)记录', noCache: true, activeMenu: '/order/list' }, hidden: true } ] }, { path: '/finance', component: Layout, redirect: '/finance/list', name: 'Finance', meta: { title: '财务管理', icon: 'money' }, children: [ { path: 'list', name: 'List', component: () => import('@/views/finance/list'), meta: { title: '对账列表', icon: 'list' } }, { path: 'refund', name: 'Refund', component: () => import('@/views/finance/refund'), meta: { title: '退款管理', icon: 'skill' } } ] }, { path: '/other', component: Layout, redirect: '/other/about', name: 'Other', meta: { title: '其他设置', icon: 'example' }, children: [ { path: 'about', name: 'About', component: () => import('@/views/other/about'), meta: { title: '关于我们', icon: 'peoples' } }, { path: 'after', name: 'After', component: () => import('@/views/other/after'), meta: { title: '售后无忧', icon: 'star' } }, { path: 'notes', name: 'Notes', component: () => import('@/views/other/notes'), meta: { title: '购物须知', icon: 'form' } }, { path: 'password', name: 'Password', component: () => import('@/views/other/password'), meta: { title: '修改密码', icon: 'eye' } } ] } ] /** * asyncRoutes * the routes that need to be dynamically loaded based on user roles */ export const asyncRoutes = [ // 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 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