const Router = VueRouter;
const routes = [
    //默认跳转到登录页
    {
        path: "/",
        redirect: "/login"
    },
    //默认跳转到登录页
    {
        path: '/login',
        component: () => import('@/views/login/index'),
        hidden: true
    },
    {
        path: '/home',
        component: () => import('@/layout/index'),
        redirect: '/product',
        children: [
            {
                path: 'live',
                component: () => import('@/views/live/index'),
                name: 'live',
                alwaysShow: true,
                meta: { title: '直播', noCache: true, breadcrumb: true }
            },
            {
                path: 'product',
                component: () => import('@/views/product/index'),
                name: 'product',
                alwaysShow: true,
                meta: { title: '产品', noCache: true, breadcrumb: true }
            },

            {
                path: 'my',
                component: () => import('@/views/my/index'),
                name: 'my',
                alwaysShow: true,
                meta: { title: '我的', noCache: true, breadcrumb: true }
            },
        ]
    },
    {
        path: '/orderRes',
        component: () => import('@/views/order/orderRes'),
        hidden: true
    },
    {
        path: '/liveD',
        component: () => import('@/views/live/liveD'),
        hidden: true
    },
    {
        path: '/address',
        component: () => import('@/views/address/index'),
        hidden: true
    },
    {
        path: '/addressView',
        component: () => import('@/views/address/view'),
        hidden: true
    },
    {
        path: '/order',
        component: () => import('@/views/order/index'),
        hidden: true
    },
    {
        path: '/oDetail',
        component: () => import('@/views/order/detail'),
        hidden: true
    },
    {
        path: '/aboutUs',
        component: () => import('@/views/aboutUs/index'),
        hidden: true
    },


];
console.log(process.env.BASE_URL);
const router = new Router({
    mode: "hash",
    base: process.env.BASE_URL,
    scrollBehavior: () => ({ y: 0 }),
    routes
});

// 重写路由的push方法，主要是为了解决同一个路由路径重复点击报错
const routerPush = Router.prototype.push;
Router.prototype.push = function push(location) {
    return routerPush.call(this, location).catch(error => error);
};
Vue.use(Router);
export default router;
