import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/Home/Home'

Vue.use(VueRouter)

const routes = [
  {
    path: '/welcome',
    name: 'welcome',
    component: ()=>import('../views/signAndResiger/welcome')
  },
  {
    path: '/login',
    name: 'login',
    component: ()=>import('../views/signAndResiger/login')
  },{
    path: '/resiger',
    name: 'resiger',
    component: ()=>import('../views/signAndResiger/resiger')
  },{
    path: '/voteDetial',
    name: 'voteDetial',
    component: ()=>import('../views/fuzhu/voteDetial')
  },{
    path: '/meetingDetial',
    name: 'meetingDetial',
    component: ()=>import('../views/fuzhu/meetingDetial')
  },{
    path: '/binding',
    name: 'binding',
    component: ()=>import('../views/signAndResiger/binding')
  },{
    path: '/newsPage',
    name: 'newsPage',
    component: ()=>import('../views/fuzhu/newsPage')
  },{
    path: '/announcementList',
    name: 'announcementList',
    component: ()=>import('../views/fuzhu/announcementList')
  },{
    path: '/meetingList',
    name: 'meetingList',
    component: ()=>import('../views/fuzhu/meetingList')
  },{
    path: '/voteModel',
    name: 'voteModel',
    component: ()=>import('../views/fuzhu/voteModel')
  },
  {
    path: '/Main',
    name: 'Main',
    component: ()=>import('../views/Home/Main'),
    children:[
      {
        path: '/home',
        name: 'home',
        component: HomeView
      },
      {
        path: '/my',
        name: 'my',
        component: ()=>import('../views/Home/my')
      },
    ]
  },
]

const router = new VueRouter({
  routes
})
router.beforeEach((to,from,next)=>{
  if(to.path=='/'){
    next('/welcome')
  }else{
    next()
  }
})

export default router
