初始化

This commit is contained in:
2026-04-02 23:40:04 +08:00
commit 381ea7085d
107 changed files with 11858 additions and 0 deletions
+67
View File
@@ -0,0 +1,67 @@
import { createRouter, createWebHistory } from 'vue-router'
import Layout from '../components/Layout.vue'
import { useAuthStore } from '../stores/auth'
const routes = [
{
path: '/login',
name: 'Login',
component: () => import('../views/Login.vue')
},
{
path: '/callback',
name: 'Callback',
component: () => import('../views/Callback.vue')
},
{
path: '/',
component: Layout,
redirect: '/dashboard',
meta: { requiresAuth: true },
children: [
{
path: '/dashboard',
name: 'Dashboard',
component: () => import('../views/Dashboard.vue')
},
{
path: '/devices',
name: 'DeviceList',
component: () => import('../views/DeviceList.vue')
},
{
path: '/import',
name: 'ImportData',
component: () => import('../views/ImportData.vue')
},
{
path: '/charts',
name: 'Charts',
component: () => import('../views/Charts.vue')
},
{
path: '/olt',
name: 'OltManage',
component: () => import('../views/OltManage.vue')
}
]
}
]
const router = createRouter({
history: createWebHistory(),
routes
})
router.beforeEach((to, from, next) => {
const authStore = useAuthStore()
if (to.meta.requiresAuth && !authStore.token) {
next('/login')
} else if (to.path === '/login' && authStore.token) {
next('/dashboard')
} else {
next()
}
})
export default router