import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Layout',
    component: () => import('../views/layout/index.vue'),
    redirect: { name: 'Home' },
    children: [
      {
        path: '/Layout/Home',
        name: 'Home',
        component: () => import('../views/Home/index.vue'),
        meta: { myName: 'Home' },
      },
      // Visit页面
      {
        path: '/Layout/Visit',
        name: 'Visit',
        component: () => import('../views/Visit/index.vue'),
        meta: { myName: 'Visit' },
        redirect: { name: 'Visit1' },
        children: [
          {
            path: '/Layout/Visit/1',
            name: 'Visit1',
            component: () => import('../views/Visit/Visit1.vue'),
            meta: { myName: 'Visit', nameAll: 'Hours, Direction & Admission' },
          },
          {
            path: '/Layout/Visit/2',
            name: 'Visit2',
            component: () => import('../views/Visit/Visit2.vue'),
            meta: { myName: 'Visit', nameAll: 'Reservation' },
          },
          {
            path: '/Layout/Visit/3',
            name: 'Visit3',
            component: () => import('../views/Visit/Visit3.vue'),
            meta: { myName: 'Visit', nameAll: 'Floor Plans' },
          },
          {
            path: '/Layout/Visit/4',
            name: 'Visit4',
            component: () => import('../views/Visit/Visit4.vue'),
            meta: { myName: 'Visit', nameAll: 'Audio Guide & Tour' },
          },
          {
            path: '/Layout/Visit/5',
            name: 'Visit5',
            component: () => import('../views/Visit/Visit5.vue'),
            meta: { myName: 'Visit', nameAll: 'Accessibility' },
          },
          {
            path: '/Layout/Visit/6',
            name: 'Visit6',
            component: () => import('../views/Visit/Visit6.vue'),
            meta: { myName: 'Visit', nameAll: 'Café & Shop' },
          },
          {
            path: '/Layout/Visit/7',
            name: 'Visit7',
            component: () => import('../views/Visit/Visit7.vue'),
            meta: { myName: 'Visit', nameAll: 'Visitor Guidelines' },
          },
        ]
      },
      // 列表Exhibitions页面
      {
        path: '/Layout/Exhibitions/:id',
        name: 'Exhibitions',
        component: () => import('../views/Exhibitions/index.vue'),
        meta: { myName: 'Exhibitions' },
      },
      // 列表Exhibitions详情页面
      {
        path: '/Layout/ExhibitionsInfo',
        name: 'ExhibitionsInfo',
        component: () => import('../views/Exhibitions/info.vue'),
        meta: { myName: 'Exhibitions' },
      },
    ]
  }
]

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

// 导航守卫，回到页面顶部
router.beforeEach((to, from, next) => {
  document.documentElement.scrollTop = 0
  next()
})

export default router
