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

Vue.use(Router)
const router = new Router({
    routes: [{
            path: '/',
            name: 'Home',
            component: () =>
                import ('../views/Home/Home')

        },
        // {
        //     path: '/login',
        //     name: 'Login',
        //     component: () => import('../views/Login/Login')

        // },
        // {
        //     path: '/mine',
        //     name: 'Mine',
        //     props: true,
        //     // 路由元信息
        //     meta: {
        //         isLogin: true
        //     },
        //     component: () => import('@/views/Mine/Mine')
        // },
        // {
        //     path: '*',
        //     name: 'NotFound',
        //     component: () =>
        //         import ('@/views/NotFound/NotFound')

        // },
    ]
});
// 全局前置守卫
router.beforeEach((to, from, next) => {
    const isLogin = true;
    if (to.matched.some(item => item.meta.isLogin)) {
        if (isLogin) {
            next();
            return;
        }
        next('/login')
    } else {
        next();
    }
});





export default router;