// import something here // import { isEqual } from 'lodash' // import { ProgressBar } from '@/store/Modules/Interface' // import { UserStore } from "@store" // @ts-ignore import { boot } from 'quasar/wrappers' import { useGlobalStore } from '@/store/globalStore'; import { useUserStore } from '@/store/UserStore'; import { tools } from '@/store/Modules/tools'; export default boot(({ app, router }) => { // ****************************************** // *** Per non permettere di accedere alle pagine in cui รจ necessario essere Loggati ! *** // ****************************************** // Creates a `nextMiddleware()` function which not only // runs the default `next()` callback but also triggers // the subsequent Middleware function. router.beforeEach((to, from, next) => { console.log('beforeEach ROUTER', from, to ) // Execute your command before each navigation // executeCommand(); const globalStore = useGlobalStore() const userStore = useUserStore() try { if (userStore.isLogged && from.path !== to.path) { // console.log('globalStore.editOn = false (prima era = ', globalStore.editOn, ')') const pageKey = to.path // console.log('pagek=', pageKey) globalStore.editOn = tools.getCookie('edn_' + pageKey, '0') === '1' } } catch(e) { } next() /* const answer = window.confirm('Do you really want to leave? you have unsaved changes!') if (answer) { next() } else { next(false) } */ //if (to.matched.some(record => record.meta.requiresAuth) && !userStore.isLogged) { // next({ name: 'login', query: { next: to.fullPath } }) //} else { // next() //} // Continue with the navigation }); /* router.beforeEach((to, from, next) => { var accessToken = store.state.session.userSession.accessToken // ESTANDO LOGEADO if (accessToken) { // SE PERMITE IR DE AREA PUBLICA A PRIVADA if (!from.matched.some(record => record.meta.requiresAuth) && to.matched.some(record => record.meta.requiresAuth)) { next() } // SE PERMITE IR DE UNA AREA PRIVADA A OTRA PRIVADA if (from.matched.some(record => record.meta.requiresAuth) && to.matched.some(record => record.meta.requiresAuth)) { next() } // NO SE PERMITE IR A UN AREA PUBLICA DESDE UN AREA PRIVADA if (from.matched.some(record => record.meta.requiresAuth) && !to.matched.some(record => record.meta.requiresAuth)) { next(false) } // SE REDIRIJE AL PANEL if (!from.matched.some(record => record.meta.requiresAuth) && !to.matched.some(record => record.meta.requiresAuth)) { next('/Panel') } // NO ESTA LOGEADO } else { // SE PERMITE IR DE UNA AREA PUBLICA A OTRA PUBLICA if (!from.matched.some(record => record.meta.requiresAuth) && !to.matched.some(record => record.meta.requiresAuth)) { next() } // SE PERMITE IR DE UNA AREA PRIVADA A UNA PUBLICA (LOGOUT) if (from.matched.some(record => record.meta.requiresAuth) && !to.matched.some(record => record.meta.requiresAuth)) { next() } // NO SE PERMITE IR DE UNA AREA PUBLICA A UNA PRIVADA if (!from.matched.some(record => record.meta.requiresAuth) && to.matched.some(record => record.meta.requiresAuth)) { // REDIRIGIR A LOGIN next('/') } } }) */ })