import Vue from 'vue'
import VueRouter from 'vue-router'

/** 导入element-UI信息提示组件 */
import {
	Message
} from 'element-ui'

import 'element-ui/lib/theme-chalk/index.css'
Vue.use(VueRouter)

/** 按需导入后台系统功能组件 */
const routes = [{
		path: '',
		redirect: '/login'
	},
	{
		path: '/login',
		component: () => import('../components/login')
	},
	{
		path: '/admin',
		component: () => import('../components/admin'),
		children: [{
				path: '/admin/routineMonitor',
				component: () => import('../components/admin/routineMonitor')
			},
			{
				path: '/admin/checkMonitor',
				component: () => import('../components/admin/checkMonitor')
			},
			{
				path: '/admin/specialMonitor',
				component: () => import('../components/admin/specialMonitor')
			},
			{
				path: '/admin/addTask',
				component: () => import('../components/admin/addTask')
			},
			
			{
				path: '/admin/recheckMonitor',
				component: () => import('../components/admin/recheckMonitor')
			},
			{
				path: '/admin/addSpecialTask',
				component: () => import('../components/admin/addSpecialTask')
			},
			{
				path: '/admin/takeTheLeadReporList',
				component: () => import('../components/admin/takeTheLeadReporList')
			},{
				path: '/admin/taskSample',
				component: () => import('../components/admin/taskSample')
			}
		]
	},
	{
		path: '/jc',
		component: () => import('../components/jc'),
		children: [{
				path: '/jc/routineMonitor',
				component: () => import('../components/jc/routineMonitor')
			},
			{
				path: '/jc/routineMonitorqt',
				component: () => import('../components/jc/routineMonitorqt'),
				// children:[]
			},
			{
				path: '/jc/taskdetail',
				name:'taskdetail',
				component: () => import('../components/jc/taskdetail')
			},
			{
				path: '/jc/jcobj',
				name:'jcobj',
				component: () => import('../components/jc/jcobj')
			},
			{
				path: '/jc/modelSet',
				name:'modelSet',
				component: () => import('../components/jc/modelSet')
			},
			{
				path: '/jc/inputSample',
				name:'inputSample',
				component: () => import('../components/jc/inputSample')
			},
			{
				path: '/jc/sampleDetail',
				name:'sampleDetail',
				component: () => import('../components/jc/sampleDetail')
			},
			{
				path: '/jc/inputCheck',
				name:'inputCheck',
				component: () => import('../components/jc/inputCheck')
			},
			{
				path: '/jc/specialMonitorqt',
				name:'specialMonitorqt',
				component: () => import('../components/jc/specialMonitorqt')
			},
			{
				path: '/jc/specialMonitorcd',
				name:'specialMonitorcd',
				component: () => import('../components/jc/specialMonitorcd')
			},
			
			{
				path: '/jc/setTaskcd',
				name:'setTaskcd',
				component: () => import('../components/jc/setTaskcd'),
			},
			{
					path: '/jc/setTask',
					name:'setTask',
					component: () => import('../components/jc/setTask')
			}
		]
	},{
		path: '/pdf',
		component: () => import('../components/pdf'),
	}
]

const router = new VueRouter({
	routes
})

// 挂载路由导航守卫
router.beforeEach((to, from, next) => {
	// to:将要访问的路径  from:从哪里过来的   next:放行函数-> next()   next('跳转路径')
	/** 登录,初始化页面不需要拒绝 */
	if (to.path == '/login') {
		return next()
	}

	/** 其他页面需要登录 */
	// const token = window.sessionStorage.getItem('token')
	// console.log(token)
	// if (token == undefined || token == '') {
	//   Message({
	//     message: '用户未登录，请重新登录',
	//     type: 'warning',
	//     showClose: true,
	//     center: true
	//   })
	//   return next('/login')
	// }
	next()
})

export default router
