import Vue from 'vue';
import Router from 'vue-router';
import Main from 'view/Main';
import login from 'view/login';
// 合并所有router
let routers = [];
const requireComponent = require.context('./modules', false, /\.js$/); // modules下任意js文件
requireComponent.keys().forEach(fileName => {
    const item = requireComponent(fileName);
    routers = routers.concat(item.default); // modules中文件的写法是export default
});
Vue.use(Router);
const router = new Router({
    mode: 'history',
    base: '/gihss/dongying/open',
    routes: [{
        path: '/',
        name: 'main',
        component: Main,
        redirect: '/welcome',
        linkActiveClass: 'active',
        children: [
            {
                path: '/applyCheck',
                name: 'applyCheck',
                component: () => import('@/view/applyCheck.vue')
            },
            {
                path: '/reportQuery',
                name: 'reportQuery',
                component: () => import('@/view/reportQuery')
            },
            {
                path: '/yearCheck',
                name: 'yearCheck',
                component: () => import('@/view/yearCheck')
            },
            {
                path: '/daySearch',
                name: 'daySearch',
                component: () => import('@/view/daySearch')
            },
            {
                path: '/logSearch',
                name: 'logSearch',
                component: () => import('@/view/logSearch')
            },
            {
                path: '/userInfo',
                name: 'userInfo',
                meta: { isCache: false },
                component: () => import('@/view/userInfo')
            },
            {
                path: '/welcome',
                name: 'welcome',
                component: () => import('@/view/welcome')
            },
        ]
    },
    {
        path: '/login',
        name: 'login',
        component: login
    },
    {
        path: '*',
        component: Error
    }
    ]
});
export default router;
