1. 前端改为vue单体程序

2. 增加设备管理相关接口
This commit is contained in:
2025-09-08 18:16:40 +08:00
parent e5383ce268
commit 7112a16ca8
853 changed files with 546690 additions and 620 deletions

View File

@@ -0,0 +1,50 @@
import { createRouter, createWebHistory } from 'vue-router'
import Login from '../pages/Login.vue'
import Dashboard from '../pages/Dashboard.vue'
import Device from '../pages/Device.vue'
const routes = [
{
path: '/',
name: 'Login',
component: Login
},
{
path: '/dashboard',
name: 'Dashboard',
component: Dashboard,
meta: { requiresAuth: true }
},
{
path: '/device',
name: 'Device',
component: Device,
meta: { requiresAuth: true }
}
]
const router = createRouter({
history: createWebHistory(),
routes
})
// 路由守卫
router.beforeEach((to, from, next) => {
const token = localStorage.getItem('authToken')
if (to.matched.some(record => record.meta.requiresAuth)) {
if (!token) {
next('/')
} else {
next()
}
} else {
if (token && to.name === 'Login') {
next('/dashboard')
} else {
next()
}
}
})
export default router