Reorganize the frontend around app-level routing and page modules so the runtime and feature screens share a clearer navigation and composition layout for future work. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
22 lines
495 B
TypeScript
22 lines
495 B
TypeScript
import { createRouter, createWebHistory } from 'vue-router'
|
|
import { useAuthStore } from '@/stores/auth'
|
|
import { routes } from '@/app/router/routes'
|
|
|
|
const router = createRouter({
|
|
history: createWebHistory(),
|
|
routes,
|
|
})
|
|
|
|
router.beforeEach((to, _from, next) => {
|
|
const auth = useAuthStore()
|
|
if (to.meta.requiresAuth && !auth.isAuthenticated) {
|
|
next('/login')
|
|
} else if (to.meta.guest && auth.isAuthenticated) {
|
|
next('/chat')
|
|
} else {
|
|
next()
|
|
}
|
|
})
|
|
|
|
export default router
|