Sink/app/middleware/auth.global.ts
wudi 7cadbfe2b1 refactor: Migrate project files and directories to the app directory using the new compatibilityVersion: 4 feature
- Moved `app.config.ts` to the `app` directory
- Migrated `.vue` files and other assets to the `app` directory
- Updated import paths to reflect the new file locations
2025-03-24 11:05:59 +08:00

19 lines
454 B
TypeScript

export default defineNuxtRouteMiddleware(async (to) => {
if (import.meta.server)
return
if (to.path.startsWith('/dashboard') && to.path !== '/dashboard/login') {
if (!window.localStorage.getItem('SinkSiteToken'))
return navigateTo('/dashboard/login')
}
if (to.path === '/dashboard/login') {
try {
await useAPI('/api/verify')
return navigateTo('/dashboard')
}
catch (e) {
console.warn(e)
}
}
})