|
@ -7,13 +7,19 @@ const routes: Array<RouteRecordRaw> = [ |
|
|
name: "home", |
|
|
name: "home", |
|
|
component: () => |
|
|
component: () => |
|
|
import(/* webpackChunkName: "start" */ "../views/DiscoverView.vue"), |
|
|
import(/* webpackChunkName: "start" */ "../views/DiscoverView.vue"), |
|
|
|
|
|
beforeEnter: (to, from, next) => { |
|
|
|
|
|
const appStore = useAppStore(); |
|
|
|
|
|
const isAuthenticated = appStore.condition === "registered"; |
|
|
|
|
|
if (isAuthenticated) { |
|
|
|
|
|
next(); |
|
|
|
|
|
} else { |
|
|
|
|
|
next({ name: "start" }); |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
path: "/about", |
|
|
path: "/about", |
|
|
name: "about", |
|
|
name: "about", |
|
|
// route level code-splitting
|
|
|
|
|
|
// this generates a separate chunk (about.[hash].js) for this route
|
|
|
|
|
|
// which is lazy-loaded when the route is visited.
|
|
|
|
|
|
component: () => |
|
|
component: () => |
|
|
import(/* webpackChunkName: "about" */ "../views/AboutView.vue"), |
|
|
import(/* webpackChunkName: "about" */ "../views/AboutView.vue"), |
|
|
}, |
|
|
}, |
|
@ -75,6 +81,12 @@ const routes: Array<RouteRecordRaw> = [ |
|
|
/* webpackChunkName: "new-edit-commitment" */ "../views/NewEditCommitmentView.vue" |
|
|
/* webpackChunkName: "new-edit-commitment" */ "../views/NewEditCommitmentView.vue" |
|
|
), |
|
|
), |
|
|
}, |
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
path: "/project", |
|
|
|
|
|
name: "project", |
|
|
|
|
|
component: () => |
|
|
|
|
|
import(/* webpackChunkName: "project" */ "../views/ProjectViewView.vue"), |
|
|
|
|
|
}, |
|
|
{ |
|
|
{ |
|
|
path: "/new-edit-project", |
|
|
path: "/new-edit-project", |
|
|
name: "new-edit-project", |
|
|
name: "new-edit-project", |
|
@ -83,12 +95,6 @@ const routes: Array<RouteRecordRaw> = [ |
|
|
/* webpackChunkName: "new-edit-project" */ "../views/NewEditProjectView.vue" |
|
|
/* webpackChunkName: "new-edit-project" */ "../views/NewEditProjectView.vue" |
|
|
), |
|
|
), |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
|
|
|
path: "/project", |
|
|
|
|
|
name: "project", |
|
|
|
|
|
component: () => |
|
|
|
|
|
import(/* webpackChunkName: "project" */ "../views/ProjectViewView.vue"), |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
{ |
|
|
path: "/projects", |
|
|
path: "/projects", |
|
|
name: "projects", |
|
|
name: "projects", |
|
@ -111,27 +117,4 @@ const router = createRouter({ |
|
|
routes, |
|
|
routes, |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
router.beforeEach(async (to, from, next) => { |
|
|
|
|
|
const publicPages = ["/start", "/account", "/import-account"]; |
|
|
|
|
|
const isPublic = publicPages.includes(to.path); |
|
|
|
|
|
const appStore = useAppStore(); |
|
|
|
|
|
console.log(to); |
|
|
|
|
|
if (to.path === "/" && appStore.condition === "registered") { |
|
|
|
|
|
next({ path: "/account" }); |
|
|
|
|
|
} else if (isPublic) { |
|
|
|
|
|
switch (appStore.condition) { |
|
|
|
|
|
case "registered": |
|
|
|
|
|
next(); |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
next(); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} else if (appStore.condition === "uninitialized") { |
|
|
|
|
|
next({ path: "/start" }); |
|
|
|
|
|
} else { |
|
|
|
|
|
next(); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
export default router; |
|
|
export default router; |
|
|