Replace Clerk with self-contained JWT auth (bcryptjs + jose), remove all external auth dependencies. Add full i18n system with Chinese as default language and English toggle — React Context + JSON dictionaries, no external i18n library. Auth: - Add passwordHash to User model, generate JWT secret - Create /api/auth/register, login, logout, me endpoints - Rewrite proxy.ts middleware for custom session validation - Add AuthProvider + useAuth hook, sign-in/sign-up pages - Wire auth into layout and all API routes i18n: - React Context I18nProvider with localStorage + cookie persistence - dictionaries/zh.ts (default) and dictionaries/en.ts - LanguageSwitcher component, server-side createServerT() utility - CJK font stack via [lang="zh"] CSS selector - HTML lang attribute synced on language change - All pages, components, TabBar, StageBadge translated - Engine fallback strings (reflection-analyzer, summary-generator) - API routes pass locale from cookie to engines Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
import type { Metadata } from "next";
|
|
import { cookies } from "next/headers";
|
|
import { DM_Sans, Fraunces } from "next/font/google";
|
|
import TabBar from "@/components/TabBar";
|
|
import LanguageSwitcher from "@/components/LanguageSwitcher";
|
|
import { I18nProvider } from "@/lib/i18n/context";
|
|
import "./globals.css";
|
|
|
|
const fraunces = Fraunces({
|
|
variable: "--font-fraunces",
|
|
subsets: ["latin"],
|
|
axes: ["opsz", "SOFT", "WONK"],
|
|
});
|
|
|
|
const dmSans = DM_Sans({
|
|
variable: "--font-dm-sans",
|
|
subsets: ["latin"],
|
|
weight: ["400", "500", "700"],
|
|
});
|
|
|
|
export const metadata: Metadata = {
|
|
title: "Inner OS",
|
|
description: "Your private inner development practice.",
|
|
};
|
|
|
|
export default async function RootLayout({
|
|
children,
|
|
}: Readonly<{
|
|
children: React.ReactNode;
|
|
}>) {
|
|
const cookieStore = await cookies();
|
|
const langCookie = cookieStore.get("inneros-lang")?.value;
|
|
const lang = langCookie === "zh" || langCookie === "en" ? langCookie : "zh";
|
|
|
|
return (
|
|
<html
|
|
lang={lang}
|
|
className={`${fraunces.variable} ${dmSans.variable} h-full antialiased`}
|
|
>
|
|
<body className="min-h-full flex flex-col pb-16 bg-cream dark:bg-[#1E1A14] text-ink dark:text-[#F3EFE8]">
|
|
<I18nProvider>
|
|
<main className="flex-1 max-w-2xl mx-auto w-full px-5 pt-8 pb-4 relative">
|
|
<LanguageSwitcher />
|
|
{children}
|
|
</main>
|
|
<TabBar />
|
|
</I18nProvider>
|
|
</body>
|
|
</html>
|
|
);
|
|
}
|