import Vue from 'vue'
import Router from 'vue-router'
import otherModuleRoutes from './module'

Vue.use(Router)

const routes = [{
  path: '/login',
  component: (resolve) => {
    import('@/pages/auth/Login.vue').then(resolve)
  },
  meta: {
    skipAuth: true
  }
}, {
  path: '/',
  component: (resolve) => {
    import('@/pages/CommonView.vue').then(resolve)
  },
  children: [...otherModuleRoutes, {
    path: '/', redirect: '/dashboard'
  }]
}, {
  path: '*',
  component: {
    render(h) {
      return h('div', {staticClass: 'flex flex-main-center', attrs: { style: 'width:100%;font-size:32px' }}, 'Page not found')
    }
  }
}]

const router = new Router({
  mode: 'hash',
  linkActiveClass: 'active',
  scrollBehavior: () => ({ y: 0 }),
  routes
})

export default router
