import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/* Router Modules */
/**
 * Note: 子菜单仅在路由children.length> = 1时出现
 *
 * hidden: true                   如果设置为true，则项目不会显示在左侧菜单栏中（默认为false）
 * alwaysShow: true               如果设置为true，将始终显示根菜单
 *                                如果未设置alwaysShow，则当项具有多个子路由时，它将变为嵌套模式，否则不显示根菜单
 * redirect: noRedirect           如果设置noRedirect，则不会在面包屑中重定向
 * name:'router-name'             该名称由<keep-alive>使用
 * meta : {
    title: 'title'               名称显示在侧边栏和面包屑中
    icon: 'svg-name'             侧栏中的图标显示
    breadcrumb: false            如果设置为false，则该项将隐藏在面包屑中（默认为true）
    activeMenu: '/example/list'  如果设置了路径，则侧边栏将高亮显示此路径
  }
 */

/**
 * constantRoutes
 * 没有权限要求的页面
 * 所有角色都可访问
 */
export const constantRoutes = [
  {
    path: '/',
    redirect: '/login',
    hidden: true
  },
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path*',
        component: () => import('@/views/redirect')
      }
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/resetpassword',
    component: () => import('@/views/forgetpassword/index'),
    name: 'Resetpassword',
    hidden: true
  },
  {
    path: '/recompose',
    component: () => import('@/views/recompose/index'),
    name: 'Recompose',
    hidden: true
  },
  {
    path: '/email-recompose',
    component: () => import('@/views/email-recompose/index'),
    name: 'emailRecompose',
    hidden: true
  },
  {
    path: '/joinVerify',
    component: () => import('@/views/joinVerify/index'),
    name: 'joinVerify',
    hidden: true
  },
  {
    path: '/trialStats',
    component: () => import('@/views/reviewers/trialStats'),
    name: 'trialStats',
    hidden: true
  },
  {
    path: '/showdicom',
    name: 'showdicoms',
    hidden: true,
    component: () => import('@/views/dicom-show/dicom-study')
  },

  // {
  //   path: '/showvisitdicoms',
  //   name: 'showvisitdicoms',
  //   hidden: true,
  //   component: () => import('@/views/dicom-show/dicom-visit')
  // },
  // {
  //   path: '/showseriesdicoms',
  //   name: 'showseriesdicoms',
  //   hidden: true,
  //   component: () => import('@/views/dicom-show/dicom-series')
  // },
  // {
  //   path: '/preview',
  //   name: 'previewDicoms',
  //   component: () => import('@/views/dicom-show/server-dicom-temporary'),
  //   hidden: true
  // },

  {
    path: '/showNoneDicoms',
    hidden: true,
    component: () => import('@/views/none-dicom-show/index')
  },
  {
    path: '/noneDicomReading',
    name: 'noneDicomReading',
    hidden: true,
    component: () => import('@/views/trials/trials-panel/reading/none-dicoms/index')
  },
  {
    path: '/readingDicoms',
    component: () => import('@/views/trials/trials-panel/reading/dicoms/index'),
    hidden: true
  },
  {
    path: '/nonedicoms',
    hidden: true,
    component: () => import('@/views/trials/trials-panel/reading/dicoms/none-dicoms')
  },
  {
    path: '/readingPage',
    name: 'readingPage',
    hidden: true,
    component: () => import('@/views/trials/trials-panel/reading/reading-page/index')
  },
  {
    path: '/petct',
    name: 'petct',
    hidden: true,
    component: () => import('@/views/trials/trials-panel/reading/dicoms/components/Fusion/PetCt')
  },
  {
    path: '/visitDicomReview',
    name: 'visitDicomReview',
    hidden: true,
    component: () => import('@/views/trials/trials-panel/reading/dicoms/index')
  },
  {
    path: '/visitNondicomReview',
    name: 'visitNondicomReview',
    hidden: true,
    component: () => import('@/views/trials/trials-panel/reading/none-dicoms/index')
  },
  {
    path: '/globalReview',
    name: 'globalReview',
    hidden: true,
    component: () => import('@/views/trials/trials-panel/reading/global-review/index')
  },
  {
    path: '/adReview',
    name: 'adReview',
    hidden: true,
    component: () => import('@/views/trials/trials-panel/reading/ad-review/index')
  },
  {
    path: '/oncologyReview',
    name: 'oncologyReview',
    hidden: true,
    component: () => import('@/views/trials/trials-panel/reading/oncology-review/index')
  },

  {
    path: '/imagesShare',
    name: 'imagesShare',
    component: () => import('@/views/share/images'),
    hidden: true
  },
  {
    path: '/clinicalData',
    name: 'clinicalData',
    component: () => import('@/views/trials/trials-panel/clinical-data/index'),
    hidden: true
  },
  {
    path: '/researchLogin',
    name: 'researchLogin',
    component: () => import('@/views/research/login'),
    hidden: true
  },
  {
    path: '/researchForm',
    name: 'researchForm',
    component: () => import('@/views/research/form'),
    hidden: true
  },
  {
    path: '/trialsResume',
    component: () => import('@/views/trials/trials-panel/enrolled-reviewers/resume/index'),
    hidden: true
  },
  {
    path: '/ReviewersResearch',
    component: () => import('@/views/reviewers/ReviewersResearch'),
    hidden: true
  },
  {
    path: '/ReviewersResearchForm',
    component: () => import('@/views/reviewers/ReviewersResearchForm'),
    hidden: true
  },
  {
    path: '/blindResumeInfo',
    component: () => import('@/views/blindResumeInfo/index'),
    hidden: true
  },
  {
    path: '/showvisitdicoms',
    name: 'showvisitdicoms',
    hidden: true,
    component: () => import('@/views/dicom-show/dicom-visit')
  },
  {
    path: '/criterionquestions',
    name: 'criterionquestions',
    hidden: true,
    component: () => import('@/views/trials/trials-panel/setting/reading-unit/preview')
  },
  // {
  //   path: '/audit',
  //   name: 'audit',
  //   component: () => import('@/views/trials/audit'),
  //   hidden: true
  // },
  {
    path: '/error',
    component: () => import('@/views/error'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
  {
    path: '/editUser',
    component: Layout,
    redirect: '/editUser/baiscInfo',
    hidden: true,
    children: [{
      path: 'baiscInfo',
      name: 'BaiscInfo',
      component: () => import('@/views/user/editInfo')
    },
    {
      path: 'account',
      name: 'Account',
      component: () => import('@/views/user/account')
    }
    ]
  }
]

const createRouter = () => new Router({
  mode: 'history',
  base: '/',
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
