import Vue from 'vue'
import Router from 'vue-router'
import store from '../store'
Vue.use(Router)

import Layout from '@/layout'
import news from './news/index'
import driverManagement from './driverManagement/index'
import cargoOwnerManagement from './cargoOwnerManagement/index'
import enterpriseManagement from './enterpriseManagement/index'
import orderManagement from './orderManagement/index'
import contractManagement from './contractManagement/index'
import platformManagement from './platformManagement/index'
import feedbackManagement from './feedbackManagement/index'
import officialWebsiteManagement from './officialWebsiteManagement/index'
import parkReportManagement from './parkReportManagement/index'
import administrationManagement from './administrationManagement/index'
import settlementManagement from './settlementManagement/index'
import operationLog from './operationLog/index'


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: 'shouye',
                checkIcon:'checkshouye'
            }
        }]
    },
    {
        path: '/permissionSetting',
        component: Layout,
        redirect: '/permissionSettingManagement',
        name: 'permissionSettingManagement',
        meta: {
            title: '权限设置',
            icon: 'permission',
            checkIcon:'checkpermission'
        },
        children: [{
                path: 'permissionSetting',
                name: 'permissionSetting',
                component: () =>
                    import ('@/views/permissionSetting/permissionSetting'),
                meta: {
                    title: '角色设置',
                    // icon: 'shouye'
                }
            },
            {
                path: 'permissionSettingPerson',
                name: 'permissionSettingPerson',
                component: () =>
                    import ('@/views/permissionSetting/permissionSettingPerson'),
                meta: {
                    title: '人员设置',
                    // icon: 'shouye'
                }
            }
        ]
    },
    // {
    //     path: '*',
    //     redirect: '/404',
    //     hidden: true
    // }
]
let cofigRouter = [
    news,
    driverManagement,
    cargoOwnerManagement,
    enterpriseManagement,
    orderManagement,
    contractManagement,
    platformManagement,
    feedbackManagement,
    officialWebsiteManagement,
    parkReportManagement,
    administrationManagement,
    settlementManagement,
    operationLog,
]
export const asyncRoutes = cofigRouter
const createRouter = () =>
    new Router({
        // mode: 'history',
        scrollBehavior: () => ({
            y: 0
        }),
        linkActiveClass: 'active', // router-link  .active样式
        routes: constantRoutes
    })

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