mirror of
https://github.com/massbug/judge4c.git
synced 2025-05-17 23:12:23 +00:00
feat(problem): refactor layout and page components
- Refactored `ProblemLayout` to pass panel components (Description, Solutions, etc.) as props. - Updated `ProblemPage` to dynamically render dock panels with content from props, instead of static components. - Removed `DefaultDockviewOptions` and integrated custom panel configuration directly in `ProblemPage`. - Enhanced `DockView` to support dynamic panel content rendering based on passed props.
This commit is contained in:
parent
a897e00a72
commit
a559c326a8
@ -1,20 +1,42 @@
|
|||||||
import prisma from "@/lib/prisma";
|
import prisma from "@/lib/prisma";
|
||||||
import { notFound } from "next/navigation";
|
import { notFound } from "next/navigation";
|
||||||
|
import ProblemPage from "@/app/(app)/problems/[id]/page";
|
||||||
import { ProblemStoreProvider } from "@/providers/problem-store-provider";
|
import { ProblemStoreProvider } from "@/providers/problem-store-provider";
|
||||||
import { PlaygroundHeader } from "@/components/features/playground/header";
|
import { PlaygroundHeader } from "@/components/features/playground/header";
|
||||||
|
|
||||||
interface ProblemProps {
|
interface ProblemProps {
|
||||||
params: Promise<{ id: string }>;
|
params: Promise<{ id: string }>;
|
||||||
children: React.ReactNode;
|
Description: React.ReactNode;
|
||||||
|
Solutions: React.ReactNode;
|
||||||
|
Submissions: React.ReactNode;
|
||||||
|
Code: React.ReactNode;
|
||||||
|
Testcase: React.ReactNode;
|
||||||
|
TestResult: React.ReactNode;
|
||||||
|
Bot: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function ProblemLayout({
|
export default async function ProblemLayout({
|
||||||
params,
|
params,
|
||||||
children,
|
Description,
|
||||||
|
Solutions,
|
||||||
|
Submissions,
|
||||||
|
Code,
|
||||||
|
Testcase,
|
||||||
|
TestResult,
|
||||||
|
Bot,
|
||||||
}: ProblemProps) {
|
}: ProblemProps) {
|
||||||
const { id } = await params;
|
const { id } = await params;
|
||||||
|
|
||||||
const [problem, editorLanguageConfigs, languageServerConfigs, submissions] = await Promise.all([
|
if (!id) {
|
||||||
|
return notFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
const [
|
||||||
|
problem,
|
||||||
|
editorLanguageConfigs,
|
||||||
|
languageServerConfigs,
|
||||||
|
submissions,
|
||||||
|
] = await Promise.all([
|
||||||
prisma.problem.findUnique({
|
prisma.problem.findUnique({
|
||||||
where: { id },
|
where: { id },
|
||||||
include: {
|
include: {
|
||||||
@ -30,7 +52,7 @@ export default async function ProblemLayout({
|
|||||||
prisma.languageServerConfig.findMany(),
|
prisma.languageServerConfig.findMany(),
|
||||||
prisma.submission.findMany({
|
prisma.submission.findMany({
|
||||||
where: { problemId: id },
|
where: { problemId: id },
|
||||||
})
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (!problem) {
|
if (!problem) {
|
||||||
@ -48,7 +70,15 @@ 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">
|
||||||
{children}
|
<ProblemPage
|
||||||
|
Description={Description}
|
||||||
|
Solutions={Solutions}
|
||||||
|
Submissions={Submissions}
|
||||||
|
Code={Code}
|
||||||
|
Testcase={Testcase}
|
||||||
|
TestResult={TestResult}
|
||||||
|
Bot={Bot}
|
||||||
|
/>
|
||||||
</main>
|
</main>
|
||||||
</ProblemStoreProvider>
|
</ProblemStoreProvider>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,35 +1,140 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Bot,
|
BotIcon,
|
||||||
Code,
|
CircleCheckBigIcon,
|
||||||
|
FileTextIcon,
|
||||||
|
FlaskConicalIcon,
|
||||||
|
SquareCheckIcon,
|
||||||
|
SquarePenIcon,
|
||||||
|
TerminalIcon,
|
||||||
|
} from "lucide-react";
|
||||||
|
import Dockview from "@/components/dockview";
|
||||||
|
import { useDockviewStore } from "@/stores/dockview";
|
||||||
|
|
||||||
|
interface ProblemPageProps {
|
||||||
|
Description: React.ReactNode;
|
||||||
|
Solutions: React.ReactNode;
|
||||||
|
Submissions: React.ReactNode;
|
||||||
|
Code: React.ReactNode;
|
||||||
|
Testcase: React.ReactNode;
|
||||||
|
TestResult: React.ReactNode;
|
||||||
|
Bot: React.ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function ProblemPage({
|
||||||
Description,
|
Description,
|
||||||
Solutions,
|
Solutions,
|
||||||
Submissions,
|
Submissions,
|
||||||
|
Code,
|
||||||
Testcase,
|
Testcase,
|
||||||
TestResult,
|
TestResult,
|
||||||
} from "@/app/(app)/problems/[id]/features";
|
Bot,
|
||||||
import DockView from "@/components/dockview";
|
}: ProblemPageProps) {
|
||||||
import { useDockviewStore } from "@/stores/dockview";
|
|
||||||
import { DefaultDockviewOptions } from "@/config/dockview";
|
|
||||||
|
|
||||||
export default function ProblemPage() {
|
|
||||||
const { setApi } = useDockviewStore();
|
const { setApi } = useDockviewStore();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DockView
|
<Dockview
|
||||||
storageKey="dockview:problem"
|
storageKey="dockview:problem"
|
||||||
components={{
|
|
||||||
Description: () => <Description />,
|
|
||||||
Solutions: () => <Solutions />,
|
|
||||||
Submissions: () => <Submissions />,
|
|
||||||
Code: () => <Code />,
|
|
||||||
Testcase: () => <Testcase />,
|
|
||||||
TestResult: () => <TestResult />,
|
|
||||||
Bot: () => <Bot />,
|
|
||||||
}}
|
|
||||||
options={DefaultDockviewOptions.filter((panel) => panel.id !== "Bot")}
|
|
||||||
onApiReady={setApi}
|
onApiReady={setApi}
|
||||||
|
options={[
|
||||||
|
{
|
||||||
|
id: "Description",
|
||||||
|
component: "Description",
|
||||||
|
tabComponent: "Description",
|
||||||
|
title: "Description",
|
||||||
|
params: {
|
||||||
|
icon: FileTextIcon,
|
||||||
|
content: Description,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "Solutions",
|
||||||
|
component: "Solutions",
|
||||||
|
tabComponent: "Solutions",
|
||||||
|
title: "Solutions",
|
||||||
|
params: {
|
||||||
|
icon: FlaskConicalIcon,
|
||||||
|
content: Solutions,
|
||||||
|
},
|
||||||
|
position: {
|
||||||
|
referencePanel: "Description",
|
||||||
|
direction: "within",
|
||||||
|
},
|
||||||
|
inactive: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "Submissions",
|
||||||
|
component: "Submissions",
|
||||||
|
tabComponent: "Submissions",
|
||||||
|
title: "Submissions",
|
||||||
|
params: {
|
||||||
|
icon: CircleCheckBigIcon,
|
||||||
|
content: Submissions,
|
||||||
|
},
|
||||||
|
position: {
|
||||||
|
referencePanel: "Solutions",
|
||||||
|
direction: "within",
|
||||||
|
},
|
||||||
|
inactive: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "Code",
|
||||||
|
component: "Code",
|
||||||
|
tabComponent: "Code",
|
||||||
|
title: "Code",
|
||||||
|
params: {
|
||||||
|
icon: SquarePenIcon,
|
||||||
|
content: Code,
|
||||||
|
},
|
||||||
|
position: {
|
||||||
|
referencePanel: "Submissions",
|
||||||
|
direction: "right",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "Testcase",
|
||||||
|
component: "Testcase",
|
||||||
|
tabComponent: "Testcase",
|
||||||
|
title: "Testcase",
|
||||||
|
params: {
|
||||||
|
icon: SquareCheckIcon,
|
||||||
|
content: Testcase,
|
||||||
|
},
|
||||||
|
position: {
|
||||||
|
referencePanel: "Code",
|
||||||
|
direction: "below",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "TestResult",
|
||||||
|
component: "TestResult",
|
||||||
|
tabComponent: "TestResult",
|
||||||
|
title: "Test Result",
|
||||||
|
params: {
|
||||||
|
icon: TerminalIcon,
|
||||||
|
content: TestResult,
|
||||||
|
},
|
||||||
|
position: {
|
||||||
|
referencePanel: "Testcase",
|
||||||
|
direction: "within",
|
||||||
|
},
|
||||||
|
inactive: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "Bot",
|
||||||
|
component: "Bot",
|
||||||
|
tabComponent: "Bot",
|
||||||
|
title: "Bot",
|
||||||
|
params: {
|
||||||
|
icon: BotIcon,
|
||||||
|
content: Bot,
|
||||||
|
autoAdd: false,
|
||||||
|
},
|
||||||
|
position: {
|
||||||
|
direction: "right",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user