import Vue from 'vue'
import VueRouter from 'vue-router'
import City from '@/views/city/index.vue'
import Area from '@/views/area/index.vue'
import Build from '@/views/build/index.vue'
import Main from '@/views/main/index.vue'
import { DefaultLayout } from '@/layouts'

Vue.use(VueRouter)

const address = [
  {
    label: '重庆市',
    path: '/city'
  },
  {
    label: '北碚区',
    path: '/area'
  },
  {
    label: '北碚区万达广场',
    path: '/build'
  }
]

const routes = [
  {
    // 主页
    path: '/',
    name: 'Main',
    component: Main,
  },
  {
    // 重庆子页
    path: '/chongqing',
    redirect: '/city',
    component: DefaultLayout,
    children: [
      {
        path: '/city',
        name: 'City',
        component: City,
        meta: {
          address,
          index: 0
        }
      },
      {
        path: '/area',
        name: 'Area',
        meta: {
          address,
          index: 1
        },
        component: Area
      },
      {
        path: '/build',
        name: 'Build',
        meta: {
          address,
          index: 2
        },
        component: Build
      }
    ]
  }
]

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

export default router
