新增 Web 浏览端(Go+Vue 报表系统)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
fish
2026-05-03 14:34:50 +08:00
parent bf8f578761
commit 750584e619
47 changed files with 2557 additions and 18 deletions

View File

@@ -0,0 +1,48 @@
import { createRouter, createWebHistory, type RouteRecordRaw } from 'vue-router'
import { useAuthStore } from '@/stores/auth'
const routes: RouteRecordRaw[] = [
{
path: '/login',
name: 'login',
component: () => import('@/views/LoginView.vue'),
meta: { layout: 'blank', public: true },
},
{ path: '/', redirect: '/scores' },
{
path: '/scores',
name: 'scores',
component: () => import('@/views/ScoresView.vue'),
},
{
path: '/chart',
name: 'chart',
component: () => import('@/views/ChartView.vue'),
},
{
path: '/admin/users',
name: 'admin-users',
component: () => import('@/views/AdminUsersView.vue'),
meta: { adminOnly: true },
},
{ path: '/:pathMatch(.*)*', redirect: '/scores' },
]
const router = createRouter({
history: createWebHistory(),
routes,
})
router.beforeEach((to) => {
const auth = useAuthStore()
if (to.meta.public) return true
if (!auth.token) {
return { path: '/login', query: { redirect: to.fullPath } }
}
if (to.meta.adminOnly && !auth.isAdmin) {
return { path: '/scores' }
}
return true
})
export default router