Test: wait Seite speichern
This commit is contained in:
26
app/page.js
26
app/page.js
@@ -1,13 +1,35 @@
|
||||
"use client";
|
||||
import { useEffect } from "react";
|
||||
import { useRouter } from "next/navigation"; // App-Router Hook für Navigation
|
||||
import { storePage } from "../utils/indexedDB"; // Importiere die Funktion storePage aus indexedDB.js
|
||||
|
||||
export default function Home() {
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
// Umleitung zur Dashboard-Seite bei der Initialisierung
|
||||
router.push("/dashboard");
|
||||
if (typeof window !== "undefined" && storePage) {
|
||||
// Speichere die Seite "wait" als HTML in IndexedDB
|
||||
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);
|
||||
// Auch bei einem Fehler weiter zur Dashboard-Seite leiten
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user