import { createRootRoute, createRoute, createRouter, lazyRouteComponent, Navigate, redirect, } from "@tanstack/react-router" import { Absturz } from "./Absturz" import { Shell } from "./Shell" import { UebersichtSeite } from "@/views/Uebersicht" const wurzel = createRootRoute({ component: Shell, // Alte Lesezeichen (/ideen, /wissen, /cockpit …) führen einfach zur Übersicht. notFoundComponent: () => , }) // Die Übersicht ist der Normalfall und kommt im ersten Bündel mit; alle anderen Seiten werden erst beim // ersten Besuch nachgeladen (Budget: 140 KB gzip für den Einstieg). const uebersicht = createRoute({ getParentRoute: () => wurzel, path: "/", component: UebersichtSeite }) // Bereich KI-Box const box = createRoute({ getParentRoute: () => wurzel, path: "/box", component: lazyRouteComponent(() => import("@/views/Start"), "StartSeite"), }) const boxUpdates = createRoute({ getParentRoute: () => wurzel, path: "/box/updates", component: lazyRouteComponent(() => import("@/views/Updates"), "UpdatesSeite"), }) const boxModelle = createRoute({ getParentRoute: () => wurzel, path: "/box/modelle", component: lazyRouteComponent(() => import("@/views/Modelle"), "ModelleSeite"), }) const boxMonitoring = createRoute({ getParentRoute: () => wurzel, path: "/box/monitoring", component: lazyRouteComponent(() => import("@/views/Monitoring"), "BoxMonitoringSeite"), }) const boxDienste = createRoute({ getParentRoute: () => wurzel, path: "/box/dienste", component: lazyRouteComponent(() => import("@/views/Dienste"), "DiensteSeite"), }) // Bereich Homelab const homelab = createRoute({ getParentRoute: () => wurzel, path: "/homelab", component: lazyRouteComponent(() => import("@/views/Homelab"), "HomelabSeite"), }) const homelabUpdates = createRoute({ getParentRoute: () => wurzel, path: "/homelab/updates", component: lazyRouteComponent(() => import("@/views/Homelab"), "HomelabUpdatesSeite"), }) const homelabSnapshots = createRoute({ getParentRoute: () => wurzel, path: "/homelab/snapshots", component: lazyRouteComponent(() => import("@/views/HomelabSnapshots"), "HomelabSnapshotsSeite"), }) const homelabMonitoring = createRoute({ getParentRoute: () => wurzel, path: "/homelab/monitoring", component: lazyRouteComponent(() => import("@/views/Monitoring"), "HomelabMonitoringSeite"), }) const homelabProtokoll = createRoute({ getParentRoute: () => wurzel, path: "/homelab/protokoll", component: lazyRouteComponent(() => import("@/views/HomelabProtokoll"), "HomelabProtokollSeite"), }) // Handy-Startansicht (seit 26.09.2026): Ampel und „Braucht Aufmerksamkeit“; die installierte App startet hier. const handy = createRoute({ getParentRoute: () => wurzel, path: "/handy", component: lazyRouteComponent(() => import("@/views/Handy"), "HandySeite"), }) const einstellungen = createRoute({ getParentRoute: () => wurzel, path: "/einstellungen", component: lazyRouteComponent(() => import("@/views/Einstellungen"), "EinstellungenSeite"), }) // Frühere Adressen der KI-Box (bis 24.09.2026) leiten weiter — Lesezeichen und Links bleiben gültig. const altUpdates = createRoute({ getParentRoute: () => wurzel, path: "/updates", beforeLoad: () => { throw redirect({ to: "/box/updates" }) }, }) const altModelle = createRoute({ getParentRoute: () => wurzel, path: "/modelle", beforeLoad: ({ location }) => { throw redirect({ to: "/box/modelle", hash: location.hash || undefined }) }, }) export const router = createRouter({ routeTree: wurzel.addChildren([ uebersicht, box, boxUpdates, boxModelle, boxMonitoring, boxDienste, homelab, homelabUpdates, homelabMonitoring, homelabProtokoll, einstellungen, altUpdates, altModelle, homelabSnapshots, handy, ]), defaultPreload: "intent", defaultErrorComponent: Absturz, }) declare module "@tanstack/react-router" { interface Register { router: typeof router } }