import Vue from 'vue'
import Router from 'vue-router'

// h5
const chatList = () => import('@/pages/h5/view/chatList.vue')
const aboutMe = () => import('@/pages/h5/view/aboutMe.vue')
const editMe = () => import('@/pages/h5/view/editMe.vue')
const h5ChatRoom = () => import('@/pages/h5/view/chatRoom.vue')

// pc
const pcChatRoom = () => import('@/components/chatRoom/chatRoom.vue')
const noChat = () => import('@/components/chatRoom/noChat.vue')

Vue.use(Router)

const pcRouter = new Router({
  routes: [{
    path: '/',
    alias: '/user/:id',
    name: 'noChat',
    component: noChat
  }, {
    path: '/group/:id',
    name: 'groupChat',
    component: pcChatRoom
  }, {
    path: '/pm/:id',
    name: 'pmChat',
    component: pcChatRoom
  }
  ]
})

const h5Router = new Router({
  routes: [{
    path: '/',
    alias: '/user/:id',
    name: 'chatList',
    component: chatList
  }, {
    path: '/me',
    name: 'aboutMe',
    component: aboutMe
  }, {
    path: '/editMe',
    name: 'editMe',
    component: editMe
  }, {
    path: '/group/:id',
    name: 'groupChat',
    component: h5ChatRoom
  }, {
    path: '/pm/:id',
    name: 'pmChat',
    component: h5ChatRoom
  }
  ]
})

// router.beforeEach((to, from, next) => {
//   // next()
//   let userId = $store.state.userId
//   let token = $store.state.token
//   if(userId && token)
// })

export {
  h5Router,
  pcRouter
}
