89f0127da6
* feat: add read-only plugins page * fix: align plugins page i18n and header
123 lines
3.0 KiB
TypeScript
123 lines
3.0 KiB
TypeScript
import { createRouter, createWebHashHistory } from 'vue-router'
|
|
import { hasApiKey } from '@/api/client'
|
|
|
|
const router = createRouter({
|
|
history: createWebHashHistory(),
|
|
routes: [
|
|
{
|
|
path: '/',
|
|
name: 'login',
|
|
component: () => import('@/views/LoginView.vue'),
|
|
meta: { public: true },
|
|
},
|
|
{
|
|
path: '/hermes/chat',
|
|
name: 'hermes.chat',
|
|
component: () => import('@/views/hermes/ChatView.vue'),
|
|
},
|
|
{
|
|
path: '/hermes/history',
|
|
name: 'hermes.history',
|
|
component: () => import('@/views/hermes/HistoryView.vue'),
|
|
},
|
|
{
|
|
path: '/hermes/jobs',
|
|
name: 'hermes.jobs',
|
|
component: () => import('@/views/hermes/JobsView.vue'),
|
|
},
|
|
{
|
|
path: '/hermes/kanban',
|
|
name: 'hermes.kanban',
|
|
component: () => import('@/views/hermes/KanbanView.vue'),
|
|
},
|
|
{
|
|
path: '/hermes/models',
|
|
name: 'hermes.models',
|
|
component: () => import('@/views/hermes/ModelsView.vue'),
|
|
},
|
|
{
|
|
path: '/hermes/profiles',
|
|
name: 'hermes.profiles',
|
|
component: () => import('@/views/hermes/ProfilesView.vue'),
|
|
},
|
|
{
|
|
path: '/hermes/logs',
|
|
name: 'hermes.logs',
|
|
component: () => import('@/views/hermes/LogsView.vue'),
|
|
},
|
|
{
|
|
path: '/hermes/usage',
|
|
name: 'hermes.usage',
|
|
component: () => import('@/views/hermes/UsageView.vue'),
|
|
},
|
|
{
|
|
path: '/hermes/skills',
|
|
name: 'hermes.skills',
|
|
component: () => import('@/views/hermes/SkillsView.vue'),
|
|
},
|
|
{
|
|
path: '/hermes/plugins',
|
|
name: 'hermes.plugins',
|
|
component: () => import('@/views/hermes/PluginsView.vue'),
|
|
},
|
|
{
|
|
path: '/hermes/memory',
|
|
name: 'hermes.memory',
|
|
component: () => import('@/views/hermes/MemoryView.vue'),
|
|
},
|
|
{
|
|
path: '/hermes/settings',
|
|
name: 'hermes.settings',
|
|
component: () => import('@/views/hermes/SettingsView.vue'),
|
|
},
|
|
{
|
|
path: '/hermes/gateways',
|
|
name: 'hermes.gateways',
|
|
component: () => import('@/views/hermes/GatewaysView.vue'),
|
|
},
|
|
{
|
|
path: '/hermes/channels',
|
|
name: 'hermes.channels',
|
|
component: () => import('@/views/hermes/ChannelsView.vue'),
|
|
},
|
|
{
|
|
path: '/hermes/terminal',
|
|
name: 'hermes.terminal',
|
|
component: () => import('@/views/hermes/TerminalView.vue'),
|
|
},
|
|
{
|
|
path: '/hermes/group-chat',
|
|
name: 'hermes.groupChat',
|
|
component: () => import('@/views/hermes/GroupChatView.vue'),
|
|
},
|
|
{
|
|
path: '/hermes/files',
|
|
name: 'hermes.files',
|
|
component: () => import('@/views/hermes/FilesView.vue'),
|
|
},
|
|
],
|
|
})
|
|
|
|
router.beforeEach((to, _from, next) => {
|
|
// Public pages don't need auth
|
|
if (to.meta.public) {
|
|
// Already has key, skip login
|
|
if (to.name === 'login' && hasApiKey()) {
|
|
next({ path: '/hermes/chat' })
|
|
return
|
|
}
|
|
next()
|
|
return
|
|
}
|
|
|
|
// All other pages require token
|
|
if (!hasApiKey()) {
|
|
next({ name: 'login' })
|
|
return
|
|
}
|
|
|
|
next()
|
|
})
|
|
|
|
export default router
|