import Vue from 'vue'
import Router from 'vue-router'
import Layout from '@/pages/layout'
import Login from '@/pages/login'
import Message from '@/pages/message'
import UserAnalysis from '@/pages/user-analysis'
import Display from '@/pages/display'
import Information from '@/pages/information'
import CulturalRelic from '@/pages/cultural-relic'
import Questionnaire from '@/pages/questionnaire'
import WorkLog from '@/pages/work-log'
import Modify from '@/pages/modify'
import Role from '@/pages/role'

import editInformation from '@/pages/editPages/message'
import editDisplay from '@/pages/editPages/display'
import editCulturalRelic from '@/pages/editPages/cultural-relic'
import editQuestionnaire from '@/pages/editPages/questionnaire'
import editRole from '@/pages/editPages/role'

import showCulturalRelic from '@/pages/showPages/cultural-relic'

import User from '@/pages/user'

import Home from '@/pages/home'

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

export default new Router({
  routes: [
    {
      path: '/',
      // name: 'mainLayout',
      component: Layout,
      children: [
        {
          path: '/',
          name: 'home',
          component: Home,
          meta: {index: -1}
        },
        {
          path: '/message',
          name: 'message',
          component: Message,
          meta: {index: 0}
        },

        {
          path: '/user-analysis',
          name: 'user-analysis',
          component: UserAnalysis,
          meta: {index: 1}
        }, {
          path: '/display',
          name: 'display',
          component: Display,
          meta: {index: 3}
        },
        {
          path: '/edit-display/:type/:id',
          name: 'edit-display',
          component: editDisplay,
          meta: {index: 3}
        },
        {
          path: '/information',
          name: 'information',
          component: Information,
          meta: {index: 2}
        },
        {
          path: '/edit-information/:type',
          name: 'edit-information',
          component: editInformation,
          meta: {index: 2}
        },
        {
          path: '/cultural-relic',
          name: 'cultural-relic',
          component: CulturalRelic,
          meta: {index: 4}
        },
        {
          path: '/edit-cultural-relic/:type',
          name: 'edit-cultural-relic',
          component: editCulturalRelic,
          meta: {index: 4}
        },
        {
          path: '/show-cultural-relic/:id',
          name: 'show-cultural-relic',
          component: showCulturalRelic,
          meta: {index: 4}
        },
        {
          path: '/questionnaire',
          name: 'questionnaire',
          component: Questionnaire,
          meta: {index: 5}
        },
        {
          path: '/edit-questionnaire',
          name: 'edit-questionnaire',
          component: editQuestionnaire,
          meta: {index: 5}
        }, {
          path: '/user',
          name: 'user',
          component: User,
          meta: {index: 6}
        }, {
          path: '/work-log',
          name: 'work-log',
          component: WorkLog,
          meta: {index: 7}
        }, {
          path: '/modify',
          name: 'modify',
          component: Modify,
          meta: {index: 8}
        }, {
          path: '/role',
          name: 'role',
          component: Role,
          meta: {index: 9}
        }, {
          path: '/edit-role/:type/:id',
          name: 'edit-role',
          component: editRole,
          meta: {index: 9}
        }]
    },
    {
      path: '/login',
      name: 'login',
      component: Login
    }
  ]
})
