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'/'el-icon-x' the icon show in the sidebar 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: '/login', component: () => import('@/views/login/index'), hidden: true }, { path: '/404', component: () => import('@/views/404'), hidden: true }, { path: '/', component: Layout, redirect: '/dashboard', children: [{ path: 'dashboard', name: 'Dashboard', component: () => import('@/views/dashboard/index'), meta: { title: '首页', icon: 'dashboard' } }] }, { path: '/form', component: Layout, children: [ { path: 'index', name: 'Form', component: () => import('@/views/form/index'), meta: { title: 'Form', icon: 'form' }, hidden: true } ] }, { path: '/join', component: Layout, children: [ { path: 'list', name: 'join', component: () => import('@/views/join/list'), meta: { title: '加盟申请列表', icon: 'el-icon-s-help' } }, { path: 'edit/:id(\\d+)', name: 'editJoin', component: () => import('@/views/join/edit'), meta: { title: '加盟申请查看', icon: 'el-icon-s-help' }, hidden: true } ] }, { path: '/city', component: Layout, children: [ { path: 'list', name: 'join', component: () => import('@/views/city/list'), meta: { title: '开放区域列表', icon: 'el-icon-s-help' } }, { path: 'edit/:id(\\d+)', name: 'editJoin', component: () => import('@/views/join/edit'), meta: { title: '加盟申请查看', icon: 'el-icon-s-help' }, hidden: true } ] }, { path: '/advice', component: Layout, children: [ { path: 'list', name: 'advice', component: () => import('@/views/advice/list'), meta: { title: '意见列表', icon: 'el-icon-s-help' } }, { path: 'edit/:id(\\d+)', name: 'editAdvice', component: () => import('@/views/advice/edit'), meta: { title: '查看意见', icon: 'el-icon-s-help' }, hidden: true } ] }, { path: '/setting', component: Layout, name: 'setting', meta: { title: '小程序设置', icon: 'el-icon-setting' }, children: [ { path: 'edit', component: () => import('@/views/setting/edit'), name: 'CreateBanner', meta: { title: '关于我们', icon: 'el-icon-edit' } }, { path: 'editServer', component: () => import('@/views/setting/editServer'), name: 'EditBanner', meta: { title: '服务协议', icon: 'el-icon-edit' } } ] }, { path: '/banner', component: Layout, redirect: '/banner/list', name: 'article', meta: { title: '轮播设置', icon: 'el-icon-s-help' }, children: [ { path: 'create', component: () => import('@/views/banner/create'), name: 'CreateBanner', meta: { title: '创建轮播图', icon: 'el-icon-edit' } }, { path: 'edit/:id(\\d+)', component: () => import('@/views/banner/edit'), name: 'EditBanner', meta: { title: '修改轮播图', noCache: true, activeMenu: '/banner/list' }, hidden: true }, { path: 'list', component: () => import('@/views/banner/list'), name: 'BannerList', meta: { title: '轮播图列表', icon: 'el-icon-s-order' } } ] }, { path: '/question', component: Layout, redirect: '/banner/list', name: 'question', meta: { title: '常见疑问设置', icon: 'el-icon-s-help' }, children: [ { path: 'create', component: () => import('@/views/question/create'), name: 'CreateQuestion', meta: { title: '创建疑问', icon: 'el-icon-edit' } }, { path: 'edit/:id(\\d+)', component: () => import('@/views/question/edit'), name: 'EditBanner', meta: { title: '修改疑问', noCache: true, activeMenu: '/question/list' }, hidden: true }, { path: 'list', component: () => import('@/views/question/list'), name: 'BannerList', meta: { title: '常见疑问列表', icon: 'el-icon-s-order' } } ] }, { path: '/user', component: Layout, redirect: '/user/list', name: 'user', meta: { title: '用户', icon: 'el-icon-user' }, children: [ { path: 'create', component: () => import('@/views/user/create'), name: 'CreateUser', meta: { title: '创建用户', icon: 'el-icon-edit' }, hidden: true }, { path: 'edit/:id(\\d+)', component: () => import('@/views/user/edit'), name: 'EditUser', meta: { title: '修改用户', noCache: true, activeMenu: '/user/list' }, hidden: true }, { path: 'list', component: () => import('@/views/user/list'), name: 'UserList', meta: { title: '用户列表', icon: 'el-icon-s-order' } } ] }, { path: '/article', component: Layout, redirect: '/article/list', name: 'article', meta: { title: '资讯信息', icon: 'el-icon-reading' }, children: [ { path: 'create', component: () => import('@/views/article/create'), name: 'CreateArticle', meta: { title: '创建文章', icon: 'el-icon-edit' } }, { path: 'edit/:id(\\d+)', component: () => import('@/views/article/edit'), name: 'EditArticle', meta: { title: '修改文章', noCache: true, activeMenu: '/article/list' }, hidden: true }, { path: 'list', component: () => import('@/views/article/list'), name: 'ArticleList', meta: { title: '文章列表', icon: 'el-icon-s-order' } } ] }, { path: '/live', component: Layout, redirect: '/live/list', name: 'live', meta: { title: '直播列表', icon: 'el-icon-reading' }, children: [ { path: 'create', component: () => import('@/views/live/create'), name: 'CreateLive', meta: { title: '创建直播间', icon: 'el-icon-edit' } }, { path: 'edit/:id(\\d+)', component: () => import('@/views/live/edit'), name: 'EditLive', meta: { title: '修改直播间', noCache: true, activeMenu: '/live/list' }, hidden: true }, { path: 'list', component: () => import('@/views/live/list'), name: 'ArticleLive', meta: { title: '直播列表', icon: 'el-icon-s-order' } } ] }, { path: '/video', component: Layout, redirect: '/video/list', name: 'video', meta: { title: '短视频', icon: 'el-icon-video-camera' }, children: [ { path: 'create', component: () => import('@/views/video/create'), name: 'CreateVideo', meta: { title: '创建短视频', icon: 'el-icon-edit' } }, { path: 'edit/:id(\\d+)', component: () => import('@/views/video/edit'), name: 'EditVideo', meta: { title: '修改短视频', noCache: true, activeMenu: '/video/list' }, hidden: true }, { path: 'list', component: () => import('@/views/video/list'), name: 'VideoList', meta: { title: '短视频列表', icon: 'el-icon-s-order' } } ] }, // 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