39 lines
1.4 KiB
JavaScript
39 lines
1.4 KiB
JavaScript
"use client";
|
|
import { useEffect } from "react";
|
|
import { useRouter } from "next/navigation"; // App-Router Hook für Navigation
|
|
|
|
// Importiere `storePage` nur im Client
|
|
export default function Home() {
|
|
const router = useRouter();
|
|
|
|
useEffect(() => {
|
|
// Überprüfe, ob der Code im Browser läuft
|
|
if (typeof window !== "undefined") {
|
|
// Dynamischer Import von `storePage` nur im Browser
|
|
import("../utils/indexedDB").then(({ storePage }) => {
|
|
const pageContent = `
|
|
<div style="text-align: center; margin-top: 100px;">
|
|
<h1>Bitte warten...</h1>
|
|
<div class="spinner"></div>
|
|
<p>Die Seite wird automatisch neu geladen.</p>
|
|
</div>`;
|
|
storePage("waitPage", new Blob([pageContent], { type: "text/html" }))
|
|
.then(() => {
|
|
console.log("Seite 'wait' erfolgreich gespeichert.");
|
|
// Weiterleitung zur Dashboard-Seite
|
|
router.push("/dashboard");
|
|
})
|
|
.catch((error) => {
|
|
console.error("Fehler beim Speichern der Seite 'wait':", error);
|
|
router.push("/dashboard");
|
|
});
|
|
});
|
|
} else {
|
|
// Falls kein Browser oder IndexedDB verfügbar ist, direkt zur Dashboard-Seite weiterleiten
|
|
router.push("/dashboard");
|
|
}
|
|
}, [router]);
|
|
|
|
return <div>Wird geladen...</div>; // Temporärer Ladezustand
|
|
}
|