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


Vue.use(Router)

export default new Router({
    routes: [
        {

            path: '/',
            name: 'menu',
            component: () => import(/* webpackChunkName: "views" */ '../views/menu/menu'),
            children: [
                {
                    path: '/project',
                    name: 'project',
                    meta: {title: '项目管理', tab: true, keepAlive: true},
                    component: () => import(/* webpackChunkName: "views" */ '../views/project/list'),

                },
                {
                    path: '/operatorList',
                    name: 'operatorList',
                    meta: {title: '运营商指定项目', tab: true, keepAlive: true},
                    component: () => import(/* webpackChunkName: "views" */ '../views/project/operatorList'),

                },

                {
                    path: '/operatorLog',
                    name: 'operatorLog',
                    meta: {title: '操作日志', tab: true, keepAlive: true},
                    component: () => import(/* webpackChunkName: "views" */ '../views/operatorLog/list'),
                }
                ,
                {
                    path: '/user',
                    name: 'user',
                    meta: {title: '用户管理', tab: true, keepAlive: true},
                    component: () => import(/* webpackChunkName: "views" */ '../views/user/list'),
                }
                ,
                {
                    path: '/operator',
                    name: 'operator',
                    meta: {title: '运营商管理', tab: true, keepAlive: true},
                    component: () => import(/* webpackChunkName: "views" */ '../views/operator/list'),
                }
                ,
                {
                    path: '/gateway',
                    name: 'gateway',
                    meta: {title: '网关管理', tab: true, keepAlive: true},
                    component: () => import(/* webpackChunkName: "views" */ '../views/gateway/list'),
                }
                ,
                {
                    path: '/device',
                    name: 'device',
                    meta: {title: '设备管理', tab: true, keepAlive: true},
                    component: () => import(/* webpackChunkName: "views" */ '../views/device/list'),
                }
                ,
                {
                    path: '/deviceAlarmRecord',
                    name: 'deviceAlarmRecord',
                    meta: {title: '报警管理', tab: true, keepAlive: true},
                    component: () => import(/* webpackChunkName: "views" */ '../views/deviceAlarmRecord/list'),
                }
                ,
                {
                    path: '/power',
                    name: 'power',
                    meta: {title: '权限管理', tab: true, keepAlive: true},
                    component: () => import(/* webpackChunkName: "views" */ '../views/power/list'),
                }
                ,
                {
                    path: '/role',
                    name: 'role',
                    meta: {title: '角色管理', tab: true, keepAlive: true},
                    component: () => import(/* webpackChunkName: "views" */ '../views/role/list'),
                }
            ]
        },

        {
            path: '/login',
            name: 'login',
            meta: {title: '登录', tab: true, keepAlive: true},
            component: () => import(/* webpackChunkName: "views" */ '../views/login/login'),
        },


    ]
})


// //全局路由守卫
// router.beforeEach((to, from, next) => {
//   if (to.path === '/')
//     return next();
//   // 取出token
//   const token = window.sessionStorage.getItem('token');
//   if (!token)   //没有token的时候 跳转到登陆页面
//     return next('/');
//
//   next();
// })
