2025-03-14 07:36:29 +00:00
|
|
|
import "@/app/globals.css";
|
|
|
|
import { Toaster } from "sonner";
|
2025-02-19 01:00:15 +00:00
|
|
|
import type { Metadata } from "next";
|
2025-02-19 13:20:25 +00:00
|
|
|
import { ThemeProvider } from "@/components/theme-provider";
|
2025-03-12 09:38:33 +00:00
|
|
|
import { SettingsDialog } from "@/components/settings-dialog";
|
2025-04-13 11:13:45 +00:00
|
|
|
import { getUserLocale } from "@/services/locale";
|
|
|
|
import IntlProvider from "@/components/intl-provider";
|
|
|
|
import React from "react";
|
2025-02-19 01:00:15 +00:00
|
|
|
|
|
|
|
export const metadata: Metadata = {
|
2025-04-13 11:13:45 +00:00
|
|
|
title: "Judge4c",
|
|
|
|
description:
|
|
|
|
"A full-stack, open-source online judge platform designed to elevate college programming education.",
|
2025-02-19 01:00:15 +00:00
|
|
|
};
|
|
|
|
|
2025-02-21 11:49:56 +00:00
|
|
|
interface RootLayoutProps {
|
2025-04-13 11:13:45 +00:00
|
|
|
children: React.ReactNode;
|
2025-02-21 11:49:56 +00:00
|
|
|
}
|
|
|
|
|
2025-04-13 11:13:45 +00:00
|
|
|
export default async function RootLayout({ children }: RootLayoutProps) {
|
|
|
|
let locale = await getUserLocale();
|
|
|
|
|
|
|
|
if (!locale) {
|
|
|
|
console.warn("未检测到用户语言,使用默认语言 'en'");
|
|
|
|
locale = "en";
|
|
|
|
} else {
|
|
|
|
console.log(`检测到用户语言:${locale}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
let messages;
|
|
|
|
try {
|
|
|
|
messages = (await import(`../../messages/${locale}.json`)).default;
|
|
|
|
console.log(`已成功加载语言文件: messages/${locale}.json`);
|
|
|
|
} catch (error) {
|
|
|
|
console.error(
|
|
|
|
`加载语言文件 messages/${locale}.json 失败,回退到 messages/en.json`,
|
|
|
|
error
|
|
|
|
);
|
|
|
|
locale = "en";
|
|
|
|
messages = (await import(`../../messages/en.json`)).default;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<html lang={locale} className="h-full" suppressHydrationWarning>
|
|
|
|
<body className="flex min-h-full antialiased">
|
|
|
|
<IntlProvider locale={locale} messages={messages}>
|
|
|
|
<ThemeProvider
|
|
|
|
attribute="class"
|
|
|
|
defaultTheme="system"
|
|
|
|
enableSystem
|
|
|
|
disableTransitionOnChange
|
|
|
|
>
|
|
|
|
<div className="w-full">{children}</div>
|
|
|
|
<SettingsDialog />
|
|
|
|
<Toaster position="top-right" />
|
|
|
|
</ThemeProvider>
|
|
|
|
</IntlProvider>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
);
|
2025-02-19 01:00:15 +00:00
|
|
|
}
|