refactor: code organization

This commit is contained in:
2024-10-23 15:23:33 +02:00
parent 018357c5ed
commit 5a32c96a88
29 changed files with 1134 additions and 615 deletions
+5 -17
View File
@@ -4,26 +4,14 @@ import App from './App.vue';
import router from './router';
import { createPinia } from 'pinia';
import { useStore } from './store';
import { createRouteGuard } from './routeGuard';
const pinia = createPinia();
const app = createApp(App);
app.use(pinia).use(router);
app.use(pinia);
app.use(router);
app.mount('#app');
router.beforeEach((to, from, next) => {
const store = useStore();
if (to.meta.protected && !store.user && !window.localStorage.getItem('user')) {
next('/login');
return;
}
if (to.meta.loginPage && window.localStorage.getItem('user')) {
next('/');
return;
}
next();
});
// Route guard
createRouteGuard(router);