import type { Router } from 'vue-router' import { useUserStore } from '@/stores/user' export function setupLoginGuard(router: Router) { const webUser = useUserStore() router.beforeEach((to, from, next) => { if (webUser.getToken && to.path === '/login') { next('/') return } if(!webUser.getToken && to.path !== '/login') { next("/login"); return; } next(); }) }