login+ai cluster

This commit is contained in:
stardrophere
2026-03-11 01:33:21 +08:00
parent 9fa07cfb07
commit 8ed819a580
39 changed files with 3392 additions and 610 deletions
+43 -7
View File
@@ -1,5 +1,10 @@
import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import { pinia } from '@/stores'
import { useAuthStore } from '@/stores/auth'
import HomeView from '@/views/HomeView.vue'
import LoginView from '@/views/LoginView.vue'
import RegisterView from '@/views/RegisterView.vue'
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
@@ -8,16 +13,47 @@ const router = createRouter({
path: '/',
name: 'home',
component: HomeView,
meta: {
requiresAuth: true,
},
},
{
path: '/about',
name: 'about',
// route level code-splitting
// this generates a separate chunk (About.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import('../views/AboutView.vue'),
path: '/login',
name: 'login',
component: LoginView,
meta: {
guestOnly: true,
},
},
{
path: '/register',
name: 'register',
component: RegisterView,
meta: {
guestOnly: true,
},
},
],
})
router.beforeEach((to) => {
const authStore = useAuthStore(pinia)
authStore.restore()
if (to.meta.requiresAuth && !authStore.isAuthenticated) {
return {
name: 'login',
query: {
redirect: to.fullPath,
},
}
}
if (to.meta.guestOnly && authStore.isAuthenticated) {
return { name: 'home' }
}
return true
})
export default router