feat(problem): add Bot panel and adapt to new dockview API

This commit is contained in:
cfngc4594 2025-04-05 18:03:36 +08:00
parent b8576dbf10
commit ba676b3213

View File

@ -12,6 +12,7 @@ interface ProblemProps {
Code: React.ReactNode; Code: React.ReactNode;
Testcase: React.ReactNode; Testcase: React.ReactNode;
TestResult: React.ReactNode; TestResult: React.ReactNode;
Bot: React.ReactNode;
} }
export default async function ProblemLayout({ export default async function ProblemLayout({
@ -22,21 +23,19 @@ export default async function ProblemLayout({
Code, Code,
Testcase, Testcase,
TestResult, TestResult,
Bot,
}: ProblemProps) { }: ProblemProps) {
const { id } = await params; const { id } = await params;
const [ const [problemData, editorLanguageConfigs, languageServerConfigs] =
problemData, await Promise.all([
editorLanguageConfigs, prisma.problem.findUnique({
languageServerConfigs, where: { id },
] = await Promise.all([ include: { templates: true },
prisma.problem.findUnique({ }),
where: { id }, prisma.editorLanguageConfig.findMany(),
include: { templates: true }, prisma.languageServerConfig.findMany(),
}), ]);
prisma.editorLanguageConfig.findMany(),
prisma.languageServerConfig.findMany(),
]);
if (!problemData) { if (!problemData) {
return notFound(); return notFound();
@ -56,12 +55,71 @@ export default async function ProblemLayout({
<PlaygroundHeader /> <PlaygroundHeader />
<main className="flex flex-grow overflow-y-hidden p-2.5 pt-0"> <main className="flex flex-grow overflow-y-hidden p-2.5 pt-0">
<DockView <DockView
Description={Description} storageKey="dockview:problem"
Solutions={Solutions} options={[
Submissions={Submissions} {
Code={Code} id: "Description",
Testcase={Testcase} title: "Description",
TestResult={TestResult} component: "Description",
tabComponent: "Description",
icon: "FileTextIcon",
node: Description,
},
{
id: "Solutions",
title: "Solutions",
component: "Solutions",
tabComponent: "Solutions",
icon: "FlaskConicalIcon",
node: Solutions,
position: { referencePanel: "Description", direction: "within" },
},
{
id: "Submissions",
title: "Submissions",
component: "Submissions",
tabComponent: "Submissions",
icon: "CircleCheckBigIcon",
node: Submissions,
position: { referencePanel: "Solutions", direction: "within" },
},
{
id: "Code",
title: "Code",
component: "Code",
tabComponent: "Code",
icon: "SquarePenIcon",
node: Code,
position: { referencePanel: "Submissions", direction: "right" },
},
{
id: "Bot",
title: "Bot",
component: "Bot",
tabComponent: "Bot",
icon: "BotIcon",
node: Bot,
position: { referencePanel: "Code", direction: "right" },
},
{
id: "Testcase",
title: "Testcase",
component: "Testcase",
tabComponent: "Testcase",
icon: "SquareCheckIcon",
node: Testcase,
position: { referencePanel: "Code", direction: "below" },
},
{
id: "TestResult",
title: "TestResult",
component: "TestResult",
tabComponent: "TestResult",
icon: "TerminalIcon",
node: TestResult,
position: { referencePanel: "Testcase", direction: "within" },
},
]}
/> />
</main> </main>
</ProblemStoreProvider> </ProblemStoreProvider>