2026-04-21 22:07:29 +08:00
|
|
|
import { createRouter, createWebHistory } from 'vue-router'
|
|
|
|
|
|
|
|
|
|
const router = createRouter({
|
2026-04-24 10:42:11 +08:00
|
|
|
history: createWebHistory(import.meta.env.BASE_URL),
|
2026-04-21 22:07:29 +08:00
|
|
|
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
|