Mercurial > gemma
view client/src/router.js @ 23:c1ef0be0ae3d
Improve build chain
In order to improve the build, there is the need to include external
asset during build time.
The variable `VUE_APP_VENDOR_IMG_PATH` defines the source folder of
the vendor images.
The destination folder is /web/img/.
To improve readability comments to .env.sample variables were added.
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Thu, 21 Jun 2018 13:39:01 +0200 |
parents | 88d0d60924cf |
children | 7ba0a77fd679 |
line wrap: on
line source
import Vue from "vue"; import Router from "vue-router"; import Login from "./views/Login.vue"; import Main from "./views/Main.vue"; import store from "./store"; Vue.use(Router); const router = new Router({ routes: [ { path: "/login", name: "login", component: Login }, { path: "/", name: "main", component: Main, meta: { requiresAuth: true } }, { path: "*", component: Login } ] }); router.beforeEach((to, from, next) => { const requiresAuth = to.matched.some(record => record.meta.requiresAuth); const currentUser = store.getters["user/authenticated"]; if (requiresAuth && !currentUser) { next("/login"); } else if (requiresAuth && currentUser) { next(); } else { next(); } }); export default router;