Complete web UI built with Vue 3, TypeScript, Element Plus, and Pinia. Includes Login, Dashboard, Servers, Repositories, Sync Logs, and Settings pages with API client, auth store, and Vue Router configuration. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { createRouter, createWebHistory } from 'vue-router'
|
|
import { useAuthStore } from '@/stores/auth'
|
|
|
|
const router = createRouter({
|
|
history: createWebHistory(),
|
|
routes: [
|
|
{
|
|
path: '/login',
|
|
name: 'Login',
|
|
component: () => import('@/views/Login.vue')
|
|
},
|
|
{
|
|
path: '/',
|
|
component: () => import('@/views/Layout.vue'),
|
|
children: [
|
|
{ path: '', name: 'Dashboard', component: () => import('@/views/Dashboard.vue') },
|
|
{ path: 'servers', name: 'Servers', component: () => import('@/views/Servers.vue') },
|
|
{ path: 'repos', name: 'Repos', component: () => import('@/views/Repos.vue') },
|
|
{ path: 'logs', name: 'Logs', component: () => import('@/views/Logs.vue') },
|
|
{ path: 'settings', name: 'Settings', component: () => import('@/views/Settings.vue') }
|
|
]
|
|
}
|
|
]
|
|
})
|
|
|
|
router.beforeEach((to, _from, next) => {
|
|
const token = localStorage.getItem('token')
|
|
if (to.path !== '/login' && !token) {
|
|
next('/login')
|
|
} else if (to.path === '/login' && token) {
|
|
next('/')
|
|
} else {
|
|
next()
|
|
}
|
|
})
|
|
|
|
export default router
|