Refactor components. Improve design. Improve routing

This commit is contained in:
2023-11-17 17:15:37 -05:00
parent cbe4b5323e
commit f2d4ce12d4
17 changed files with 278 additions and 146 deletions

View File

@@ -35,13 +35,18 @@ export default route(function (/* { store, ssrContext } */) {
history: createHistory(process.env.VUE_ROUTER_BASE),
});
Router.beforeEach(async (to, from, next) => {
Router.beforeEach((to) => {
const auth = useAuthStore();
return !to.meta.accountRoute && !auth.currentUser
? next({ name: 'login' })
: to.meta.accountRoute && auth.currentUser
? next({ name: 'index' })
: next();
if (!auth.ready) {
return false;
}
if (auth.currentUser) {
return to.meta.accountRoute ? { name: 'index' } : true;
} else {
return to.name == 'login' ? true : { name: 'login' };
}
});
return Router;