diff --git a/src/components/creater/edit-code-panel.tsx b/src/components/creater/edit-code-panel.tsx index 5e68fef..3812ce0 100644 --- a/src/components/creater/edit-code-panel.tsx +++ b/src/components/creater/edit-code-panel.tsx @@ -7,7 +7,6 @@ import { Button } from "@/components/ui/button"; import React, { useEffect, useState } from "react"; import { CoreEditor } from "@/components/core-editor"; import { getProblemData } from "@/app/actions/getProblem"; -import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"; import { Card, CardContent, CardHeader } from "@/components/ui/card"; import { PanelLayout } from "@/features/problems/layouts/panel-layout"; import { updateProblemTemplate } from "@/components/creater/problem-maintain"; @@ -70,50 +69,47 @@ export default function EditCodePanel({ problemId }: EditCodePanelProps) { return ( - - - -
- 代码模板 - + + +
+ 代码模板 + +
+
+ +
+
+ +
- - -
-
- - -
-
- -
- - setCodeTemplate({ ...codeTemplate, content: value || "" }) - } - /> -
+
+ +
+ + setCodeTemplate({ ...codeTemplate, content: value || "" }) + } + />
- - - - +
+ + ); } diff --git a/src/components/creater/edit-description-panel.tsx b/src/components/creater/edit-description-panel.tsx index b10fde4..58d0bbb 100644 --- a/src/components/creater/edit-description-panel.tsx +++ b/src/components/creater/edit-description-panel.tsx @@ -16,7 +16,6 @@ import { CoreEditor } from "@/components/core-editor"; import { getProblemData } from "@/app/actions/getProblem"; import { VideoEmbed } from "@/components/content/video-embed"; import { getProblemLocales } from "@/app/actions/getProblemLocales"; -import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"; import { PanelLayout } from "@/features/problems/layouts/panel-layout"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; @@ -105,114 +104,111 @@ export default function EditDescriptionPanel({ return ( - - - - 题目描述 - - - {/* 语言切换 */} -
- -
- - setCustomLocale(e.target.value)} - /> - -
-
- - {/* 标题输入 */} -
- + + + 题目描述 + + + {/* 语言切换 */} +
+ +
+ - setDescription({ ...description, title: e.target.value }) - } - placeholder="输入题目标题" + placeholder="添加新语言" + value={customLocale} + onChange={(e) => setCustomLocale(e.target.value)} /> +
+
- {/* 编辑/预览切换 */} -
-
- - - -
-
- -
-
- - {/* 编辑/预览区域 */} -
+ + + setDescription({ ...description, title: e.target.value }) } - > - {(viewMode === "edit" || viewMode === "compare") && ( -
- - setDescription({ ...description, content: newVal || "" }) - } - language="markdown" - className="absolute inset-0 rounded-md border border-input" - /> -
- )} - {viewMode !== "edit" && ( -
- -
- )} + placeholder="输入题目标题" + /> +
+ + {/* 编辑/预览切换 */} +
+
+ + +
- - - - +
+ +
+
+ + {/* 编辑/预览区域 */} +
+ {(viewMode === "edit" || viewMode === "compare") && ( +
+ + setDescription({ ...description, content: newVal || "" }) + } + language="markdown" + className="absolute inset-0 rounded-md border border-input" + /> +
+ )} + {viewMode !== "edit" && ( +
+ +
+ )} +
+
+
); } diff --git a/src/components/creater/edit-detail-panel.tsx b/src/components/creater/edit-detail-panel.tsx index 07156eb..e31a9a3 100644 --- a/src/components/creater/edit-detail-panel.tsx +++ b/src/components/creater/edit-detail-panel.tsx @@ -7,7 +7,6 @@ import { Button } from "@/components/ui/button"; import { Difficulty } from "@/generated/client"; import React, { useState, useEffect } from "react"; import { getProblemData } from "@/app/actions/getProblem"; -import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"; import { Card, CardContent, CardHeader } from "@/components/ui/card"; import { PanelLayout } from "@/features/problems/layouts/panel-layout"; import { updateProblemDetail } from "@/components/creater/problem-maintain"; @@ -80,91 +79,88 @@ export default function EditDetailPanel({ problemId }: { problemId: string }) { return ( - - - + + +
+ 题目详情 + +
+
+ +
+
+
+ + handleNumberInputChange(e, "displayId")} + placeholder="输入显示ID" + /> +
+
+ + +
+
+ +
+
+ + handleNumberInputChange(e, "timeLimit")} + placeholder="输入时间限制" + /> +
+
+ + handleNumberInputChange(e, "memoryLimit")} + placeholder="输入内存限制" + /> +
+
+
- 题目详情 - -
- - -
-
-
- - handleNumberInputChange(e, "displayId")} - placeholder="输入显示ID" - /> -
-
- - -
-
- -
-
- - handleNumberInputChange(e, "timeLimit")} - placeholder="输入时间限制" - /> -
-
- - handleNumberInputChange(e, "memoryLimit")} - placeholder="输入内存限制" - /> -
-
- -
-
- - setProblemDetails({ - ...problemDetails, - isPublished: e.target.checked, - }) - } - className="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 focus:ring-2" - /> - -
+
+ + setProblemDetails({ + ...problemDetails, + isPublished: e.target.checked, + }) + } + className="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 focus:ring-2" + /> +
- - - - +
+
+ ); } diff --git a/src/components/creater/edit-solution-panel.tsx b/src/components/creater/edit-solution-panel.tsx index 0a439f5..ff66cf6 100644 --- a/src/components/creater/edit-solution-panel.tsx +++ b/src/components/creater/edit-solution-panel.tsx @@ -12,7 +12,6 @@ import { CoreEditor } from "@/components/core-editor"; import { getProblemData } from "@/app/actions/getProblem"; import { VideoEmbed } from "@/components/content/video-embed"; import { getProblemLocales } from "@/app/actions/getProblemLocales"; -import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"; import { PanelLayout } from "@/features/problems/layouts/panel-layout"; import { updateProblemSolution } from "@/components/creater/problem-maintain"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; @@ -96,116 +95,113 @@ export default function EditSolutionPanel({ return ( - - - - 题目解析 - - - {/* 语言切换 */} -
- -
- - setCustomLocale(e.target.value)} - /> - -
-
- - {/* 标题输入 (仅展示) */} -
- - - setSolution({ ...solution, title: e.target.value }) - } - placeholder="输入题解标题" - disabled - /> -
- - {/* 编辑/预览切换 */} + + + 题目解析 + + + {/* 语言切换 */} +
+
-
+
- {/* 编辑/预览区域 */} -
+ + + setSolution({ ...solution, title: e.target.value }) + } + placeholder="输入题解标题" + disabled + /> +
+ + {/* 编辑/预览切换 */} +
+ +
- - -
-
- -
+ +
+ + {/* 编辑/预览区域 */} +
+ {(viewMode === "edit" || viewMode === "compare") && ( +
+ + setSolution({ ...solution, content: val || "" }) + } + language="markdown" + className="absolute inset-0 rounded-md border border-input" + /> +
+ )} + {viewMode !== "edit" && ( +
+ +
+ )} +
+ + +
+
); } diff --git a/src/components/creater/edit-testcase-panel.tsx b/src/components/creater/edit-testcase-panel.tsx index 931c97e..3377e8f 100644 --- a/src/components/creater/edit-testcase-panel.tsx +++ b/src/components/creater/edit-testcase-panel.tsx @@ -12,7 +12,6 @@ import { Button } from "@/components/ui/button"; import React, { useState, useEffect } from "react"; import { getProblemData } from "@/app/actions/getProblem"; import { generateAITestcase } from "@/app/actions/ai-testcase"; -import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"; import { Card, CardContent, CardHeader } from "@/components/ui/card"; import { PanelLayout } from "@/features/problems/layouts/panel-layout"; @@ -185,95 +184,85 @@ export default function EditTestcasePanel({ return ( - - - -
- 测试用例 -
- - - + + +
+
+
+ + {testcases.map((tc, idx) => ( +
+
+

测试用例 {idx + 1}

+
+
+ + + handleExpectedOutputChange(idx, e.target.value) + } + placeholder="输入预期输出" + /> +
+
+
+ + +
+ {tc.inputs.map((inp, iIdx) => ( +
+
+ + + handleInputChange(idx, iIdx, "name", e.target.value) + } + placeholder="参数名称" + /> +
+
+ + + handleInputChange(idx, iIdx, "value", e.target.value) + } + placeholder="参数值" + /> +
+ {iIdx > 0 && ( + + )} +
+ ))} +
- - - {testcases.map((tc, idx) => ( -
-
-

测试用例 {idx + 1}

- -
-
- - - handleExpectedOutputChange(idx, e.target.value) - } - placeholder="输入预期输出" - /> -
-
-
- - -
- {tc.inputs.map((inp, iIdx) => ( -
-
- - - handleInputChange(idx, iIdx, "name", e.target.value) - } - placeholder="参数名称" - /> -
-
- - - handleInputChange( - idx, - iIdx, - "value", - e.target.value - ) - } - placeholder="参数值" - /> -
- {iIdx > 0 && ( - - )} -
- ))} -
-
- ))} -
-
- -
+ ))} + +
); } diff --git a/src/features/problems/analysis/components/panel.tsx b/src/features/problems/analysis/components/panel.tsx index c8c54aa..26afcff 100644 --- a/src/features/problems/analysis/components/panel.tsx +++ b/src/features/problems/analysis/components/panel.tsx @@ -1,123 +1,14 @@ -import { - Card, - CardContent, - CardDescription, - CardHeader, - CardTitle, - CardFooter, -} from "@/components/ui/card"; -import prisma from "@/lib/prisma"; -import { - ChartDataPoint, - CodeAnalysisRadarChart, -} from "@/features/problems/analysis/components/radar-chart"; -import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"; import { PanelLayout } from "@/features/problems/layouts/panel-layout"; - -export const description = "A server component to fetch code analysis data."; +import { AnalysisContent } from "@/features/problems/analysis/components/content"; interface AnalysisPanelProps { submissionId: string | undefined; } -export const AnalysisPanel = async ({ submissionId }: AnalysisPanelProps) => { - if (!submissionId) { - return ( -
- No submission ID provided. -
- ); - } - - const codeAnalysisData = await prisma.codeAnalysis.findUnique({ - where: { - submissionId: submissionId, - }, - }); - - if (!codeAnalysisData) { - return ( -
- No analysis data found for this submission. -
- ); - } - - // Transform the data into a format suitable for the RadarChart - const chartData: ChartDataPoint[] = [ - { - kind: "overall", - score: codeAnalysisData.overallScore ?? 0, - fullMark: 100, - }, - { - kind: "style", - score: codeAnalysisData.styleScore ?? 0, - fullMark: 100, - }, - { - kind: "readability", - score: codeAnalysisData.readabilityScore ?? 0, - fullMark: 100, - }, - { - kind: "efficiency", - score: codeAnalysisData.efficiencyScore ?? 0, - fullMark: 100, - }, - { - kind: "correctness", - score: codeAnalysisData.correctnessScore ?? 0, - fullMark: 100, - }, - ]; - +export const AnalysisPanel = ({ submissionId }: AnalysisPanelProps) => { return ( - - - - - Code Analysis - - - Detailed evaluation of your code submission - - - - - - - -
-
- Overall Score - - {codeAnalysisData.overallScore ?? "N/A"} - /100 - -
-
-
-
-
- -
-

Feedback

-

- {codeAnalysisData.feedback} -

-
- - - - + ); }; diff --git a/src/features/problems/bot/components/panel.tsx b/src/features/problems/bot/components/panel.tsx index fa291db..a8a8a4d 100644 --- a/src/features/problems/bot/components/panel.tsx +++ b/src/features/problems/bot/components/panel.tsx @@ -11,7 +11,7 @@ interface BotPanelProps { export const BotPanel = ({ problemId }: BotPanelProps) => { return ( - + }> diff --git a/src/features/problems/code/components/panel.tsx b/src/features/problems/code/components/panel.tsx index ecf696f..7c888b3 100644 --- a/src/features/problems/code/components/panel.tsx +++ b/src/features/problems/code/components/panel.tsx @@ -13,7 +13,7 @@ interface CodePanelProps { export const CodePanel = ({ problemId }: CodePanelProps) => { return ( - +
}> diff --git a/src/features/problems/description/components/content.tsx b/src/features/problems/description/components/content.tsx index cd20dde..481d506 100644 --- a/src/features/problems/description/components/content.tsx +++ b/src/features/problems/description/components/content.tsx @@ -2,7 +2,6 @@ import prisma from "@/lib/prisma"; import { getLocale } from "next-intl/server"; import { Skeleton } from "@/components/ui/skeleton"; import { MdxRenderer } from "@/components/content/mdx-renderer"; -import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"; import type { Locale, ProblemLocalization } from "@/generated/client"; const getLocalizedDescription = ( @@ -40,12 +39,7 @@ export const DescriptionContent = async ({ const description = getLocalizedDescription(descriptions, locale as Locale); - return ( - - - - - ); + return ; }; export const DescriptionContentSkeleton = () => { diff --git a/src/features/problems/detail/components/panel.tsx b/src/features/problems/detail/components/panel.tsx index 75e7114..8bfe231 100644 --- a/src/features/problems/detail/components/panel.tsx +++ b/src/features/problems/detail/components/panel.tsx @@ -16,7 +16,7 @@ export const DetailPanel = ({ submissionId }: DetailPanelProps) => { } return ( - + }> diff --git a/src/features/problems/layouts/panel-layout.tsx b/src/features/problems/layouts/panel-layout.tsx index 1b09a7d..08e87bd 100644 --- a/src/features/problems/layouts/panel-layout.tsx +++ b/src/features/problems/layouts/panel-layout.tsx @@ -1,12 +1,27 @@ +import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"; + interface PanelLayoutProps { + isScroll?: boolean; children: React.ReactNode; } -export const PanelLayout = ({ children }: PanelLayoutProps) => { +export const PanelLayout = ({ + isScroll = true, + children, +}: PanelLayoutProps) => { return (
-
{children}
+
+ {isScroll ? ( + + {children} + + + ) : ( + children + )} +
); diff --git a/src/features/problems/solution/components/content.tsx b/src/features/problems/solution/components/content.tsx index 70f2970..4098de2 100644 --- a/src/features/problems/solution/components/content.tsx +++ b/src/features/problems/solution/components/content.tsx @@ -2,7 +2,6 @@ import prisma from "@/lib/prisma"; import { getLocale } from "next-intl/server"; import { Skeleton } from "@/components/ui/skeleton"; import { MdxRenderer } from "@/components/content/mdx-renderer"; -import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"; import type { Locale, ProblemLocalization } from "@/generated/client"; const getLocalizedSolution = ( @@ -38,12 +37,7 @@ export const SolutionContent = async ({ problemId }: SolutionContentProps) => { const solution = getLocalizedSolution(solutions, locale as Locale); - return ( - - - - - ); + return ; }; export const SolutionContentSkeleton = () => { diff --git a/src/features/problems/submission/components/content.tsx b/src/features/problems/submission/components/content.tsx index bd5811b..28bb51c 100644 --- a/src/features/problems/submission/components/content.tsx +++ b/src/features/problems/submission/components/content.tsx @@ -3,7 +3,6 @@ import { CodeXmlIcon } from "lucide-react"; import { useTranslations } from "next-intl"; import { Button } from "@/components/ui/button"; import { Skeleton } from "@/components/ui/skeleton"; -import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"; import { SubmissionTable } from "@/features/problems/submission/components/table"; interface SubmissionContentProps { @@ -45,11 +44,12 @@ export const SubmissionContent = async ({ const session = await auth(); const userId = session?.user?.id; - return ( - - {userId ? : } - - + return userId ? ( +
+ +
+ ) : ( + ); }; diff --git a/src/features/problems/testcase/content.tsx b/src/features/problems/testcase/content.tsx index 5e5c56a..e5bbdcf 100644 --- a/src/features/problems/testcase/content.tsx +++ b/src/features/problems/testcase/content.tsx @@ -1,18 +1,12 @@ import { Skeleton } from "@/components/ui/skeleton"; import { TestcaseTable } from "@/features/problems/testcase/table"; -import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"; interface TestcaseContentProps { problemId: string; } export const TestcaseContent = ({ problemId }: TestcaseContentProps) => { - return ( - - - - - ); + return ; }; export const TestcaseContentSkeleton = () => {