Refactor components. Improve design. Improve routing
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -35,4 +35,10 @@ export const links = [
|
||||
icon: 'info_outline',
|
||||
front_links: true,
|
||||
},
|
||||
{
|
||||
name: 'Tasks',
|
||||
to: 'task',
|
||||
icon: 'build',
|
||||
front_links: true,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -25,6 +25,11 @@ const routes: RouteRecordRaw[] = [
|
||||
component: () => import('pages/CertificationPage.vue'),
|
||||
name: 'certification',
|
||||
},
|
||||
{
|
||||
path: '/task',
|
||||
component: () => import('pages/TaskPage.vue'),
|
||||
name: 'task',
|
||||
},
|
||||
{
|
||||
path: '/checklist',
|
||||
component: () => import('pages/ChecklistPage.vue'),
|
||||
@@ -63,7 +68,7 @@ const routes: RouteRecordRaw[] = [
|
||||
component: () => import('pages/LoginPage.vue'),
|
||||
name: 'login',
|
||||
meta: {
|
||||
accountRoute: true,
|
||||
publicRoute: true,
|
||||
},
|
||||
},
|
||||
// {
|
||||
|
||||
Reference in New Issue
Block a user