import Vue from 'vue'
import VueRouter from 'vue-router'
import frontRoute from './front.js'

Vue.use(VueRouter)

let constantRoutes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/Forestage/login/login.vue')
  },
  {
    path: '/register',
    name: 'register',
    component: () => import('@/views/Forestage/login/register.vue')
  },
  {
    path: '/forget-password',
    name: 'forget-password',
    component: () => import('@/views/Forestage/login/forget-password.vue')
  },
]
let routes = [...constantRoutes,...frontRoute]

const router = new VueRouter({
  routes
})

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}
router.afterEach(() => {
  document.body.scrollTop = 0
  document.documentElement.scrollTop = 0
})
export default router
