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


const originalPush = Router.prototype.push;
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err);
}

Vue.use(Router)

export default new Router({
    routes: [
        {
            path: '/404',
            component: () => import('@/views/404')
        },
        {
            path: '/',
            component: () => import('@/views/Index'),
            children: [
                {
                    path: 'myFriends',
                    component: () => import('@/components/menus/MyFriends')
                },
                {
                    path: 'myStar',
                    component: () => import('@/components/menus/MyStar')
                },
                {
                    path: 'allUsers',
                    component: () => import('@/components/menus/AllUsers')
                },
                {
                    path: 'hotNews',
                    component: () => import('@/components/menus/HotNews')
                },
                {
                    path: 'similarUser',
                    component: () => import('@/components/menus/user/SimilarUser')
                },
                {
                    path: 'linkUser',
                    component: () => import('@/components/menus/user/LinkUser')
                },
                {
                    path: 'recommendItem',
                    component: () => import('@/components/menus/item/RecommendItem')
                },
                {
                    path: 'feedbackHistory',
                    component: () => import('@/components/menus/item/FeedbackHistory')
                },
                {
                    path: 'similarItem',
                    component: () => import('@/components/menus/item/SimilarItem')
                },
                {
                    path: '/',
                    redirect: "myFriends"
                },
            ]
        },
        {
            path: '/login',
            name: 'Login',
            component: () => import('@/views/Login'),
        },
        {
            path: '/register',
            name: 'Register',
            component: () => import('@/views/Register'),
        },
        {path: '*', redirect: '/404'}
    ],
    mode: "hash"
})
