import { createApp } from 'vue' import { createRouter, createWebHashHistory } from 'vue-router' import { routes, handleHotUpdate } from 'vue-router/auto-routes' import { i18n, setLocale, initialLocale } from './i18n.js' import './css/all.css' import App from './app.vue' import { isLogedIn } from './global.js' await setLocale(initialLocale()) const router = createRouter({ history: createWebHashHistory(), routes, }) if (import.meta.hot) { handleHotUpdate(router) } router.beforeEach(async (to, from) => { if (!isLogedIn.value && to.name != '/login' ) { // redirect the user to the login page return { name: '/login' } } }) createApp(App).use(router).use(i18n).mount('#app')