update
All checks were successful
Build Multi-Platform Binaries / build (push) Successful in 11m54s

This commit is contained in:
Flik
2025-12-26 17:14:54 +08:00
parent 4623a7f031
commit 549f9aaf26
63 changed files with 10266 additions and 740 deletions

View File

@@ -1,8 +1,15 @@
import { createRouter, createWebHistory } from 'vue-router'
import { getToken } from '../api'
const router = createRouter({
history: createWebHistory(),
routes: [
{
path: '/login',
name: 'login',
component: () => import('../views/LoginView.vue'),
meta: { public: true },
},
{
path: '/',
name: 'home',
@@ -13,7 +20,24 @@ const router = createRouter({
name: 'client',
component: () => import('../views/ClientView.vue'),
},
{
path: '/plugins',
name: 'plugins',
component: () => import('../views/PluginsView.vue'),
},
],
})
// 路由守卫
router.beforeEach((to, _from, next) => {
const token = getToken()
if (!to.meta.public && !token) {
next('/login')
} else if (to.path === '/login' && token) {
next('/')
} else {
next()
}
})
export default router