big update

This commit is contained in:
stardrophere
2026-03-11 20:52:58 +08:00
parent 8ed819a580
commit 966bcfbba4
44 changed files with 7124 additions and 650 deletions
+35 -22
View File
@@ -2,36 +2,54 @@ import { createRouter, createWebHistory } from 'vue-router'
import { pinia } from '@/stores'
import { useAuthStore } from '@/stores/auth'
import HomeView from '@/views/HomeView.vue'
import DashboardLayout from '@/layouts/DashboardLayout.vue'
import LoginView from '@/views/LoginView.vue'
import RegisterView from '@/views/RegisterView.vue'
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: '/',
name: 'home',
component: HomeView,
meta: {
requiresAuth: true,
},
},
// 认证页面(不使用仪表盘布局)
{
path: '/login',
name: 'login',
component: LoginView,
meta: {
guestOnly: true,
},
meta: { guestOnly: true },
},
{
path: '/register',
name: 'register',
component: RegisterView,
meta: {
guestOnly: true,
},
meta: { guestOnly: true },
},
// 仪表盘内部页面(使用统一侧边栏布局)
{
path: '/',
component: DashboardLayout,
meta: { requiresAuth: true },
children: [
{
path: '',
name: 'dashboard',
component: () => import('@/views/DashboardView.vue'),
},
{
path: 'revisions',
name: 'revisions',
component: () => import('@/views/RevisionsView.vue'),
},
{
path: 'topics',
name: 'topics',
component: () => import('@/views/TopicsView.vue'),
},
{
path: 'delivery',
name: 'delivery',
component: () => import('@/views/DeliveryView.vue'),
},
],
},
],
})
@@ -41,16 +59,11 @@ router.beforeEach((to) => {
authStore.restore()
if (to.meta.requiresAuth && !authStore.isAuthenticated) {
return {
name: 'login',
query: {
redirect: to.fullPath,
},
}
return { name: 'login', query: { redirect: to.fullPath } }
}
if (to.meta.guestOnly && authStore.isAuthenticated) {
return { name: 'home' }
return { name: 'dashboard' }
}
return true