feat: Add ThemeProviderWrapper for theme management

This commit is contained in:
Shi Tianxin
2025-04-28 11:37:46 +08:00
parent 834d5221ca
commit 6b45e17714
3 changed files with 51 additions and 30 deletions

View File

@@ -0,0 +1,29 @@
// Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
// SPDX-License-Identifier: MIT
"use client";
import { usePathname } from "next/navigation";
import { ThemeProvider } from "~/components/theme-provider";
export function ThemeProviderWrapper({
children,
}: {
children: React.ReactNode;
}) {
const pathname = usePathname();
const isChatPage = pathname?.startsWith("/chat");
return (
<ThemeProvider
attribute="class"
defaultTheme={"dark"}
enableSystem={isChatPage}
forcedTheme={isChatPage ? undefined : "dark"}
disableTransitionOnChange
>
{children}
</ThemeProvider>
);
}