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,
    settlementManagement,
    parkReportManagement,
    administrationManagement,
    feedbackManagement,
    platformManagement,
    officialWebsiteManagement,
    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