e0ba384705
Co-authored-by: Cursor <cursoragent@cursor.com>
36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import { createRouter, createWebHistory } from "vue-router";
|
|
import { getToken } from "./api";
|
|
import EventsView from "./views/EventsView.vue";
|
|
import EventDetailView from "./views/EventDetailView.vue";
|
|
import HostsView from "./views/HostsView.vue";
|
|
import LoginView from "./views/LoginView.vue";
|
|
import ProblemsView from "./views/ProblemsView.vue";
|
|
import ProblemDetailView from "./views/ProblemDetailView.vue";
|
|
import DashboardView from "./views/DashboardView.vue";
|
|
import ReportsView from "./views/ReportsView.vue";
|
|
import SettingsView from "./views/SettingsView.vue";
|
|
|
|
const router = createRouter({
|
|
history: createWebHistory(),
|
|
routes: [
|
|
{ path: "/", redirect: "/dashboard" },
|
|
{ path: "/dashboard", component: DashboardView },
|
|
{ path: "/login", component: LoginView },
|
|
{ path: "/events", component: EventsView },
|
|
{ path: "/events/:id", component: EventDetailView, props: true },
|
|
{ path: "/reports", component: ReportsView },
|
|
{ path: "/hosts", component: HostsView },
|
|
{ path: "/problems", component: ProblemsView },
|
|
{ path: "/problems/:id", component: ProblemDetailView, props: true },
|
|
{ path: "/settings", component: SettingsView },
|
|
],
|
|
});
|
|
|
|
router.beforeEach((to) => {
|
|
if (to.path === "/login") return true;
|
|
if (!getToken()) return { path: "/login" };
|
|
return true;
|
|
});
|
|
|
|
export default router;
|