import Vue from 'vue'
import VueRouter from 'vue-router'
import routes from './routes'
import store from '@/store'

Vue.use(VueRouter)

const router = new VueRouter({
  // mode: 'history', // this allow all routes to be real ones (without '#')
  base: process.env.BASE_URL,
  routes
})

router.beforeEach((to, from, next) => {
  // Allow if connected or route is not protected
  if (store.getters.connected || to.meta.noAuth) {
    next()
  } else {
    store.dispatch('DISCONNECT', to)
    // next({ name: 'login', query: { redirect: to.path } })
  }
})

export default router

@@ -275,16 +275,710 @@
   routes
+,%0A%0A  scrollBehavior (to, from, savedPosition) %7B%0A    // Mimics the native scroll behavior of the browser.%0A    // This allows the user to find his way back to the scroll level of the previous/next route.%0A%0A    // if animations are enabled, we need to delay a bit the returned value of the saved%0A    // scroll state because the component probably hasn't updated the window height yet.%0A    // Note: this will only work with routes that use stored data or that has static content%0A    if (store.getters.transitions && savedPosition) %7B%0A      return new Promise(resolve =%3E %7B%0A        setTimeout(() =%3E resolve(savedPosition), 0)%0A      %7D)%0A    %7D else %7B%0A      return savedPosition %7C%7C %7B x: 0, y: 0 %7D%0A    %7D%0A  %7D
 %0A%7D)%0A%0Arou
@@ -1178,69 +1178,8 @@
 to)%0A
-    // next(%7B name: 'login', query: %7B redirect: to.path %7D %7D)%0A
   %7D%0A

add rooter restore scroll state when using navigator return/next buttons