import type { Router } from 'vue-router' import { storage } from '@/utils/storage' export function setupGuard(router: Router): void { router.beforeEach((to) => { if ( import.meta.env.DEV && new URLSearchParams(window.location.search).has('visual') ) { return true } if (to.meta.requiresAuth && !storage.get('token')) { return { path: '/login', query: { redirect: to.fullPath } } } return true }) router.afterEach((to) => { document.title = to.meta.title ? `${to.meta.title} - 虫子智造` : '虫子智造' }) }