35 lines
756 B
TypeScript
35 lines
756 B
TypeScript
import { useAuthStore } from "@/auth";
|
|
import { createPinia } from 'pinia';
|
|
import { createApp } from 'vue';
|
|
import { createRouter, createWebHistory } from 'vue-router';
|
|
import App from './App.vue';
|
|
import { initLogger } from './logger';
|
|
import { routes } from './routes';
|
|
import './style.css';
|
|
|
|
initLogger();
|
|
|
|
const app = createApp(App);
|
|
const pinia = createPinia();
|
|
const router = createRouter({
|
|
history: createWebHistory(),
|
|
routes,
|
|
});
|
|
|
|
app.use(pinia);
|
|
|
|
const authStore = useAuthStore();
|
|
|
|
router.beforeEach(async to => {
|
|
if (to.name === 'callback') {
|
|
await authStore.login();
|
|
return { name: 'home' };
|
|
} else if (!authStore.isLoggedIn) {
|
|
await authStore.redirect();
|
|
}
|
|
});
|
|
|
|
app.use(router);
|
|
|
|
app.mount('#app');
|