62 lines
1.9 KiB
TypeScript
62 lines
1.9 KiB
TypeScript
import { redirect } from "next/navigation";
|
|
import { Suspense } from "react";
|
|
import { LovartHome } from "@/components/home/lovart-home";
|
|
import { auth } from "../(auth)/auth";
|
|
import {
|
|
getSiteSettings,
|
|
getSystemSetting,
|
|
} from "@/lib/db/queries";
|
|
|
|
export default function Page() {
|
|
return (
|
|
<Suspense fallback={<div className="flex h-dvh" />}>
|
|
<NewChatPage />
|
|
</Suspense>
|
|
);
|
|
}
|
|
|
|
async function NewChatPage() {
|
|
const [session, siteSettings, homeVariantSetting, surpriseCategoriesSetting] =
|
|
await Promise.all([
|
|
auth(),
|
|
getSiteSettings(),
|
|
getSystemSetting({ key: "home_variant" }).catch(() => undefined),
|
|
getSystemSetting({ key: "home_surprise_categories" }).catch(() => undefined),
|
|
]);
|
|
|
|
const homeVariant = homeVariantSetting?.value === "lovart" ? "lovart" : "classic";
|
|
const surpriseCategories = Array.isArray(surpriseCategoriesSetting?.value)
|
|
? surpriseCategoriesSetting?.value
|
|
.map((item: unknown) => String(item || "").trim())
|
|
.filter(Boolean)
|
|
: ["全部", "精选"];
|
|
|
|
if (homeVariant !== "lovart") {
|
|
redirect("/classic");
|
|
}
|
|
|
|
return (
|
|
<LovartHome
|
|
user={
|
|
session?.user
|
|
? {
|
|
id: session.user.id,
|
|
email: session.user.email,
|
|
name: session.user.name,
|
|
type: session.user.type,
|
|
}
|
|
: null
|
|
}
|
|
isAuthenticated={Boolean(session?.user && session.user.type !== "guest")}
|
|
siteName={siteSettings.siteName || "AI Chatbot"}
|
|
siteLogo={siteSettings.siteLogo || ""}
|
|
siteLogoDark={siteSettings.siteLogoDark || ""}
|
|
surpriseCategories={surpriseCategories}
|
|
heroPromoText={siteSettings.lovartPromoText}
|
|
heroPromoActionText={siteSettings.lovartPromoActionText}
|
|
heroTitleText={siteSettings.lovartHeroTitle}
|
|
heroSubtitleText={siteSettings.lovartHeroSubtitle}
|
|
/>
|
|
);
|
|
}
|