Enhance backend functionality and frontend UI

- Updated main.py to include authentication for brand, model, and OTA routers.
- Added new OTA schemas in schemas.py for version management.
- Enhanced model retrieval with sorting options in models.py.
- Improved model update functionality to support multipart/form-data uploads.
- Updated frontend layout and styles for a more modern look, including new font integration.
- Implemented login route and authentication checks in router/index.js.
- Added sorting capabilities in model table and improved file handling in model view.
- Updated requirements.txt to include PyJWT for token management.
This commit is contained in:
yangy
2026-05-14 17:54:36 +08:00
parent b1d088a755
commit 661b85ce62
23 changed files with 2104 additions and 119 deletions
+35
View File
@@ -1,10 +1,18 @@
import { createRouter, createWebHistory } from 'vue-router'
import Layout from '@/layout/index.vue'
import { getToken, clearToken, isTokenExpired } from '@/utils/auth'
const routes = [
{
path: '/login',
name: 'Login',
component: () => import('@/views/login/index.vue'),
meta: { requiresAuth: false }
},
{
path: '/',
component: Layout,
meta: { requiresAuth: true },
redirect: '/brand',
children: [
{
@@ -18,6 +26,12 @@ const routes = [
name: 'Model',
component: () => import('@/views/model/index.vue'),
meta: { title: '型号管理', icon: 'list' }
},
{
path: '/ota',
name: 'Ota',
component: () => import('@/views/ota/index.vue'),
meta: { title: 'OTA 管理', icon: 'upload' }
}
]
}
@@ -28,4 +42,25 @@ const router = createRouter({
routes
})
router.beforeEach((to, _from, next) => {
const needAuth = to.matched.some((r) => r.meta && r.meta.requiresAuth === true)
const token = getToken()
if (needAuth) {
if (!token || isTokenExpired(token)) {
if (token) clearToken()
next({ path: '/login', query: { redirect: to.fullPath } })
return
}
}
if (to.path === '/login' && token && !isTokenExpired(token)) {
const redirect = to.query.redirect
next(typeof redirect === 'string' && redirect ? redirect : '/')
return
}
next()
})
export default router