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 { notFound } from "next/navigation";
|
||||
import CodeEditor from "@/components/code-editor";
|
||||
import WorkspaceEditorHeader from "@/components/features/playground/workspace/editor/components/header";
|
||||
import WorkspaceEditorFooter from "@/components/features/playground/workspace/editor/components/footer";
|
||||
@ -12,7 +13,8 @@ export default async function WorkspaceEditorPage({
|
||||
}: WorkspaceEditorProps) {
|
||||
const { id } = await params;
|
||||
|
||||
const problem = await prisma.problem.findUnique({
|
||||
const [problem, editorLanguageConfigs, languageServerConfigs] = await Promise.all([
|
||||
prisma.problem.findUnique({
|
||||
where: { id },
|
||||
select: {
|
||||
templates: {
|
||||
@ -22,20 +24,26 @@ export default async function WorkspaceEditorPage({
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}),
|
||||
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 (
|
||||
<>
|
||||
<WorkspaceEditorHeader
|
||||
templates={templates}
|
||||
editorLanguageConfigs={editorLanguageConfigs}
|
||||
/>
|
||||
<WorkspaceEditorHeader {...commonProps} />
|
||||
<div className="flex-1">
|
||||
<CodeEditor problemId={id} templates={templates} />
|
||||
<CodeEditor problemId={id} {...commonProps} />
|
||||
</div>
|
||||
<WorkspaceEditorFooter />
|
||||
</>
|
||||
|
Loading…
Reference in New Issue
Block a user