import { createRouter, createWebHistory } from 'vue-router' const router = createRouter({ history: createWebHistory(), routes: [ { path: '/login', component: () => import('@/views/auth/LoginView.vue') }, { path: '/', component: () => import('@/views/layout/MainLayout.vue'), meta: { requiresAuth: true }, children: [ { path: '', redirect: '/tenants' }, { path: 'tenants', component: () => import('@/views/tenants/TenantListView.vue') }, { path: 'statistics', component: () => import('@/views/statistics/StatisticsView.vue') }, ], }, ], }) router.beforeEach((to) => { const token = localStorage.getItem('ops_token') if (to.meta.requiresAuth && !token) return '/login' }) export default router