mirror of
https://github.com/massbug/judge4c.git
synced 2025-05-18 07:16:34 +00:00
feat(workspace/editor): add language server config support and optimize data fetching logic
This commit is contained in:
parent
4dc3b44bf0
commit
332e019e70
@ -1,4 +1,5 @@
|
|||||||
import prisma from "@/lib/prisma";
|
import prisma from "@/lib/prisma";
|
||||||
|
import { notFound } from "next/navigation";
|
||||||
import CodeEditor from "@/components/code-editor";
|
import CodeEditor from "@/components/code-editor";
|
||||||
import WorkspaceEditorHeader from "@/components/features/playground/workspace/editor/components/header";
|
import WorkspaceEditorHeader from "@/components/features/playground/workspace/editor/components/header";
|
||||||
import WorkspaceEditorFooter from "@/components/features/playground/workspace/editor/components/footer";
|
import WorkspaceEditorFooter from "@/components/features/playground/workspace/editor/components/footer";
|
||||||
@ -12,30 +13,37 @@ export default async function WorkspaceEditorPage({
|
|||||||
}: WorkspaceEditorProps) {
|
}: WorkspaceEditorProps) {
|
||||||
const { id } = await params;
|
const { id } = await params;
|
||||||
|
|
||||||
const problem = await prisma.problem.findUnique({
|
const [problem, editorLanguageConfigs, languageServerConfigs] = await Promise.all([
|
||||||
where: { id },
|
prisma.problem.findUnique({
|
||||||
select: {
|
where: { id },
|
||||||
templates: {
|
select: {
|
||||||
select: {
|
templates: {
|
||||||
language: true,
|
select: {
|
||||||
template: true,
|
language: true,
|
||||||
|
template: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
}),
|
||||||
});
|
prisma.editorLanguageConfig.findMany(),
|
||||||
|
prisma.languageServerConfig.findMany(),
|
||||||
|
]);
|
||||||
|
|
||||||
const editorLanguageConfigs = await prisma.editorLanguageConfig.findMany();
|
if (!problem) {
|
||||||
|
return notFound();
|
||||||
|
}
|
||||||
|
|
||||||
const templates = problem?.templates ?? [];
|
const commonProps = {
|
||||||
|
templates: problem.templates ?? [],
|
||||||
|
editorLanguageConfigs,
|
||||||
|
languageServerConfigs,
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<WorkspaceEditorHeader
|
<WorkspaceEditorHeader {...commonProps} />
|
||||||
templates={templates}
|
|
||||||
editorLanguageConfigs={editorLanguageConfigs}
|
|
||||||
/>
|
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<CodeEditor problemId={id} templates={templates} />
|
<CodeEditor problemId={id} {...commonProps} />
|
||||||
</div>
|
</div>
|
||||||
<WorkspaceEditorFooter />
|
<WorkspaceEditorFooter />
|
||||||
</>
|
</>
|
||||||
|
Loading…
Reference in New Issue
Block a user