import { providePocketBase } from '@/pocketbase'; import { createApp } from 'vue'; import { createRouter, createWebHistory } from 'vue-router'; import App from './App.vue'; import { routes } from './routes'; import './style.css'; const app = createApp(App); const pb = providePocketBase(app); const router = createRouter({ history: createWebHistory(), routes, }); router.beforeEach(async to => { if (!pb.authStore.isValid && to.name !== 'login') { return { name: 'login' }; } else if (pb.authStore.isValid && to.name === 'login') { return { name: 'home' }; } }); app.use(router); app.mount('#app');