diff --git a/src/app/(app)/problem-editor/[problemId]/page.tsx b/src/app/(app)/problem-editor/[problemId]/page.tsx new file mode 100644 index 0000000..44bb27f --- /dev/null +++ b/src/app/(app)/problem-editor/[problemId]/page.tsx @@ -0,0 +1,32 @@ +"use client"; + +import { ProblemFlexLayout } from "@/features/problems/components/problem-flexlayout"; +import { EditDescriptionPanel } from "@/components/creater/edit-description-panel"; +import { EditSolutionPanel } from "@/components/creater/edit-solution-panel"; +import { EditTestcasePanel } from "@/components/creater/edit-testcase-panel"; +import { EditDetailPanel } from "@/components/creater/edit-detail-panel"; +import { EditCodePanel } from "@/components/creater/edit-code-panel"; + +interface ProblemEditorPageProps { + params: Promise<{ problemId: string }>; +} + +export default async function ProblemEditorPage({ + params, +}: ProblemEditorPageProps) { + const { problemId } = await params; + + const components: Record = { + description: , + solution: , + detail: , + code: , + testcase: , + }; + + return ( +
+ +
+ ); +} \ No newline at end of file diff --git a/src/components/creater/edit-code-panel.tsx b/src/components/creater/edit-code-panel.tsx new file mode 100644 index 0000000..5af31d6 --- /dev/null +++ b/src/components/creater/edit-code-panel.tsx @@ -0,0 +1,80 @@ +"use client"; + +import { useState } from "react"; +import { Label } from "@/components/ui/label"; +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; +import { Button } from "@/components/ui/button"; +import { CoreEditor } from "@/components/core-editor"; + +interface Template { + id: string; + language: string; + code: string; +} + +interface EditCodePanelProps { + problemId: string; +} + +export const EditCodePanel = ({ + problemId, +}: EditCodePanelProps) => { + const [language, setLanguage] = useState("typescript"); + const [templates, setTemplates] = useState([ + { + id: "1", + language: "typescript", + code: `// TypeScript模板示例\nfunction twoSum(nums: number[], target: number): number[] {\n const map = new Map();\n for (let i = 0; i < nums.length; i++) {\n const complement = target - nums[i];\n if (map.has(complement)) {\n return [map.get(complement), i];\n }\n map.set(nums[i], i);\n }\n return [];\n}` + }, + { + id: "2", + language: "python", + code: "# Python模板示例\ndef two_sum(nums, target):\n num_dict = {}\n for i, num in enumerate(nums):\n complement = target - num\n if complement in num_dict:\n return [num_dict[complement], i]\n num_dict[num] = i\n return []" + } + ]); + + const currentTemplate = templates.find(t => t.language === language) || templates[0]; + + const handleCodeChange = (value: string | undefined) => { + if (!value) return; + + setTemplates(templates.map(t => + t.language === language + ? { ...t, code: value } + : t + )); + }; + + return ( +
+
+ + +
+ +
+ {currentTemplate && ( + + )} +
+ + +
+ ); +}; \ No newline at end of file diff --git a/src/components/creater/edit-description-panel.tsx b/src/components/creater/edit-description-panel.tsx new file mode 100644 index 0000000..ef0cbcc --- /dev/null +++ b/src/components/creater/edit-description-panel.tsx @@ -0,0 +1,75 @@ +"use client"; + +import { useState } from "react"; +import { Label } from "@/components/ui/label"; +import { Input } from "@/components/ui/input"; +import { Textarea } from "@/components/ui/textarea"; +import { Button } from "@/components/ui/button"; +import MdxPreview from "@/components/mdx-preview"; + +interface EditDescriptionPanelProps { + problemId: string; +} + +export const EditDescriptionPanel = ({ + problemId, +}: EditDescriptionPanelProps) => { + const [title, setTitle] = useState(`Problem ${problemId} Title`); + const [content, setContent] = useState(`Problem ${problemId} Description Content...`); + const [viewMode, setViewMode] = useState<'edit' | 'preview' | 'compare'>('edit'); + + return ( +
+
+ + setTitle(e.target.value)} + placeholder="输入题目标题" + /> +
+
+ + + +
+ +
+
+