All files / router index.js

0% Statements 0/10
0% Branches 0/4
0% Functions 0/3
0% Lines 0/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36                                                                       
import Vue from "vue";
import VueRouter from "vue-router";
 
import routes from "./routes";
 
Vue.use(VueRouter);
 
/*
 * If not building with SSR mode, you can
 * directly export the Router instantiation
 */
 
export default function({ store } /*, ssrContext } */) {
  const Router = new VueRouter({
    scrollBehavior: () => ({ x: 0, y: 0 }),
    routes,
 
    // Leave these as is and change from quasar.conf.js instead!
    // quasar.conf.js -> build -> vueRouterMode
    // quasar.conf.js -> build -> publicPath
    mode: process.env.VUE_ROUTER_MODE,
    base: process.env.VUE_ROUTER_BASE
  });
 
  Router.beforeEach((to, from, next) => {
    console.log(to);
    console.log(store);
    if (to.path.startsWith("/account") && !store.getters["auth/user"]) {
      return next("/login");
    }
    return next();
  });
 
  return Router;
}