Files
podsteadr/frontend/src/router.ts
T

25 lines
1.1 KiB
TypeScript
Raw Normal View History

import { createRouter, createWebHistory } from 'vue-router';
import { useAuthStore } from './stores/auth';
export const router = createRouter({
history: createWebHistory(),
routes: [
{ path: '/login', component: () => import('./views/LoginView.vue') },
{ path: '/', component: () => import('./views/HomeView.vue') },
{ path: '/upload', component: () => import('./views/wizard/EpisodeWizard.vue') },
{ path: '/live', component: () => import('./views/wizard/LiveWizard.vue') },
{ path: '/streams/:id', component: () => import('./views/StreamDashboard.vue') },
{ path: '/podcasts/:id/settings', component: () => import('./views/PodcastSettingsView.vue') },
{ path: '/podcasts/:id/episodes/:eid', component: () => import('./views/EpisodeDetailView.vue') },
{ path: '/earnings', component: () => import('./views/EarningsView.vue') },
{ path: '/settings', component: () => import('./views/SettingsView.vue') },
],
});
router.beforeEach(async (to) => {
const auth = useAuthStore();
await auth.ensureLoaded();
if (to.path !== '/login' && !auth.pubkey) return '/login';
if (to.path === '/login' && auth.pubkey) return '/';
});