import Vue from 'vue' // 引入vue import Router from 'vue-router' // 引入vue-router import Layout from '@/layout' // 页面布局 Layou Vue.use(Router) /** * 注意: 子菜单仅在route的children.length> = 1时出现 * hidden: true 如果为true,将不会显示侧边栏sidebar(默认值 false) * redirect: noRedirect 如果设置为noRedirect,则不会重定向 * name:'router-name' name被使用 (必须设置!!!) * meta : { title: 'title' 侧边栏sidebar中显示的名称(推荐设置) icon: 'svg-name' 侧边栏sidebar中显示的icon图标 } */ /** * constantRoutes * 没有权限要求的页面,所有角色roles都可以访问 */ export const constantRoutes = [ { path: '/', component: Layout, redirect: 'noRedirect', }, { path: '/indexLayout/index', component: Layout, children:[{ path: '/indexLayout/index', name: '/indexLayout/index', component: () => import('@/views/indexLayout/index'), meta: { title: '首页', icon: '' }, hidden: true, }] }, //CDA的路由 { path: '/home', component: Layout, hidden: true, redirect: 'noRedirect', children: [{ path: '/home', name: 'home', component: () => import('@/views/home/index'), meta: { title: 'CDA首页', icon: '' }, children: [ { path: '/home/myproject', component: () => import('@/views/home/myproject/index'), meta: { title: '我的项目', icon: '' }, hidden: true }, { path: '/home/openproject', component: () => import('@/views/home/openproject/index'), meta: { title: '公开项目', icon: '' }, hidden: true }, ] }] }, { path: '/index', component: Layout, children:[{ path: '/index', name: 'index', component: () => import('@/views/index/index'), meta: { title: '项目新建', icon: '' }, hidden: true, }] }, //HCFD // { // path: 'HCFDLab/index', // component: Layout, // children:[{ // path: '/index', // name: 'index', // component: () => import('@/views/HCFDLab/index'), // meta: { title: '项目新建', icon: '' }, // hidden: true, // }] // }, // 登陆 { path: '/login', component: Layout, hidden: true, redirect: 'noRedirect', children: [{ path: 'index', name: 'Index', component: () => import('@/views/login/index'), meta: { title: '登录', icon: '' } }] }, { path: '/forget', component: Layout, hidden: true, redirect: 'noRedirect', children: [{ path: 'index', name: 'Index', component: () => import('@/views/forget/index'), meta: { title: '忘记密码', icon: '' } }] }, { path: '/register', component: Layout, hidden: true, redirect: 'noRedirect', children: [{ path: 'index', name: 'Index', component: () => import('@/views/register/index'), meta: { title: '免费注册', icon: '' } }] }, { path: '/protocol', component: Layout, hidden: true, redirect: 'noRedirect', children: [{ path: 'index', name: 'Index', component: () => import('@/views/protocol/index'), meta: { title: '注册协议', icon: '' } }] }, { path: '/fail404', component: () => import('@/views/fail404/index'), hidden: true }, // 404页必须放在末尾 !!! { path: '*', redirect: '/indexLayout/index', component: () => import('@/views/indexLayout/index'), hidden: true } ] // 创建路由(hashHistory是以#后面的路径进行处理,通过HTML5 History进行前端路由管理,而 browserHistory 则是类似我们通常的页面访问路径,并没有#,但要通过服务端的配置,能够访问指定的url 都定向到当前页面,从而能够进行前端的路由管理。) const createRouter = () => new Router({ // mode: 'history', // history模式(browserHistory需要后端支持,本项目默认hashHistory ) scrollBehavior: () => ({ y: 0 }), routes: constantRoutes }) const router = createRouter() // 重置路由(通过将路由的matcher对象替换为新创建的路由实例中的matcher对象来实现) export function resetRouter() { const newRouter = createRouter() router.matcher = newRouter.matcher } export default router // 导出router