Files
TJWaterFrontend_Refine/src/app/(main)/layout.tsx
T
jiang 4a522bf42a
Generic Container CI/CD / test-build-publish (push) Successful in 1m11s
Frontend CI/CD v2 / build-test-publish-and-deploy (push) Successful in 1m11s
feat(frontend): cache 3D assets and restore loading feedback
Persist versioned models and validated network metadata in IndexedDB. Show scene download progress and recoverable errors with the existing frosted material.

Connect existing skeletons to pending navigation and route boundaries while preserving the map. Previously only dynamic imports showed fallbacks, and rejected model promises prevented retries.

Verified: 32 focused unit tests; 4 navigation and scene browser checks; 7 cache browser checks including invalid-metadata recovery; isolated production build and type checks.
2026-10-16 18:13:04 +08:00

68 lines
1.6 KiB
TypeScript

import type { Metadata } from "next";
import { cookies } from "next/headers";
import type { ReactNode } from "react";
import authOptions from "@app/api/auth/[...nextauth]/options";
import { Header } from "@components/header";
import { Title } from "@components/title";
import { AppSider } from "@components/sider/AppSider";
import {
NavigationFeedbackProvider,
PageNavigationContent,
} from "@components/loading/NavigationFeedback";
import { ThemedLayout } from "@refinedev/mui";
import { getServerSession } from "next-auth/next";
import { redirect } from "next/navigation";
import "../globals.css";
import { META_DATA } from "@config/config";
export const metadata: Metadata = META_DATA;
export default async function MainLayout({
children,
}: Readonly<{
children: ReactNode;
}>) {
const cookieStore = await cookies();
const theme = cookieStore.get("theme");
const defaultMode = theme?.value === "dark" ? "dark" : "light";
const data = await getData();
if (!data.session?.user) {
return redirect("/login");
}
return (
<NavigationFeedbackProvider>
<ThemedLayout
Header={Header}
Title={Title}
Sider={AppSider}
childrenBoxProps={{
sx: {
flex: 1,
minHeight: 0,
overflow: "hidden",
p: 0,
},
}}
containerBoxProps={{
sx: { height: "100vh", overflow: "hidden" },
}}
>
<PageNavigationContent>{children}</PageNavigationContent>
</ThemedLayout>
</NavigationFeedbackProvider>
);
}
async function getData() {
const session = await getServerSession(authOptions);
return {
session,
};
}