import Vue from 'vue'
import VueRouter from 'vue-router'
import index from '../views/index.vue'
import home from "@/components/Home/Home.vue";
import monthly from "@/components/Monthly/Monthly.vue";
import ranking from "@/components/Ranking/Ranking.vue";
import paper from "@/components/Paper/Paper.vue";
import MonthlyDetail from "@/components/Monthly/MonthlyDetail.vue";
import MonthlyByTags from "@/components/Monthly/MonthlyByTags.vue";
import UserInfoPage from "@/components/User/UserInfoPage.vue";
import ProjectDetail from "@/components/Project/ProjectDetail.vue";
import ArticleDetail from "@/components/Paper/ArticleDetail.vue";
import adminLogin from "@/components/System/AdminLogin.vue";
import systemIndex from "@/views/systemIndex.vue";
import AdminHome from "@/components/System/AdminHome.vue";
import systemManage from "@/components/System/Manage/systemManage.vue";
import userManage from "@/components/System/Manage/userManage.vue";
import projectManage from "@/components/System/Manage/projectManage.vue";
import commentManage from "@/components/System/Manage/commentManage.vue";
import categoryManage from "@/components/System/Manage/categoryManage.vue";
import articleManage from "@/components/System/Manage/articleManage.vue";

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}
Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        redirect: '/index'
    },
    {
        path: '/index',
        redirect: '/home',
        name: 'index',
        component: index,
        children: [
            {
                path: '/Home',
                name: 'Home',
                component: home
            },
            {
                path: '/monthly',
                name: 'monthly',
                component: monthly
            },
            {
                path: '/ranking',
                name: 'ranking',
                component: ranking
            },
            {
                path: '/paper',
                name: 'paper',
                component: paper
            },
            {
                path: '/MonthlyDetail',
                name: 'MonthlyDetail',
                component: MonthlyDetail
            },
            {
                path: '/UserInfoPage',
                name: 'UserInfoPage',
                component: UserInfoPage
            },
            {
                path: '/MonthlyByTags',
                name: 'MonthlyByTags',
                component: MonthlyByTags
            },
            {
                path: '/ProjectDetail',
                name: 'ProjectDetail',
                component: ProjectDetail
            },
            {
                path: '/ArticleDetail',
                name: 'ArticleDetail',
                component: ArticleDetail
            },
        ]
    },
    {
        path: '/adminLogin',
        name: 'adminLogin',
        component: adminLogin
    }, {
        path: '/systemIndex',
        name: 'systemIndex',
        component: systemIndex,
        redirect: '/adminHome',
        children: [
            {
                path: '/adminHome',
                name: 'adminHome',
                meta: {title: '首页'},
                component: AdminHome
            },
            {
                path: '/systemManage',
                meta: {title: '系统管理'},
                name: 'systemManage',
                component: systemManage
            },
            {
                path: '/userManage',
                name: 'userManage',
                meta: {title: '用户管理'},
                component: userManage
            },
            {
                path: '/projectManage',
                meta: {title: '项目管理'},
                name: 'projectManage',
                component: projectManage
            },
            {
                path: '/commentManage',
                name: 'commentManage',
                meta: {title: '评论管理'},

                component: commentManage
            },
            {
                path: '/categoryManage',
                name: 'categoryManage',
                meta: {title: '标签管理'},

                component: categoryManage
            },
            {
                path: '/articleManage',
                meta: {title: '文章管理'},
                name: 'articleManage',
                component: articleManage
            },

        ]
    }


]

const router = new VueRouter({
    mode: 'history',
    routes
})

export default router
