import Vue from 'vue';
import VueRouter from 'vue-router';
import Index from '../views/Index';
import home from '../views/home.vue';

Vue.use(VueRouter);

const routes = [
    {
        path: '/',
        component: Index,
        children: [
            {
                path: '/',
                redirect: '/home'
            },
            {
                path: '/home',
                name: 'home',
                component: home,
                meta: {
                    menu: 'home'
                }
            },
            {
                path: '/app',
                name: 'app',
                component: () => import(/* webpackChunkName: "app_download" */ '@/views/app.vue'),
                meta: {
                    menu: 'app'
                }
            },
            {
                path: '/news',
                name: 'news',
                component: () => import(/* webpackChunkName: "news" */ '@/views/news.vue'),
                meta: {
                    menu: 'news'
                }
            },
            {
                path: '/newsList',
                name: 'newsList',
                component: () => import(/* webpackChunkName: "news" */ '@/views/newsList.vue'),
                meta: {
                    menu: 'news'
                }
            },
            {
                path: '/newsList2',
                name: 'newsList2',
                component: () => import(/* webpackChunkName: "news" */ '@/views/newsList2.vue'),
                meta: {
                    menu: 'newsList2'
                }
            },
            {
                path: '/homeUpdate',
                name: 'homeUpdate',
                component: () => import(/* webpackChunkName: "news" */ '@/views/homeUpdate.vue'),
                meta: {
                    menu: 'homeUpdate'
                }
            },
            {
                path: '/policy',
                name: 'policy',
                component: () => import(/* webpackChunkName: "policy" */ '@/views/policy.vue'),
                meta: {
                    menu: 'policy'
                }
            },
            {
                path: '/policyArticle',
                name: 'policyArticle',
                component: () => import(/* webpackChunkName: "policy" */ '@/views/policyArticle.vue'),
                meta: {
                    menu: 'policy'
                }
            },

            {
                path: '/article',
                name: 'article',
                component: () => import(/* webpackChunkName: "article" */ '@/views/article.vue'),
                meta: {}
            },
            {
                path: '/resource',
                name: 'resource',
                component: () => import(/* webpackChunkName: "resource" */ '@/views/resource.vue'),
                meta: {
                    menu: 'resource'
                }
            },
            {
                path: '/resourceDetail',
                name: 'resourceDetail',
                component: () => import(/* webpackChunkName: "resourceDetail" */ '@/views/resourceDetail.vue'),
                meta: {}
            },
            {
                path: '/resourceFanceDetail',
                name: 'resourceFanceDetail',
                component: () => import(/* webpackChunkName: "resourceDetail" */ '@/views/resourceFanceDetail.vue'),
                meta: {}
            },
            {
                path: '/resourceRelease',
                name: 'resourceRelease',
                component: () => import(/* webpackChunkName: "resourceRelease" */ '@/views/resourceRelease.vue'),
                meta: {}
            },
            {
                path: '/interact',
                name: 'interact',
                component: () => import(/* webpackChunkName: "interact" */ '@/views/interact.vue'),
                meta: {
                    menu: 'interact'
                }
            },
            {
                path: '/interactDetail',
                name: 'interactDetail',
                component: () => import(/* webpackChunkName: "interactDetail" */ '@/views/interactDetail.vue'),
                meta: {}
            },
            {
                path: '/interactDetail2',
                name: 'interactDetail2',
                component: () => import(/* webpackChunkName: "interactDetail2" */ '@/views/interactDetail2.vue'),
                meta: {}
            },
            {
                path: '/interactDetail3',
                name: 'interactDetail3',
                component: () => import(/* webpackChunkName: "interactDetail3" */ '@/views/interactDetail3.vue'),
                meta: {}
            },
            {
                path: '/list',
                name: 'list',
                component: () => import(/* webpackChunkName: "list" */ '@/views/list.vue'),
                meta: {}
            },
            {
                path: '/manage',
                name: 'manage',
                component: () => import(/* webpackChunkName: "manage" */ '@/views/manage.vue'),
                meta: {}
            },
            {
                path: '/artNeed',
                name: 'artNeed',
                component: () => import(/* webpackChunkName: "artNeed" */ '@/views/ArtNeed.vue'),
                meta: {}
            },
            {
                path: '/auth',
                name: 'auth',
                component: () => import(/* webpackChunkName: "auth" */ '@/views/auth.vue'),
                meta: {}
            },
            {
                path: '/enterprise',
                name: 'enterprise',
                component: () => import(/* webpackChunkName: "enterprise" */ '@/views/enterprise.vue'),
                meta: {}
            },
            {
                path: '/',
                component: () => import('@/views/mine/mine.vue'),
                children: [
                    // {
                    //     path: '/message',
                    //     name: 'message',
                    //     component: () => import('@/views/mine/message.vue'),
                    //     meta: {}
                    // },
                    {
                        path: '/interactive',
                        name: 'interactive',
                        component: () => import('@/views/mine/interactive.vue'),
                        meta: {}
                    },
                    {
                        path: '/release',
                        name: 'release',
                        component: () => import('@/views/mine/release.vue'),
                        meta: {}
                    },
                    {
                        path: '/releaseDetails',
                        name: 'releaseDetails',
                        component: () => import('@/views/mine/releaseDetails.vue'),
                        meta: {}
                    },
                    {
                        path: '/myCollection',
                        name: 'myCollection',
                        component: () => import('@/views/mine/myCollection.vue'),
                        meta: {}
                    },
                    {
                        path: '/editInfo',
                        name: 'editInfo',
                        component: () => import('@/views/mine/editInfo.vue'),
                        meta: {}
                    },
                    {
                        path: '/account',
                        name: 'account',
                        component: () => import('@/views/mine/account.vue'),
                        meta: {}
                    },
                    {
                        path: '/editPassword',
                        name: 'editPassword',
                        component: () => import('@/views/mine/editPassword.vue'),
                        meta: {}
                    },
                    {
                        path: '/docking',
                        name: 'docking',
                        component: () => import('@/views/mine/docking.vue'),
                        meta: {}
                    },
                    {
                        path: '/releaseSupply',
                        name: 'releaseSupply',
                        component: () => import('@/views/mine/releaseSupply.vue'),
                        meta: {}
                    },
                    {
                        path: '/releaseRequirement',
                        name: 'releaseRequirement',
                        component: () => import('@/views/mine/releaseRequirement.vue'),
                        meta: {}
                    },
                    // {
                    //     path: '/releaseInfo',
                    //     name: 'releaseInfo',
                    //     component: () => import('@/views/mine/releaseInfo.vue'),
                    //     meta: {}
                    // },
                    {
                        path: '/editPhoneStep1',
                        name: 'editPhoneStep1',
                        component: () => import('@/views/mine/editPhoneStep1.vue'),
                        meta: {}
                    },
                    {
                        path: '/editPhoneStep2',
                        name: 'editPhoneStep2',
                        component: () => import('@/views/mine/editPhoneStep2.vue'),
                        meta: {}
                    },
                    {
                        path: '/editPhoneStep3',
                        name: 'editPhoneStep3',
                        component: () => import('@/views/mine/editPhoneStep3.vue'),
                        meta: {}
                    }
                ]
            },
            {
                path: '/',
                component: () => import('@/views/messageCenter/messageCenter.vue'),
                children: [
                    {
                        path: '/message',
                        name: 'message',
                        component: () => import('@/views/messageCenter/message.vue'),
                        meta: {}
                    },
                    {
                        path: '/reply',
                        name: 'reply',
                        component: () => import('@/views/messageCenter/reply.vue'),
                        meta: {}
                    },
                    {
                        path: '/giveLike',
                        name: 'giveLike',
                        component: () => import('@/views/messageCenter/giveLike.vue'),
                        meta: {}
                    },
                    {
                        path: '/messageDetails',
                        name: 'messageDetails',
                        component: () => import('@/views/messageCenter/messageDetails.vue'),
                        meta: {}
                    },
                    {
                        path: '/chat',
                        name: 'chat',
                        component: () => import('@/views/messageCenter/chat.vue'),
                        meta: {}
                    }
                ]
            }
        ]
    },
    {
        path: '/',

        component: () => import('@/views/login/loginBase.vue'),
        meta: {},
        children: [
            {
                path: '/login',
                name: 'login',
                component: () => import('@/views/login/login.vue'),
                meta: {}
            },
            {
                path: '/register',
                name: 'register',
                component: () => import('@/views/login/register.vue'),
                meta: {}
            },
            {
                path: '/registerResult',
                name: 'registerResult',
                component: () => import('@/views/login/registerResult.vue'),
                meta: {}
            },
            {
                path: '/retrieve',
                name: 'retrieve',
                component: () => import('@/views/login/retrieve.vue'),
                meta: {}
            },
            {
                path: '/attest',
                name: 'attest',
                component: () => import('@/views/login/attest.vue'),
                meta: {}
            },
            {
                path: '/attestResult',
                name: 'attestResult',
                component: () => import('@/views/login/attestResult.vue'),
                meta: {}
            }
        ]
    },

    {
        path: '/result',
        name: 'result',
        component: () => import(/* webpackChunkName: "result" */ '@/views/result.vue'),
        meta: {}
    },
    // {
    //     path: '/message',
    //     name: 'message',
    //     component: () => import(/* webpackChunkName: "message" */ '@/views/mine/message.vue'),
    //     meta: {}
    // },
    {
        path: '/',
        component: () => import('@/views/search/searchBase.vue'),
        children: [
            {
                path: '/search',
                name: 'search',
                component: () => import('@/views/search/search.vue'),
                meta: {}
            }
        ]
    }
];

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
});

export default router;

router.afterEach((to, from, next) => {
    window.scrollTo(0, 0);
});
