feat(web): prompt-templates view + chat/admin routes + nav + isAdmin guard

This commit is contained in:
2026-05-04 20:15:49 +08:00
parent 372af06b01
commit ff283013da
4 changed files with 284 additions and 1 deletions
+59
View File
@@ -62,6 +62,62 @@ const routes: RouteRecordRaw[] = [
component: () => import('@/views/workspaces/WorkspaceHomeView.vue'),
meta: { requiresAuth: true },
},
{
path: '/chat',
name: 'chat-home',
component: () => import('@/views/chat/ChatHomeView.vue'),
meta: { requiresAuth: true },
},
{
path: '/chat/:conversationId',
name: 'chat-detail',
component: () => import('@/views/chat/ChatDetailView.vue'),
meta: { requiresAuth: true },
},
{
path: '/projects/:pid/chat',
name: 'project-chat-home',
component: () => import('@/views/chat/ChatHomeView.vue'),
meta: { requiresAuth: true },
},
{
path: '/projects/:pid/chat/:conversationId',
name: 'project-chat-detail',
component: () => import('@/views/chat/ChatDetailView.vue'),
meta: { requiresAuth: true },
},
{
path: '/prompt-templates',
name: 'prompt-templates',
component: () =>
import('@/views/prompt-templates/PromptTemplatesView.vue'),
meta: { requiresAuth: true },
},
{
path: '/me/usage',
name: 'me-usage',
component: () => import('@/views/admin/UsageView.vue'),
meta: { requiresAuth: true },
},
{
path: '/admin/llm-endpoints',
name: 'admin-llm-endpoints',
component: () => import('@/views/admin/LLMEndpointsView.vue'),
meta: { requiresAuth: true, requiresAdmin: true },
},
{
path: '/admin/llm-models',
name: 'admin-llm-models',
component: () => import('@/views/admin/LLMModelsView.vue'),
meta: { requiresAuth: true, requiresAdmin: true },
},
{
path: '/admin/usage',
name: 'admin-usage',
component: () => import('@/views/admin/UsageView.vue'),
props: { adminMode: true },
meta: { requiresAuth: true, requiresAdmin: true },
},
]
const router = createRouter({
@@ -74,6 +130,9 @@ router.beforeEach((to) => {
if (to.meta.requiresAuth && !auth.isAuthenticated) {
return { name: 'login', query: { next: to.fullPath } }
}
if (to.meta.requiresAdmin && !auth.isAdmin) {
return { name: 'home' }
}
if (to.name === 'login' && auth.isAuthenticated) {
return { name: 'home' }
}