From 012ca82d76207982cd1a6c02f5f7b34ba8959fb1 Mon Sep 17 00:00:00 2001 From: cfngc4594 Date: Thu, 19 Jun 2025 17:54:35 +0800 Subject: [PATCH] feat(admin): Implement admin problem editing and protected routing --- .../(app)/problem-editor/[problemId]/page.tsx | 121 ------------------ 1 file changed, 121 deletions(-) delete mode 100644 src/app/(app)/problem-editor/[problemId]/page.tsx diff --git a/src/app/(app)/problem-editor/[problemId]/page.tsx b/src/app/(app)/problem-editor/[problemId]/page.tsx deleted file mode 100644 index 3e2be4c..0000000 --- a/src/app/(app)/problem-editor/[problemId]/page.tsx +++ /dev/null @@ -1,121 +0,0 @@ -"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'; -import { updateProblem } from '@/app/actions/updateProblem'; - -interface ProblemEditorPageProps { - params: Promise<{ problemId: string }>; -} - -interface UpdateData { - content: string; - language?: 'c' | 'cpp'; - inputs?: Array<{ index: number; name: string; value: string }>; -} - -const handleUpdate = async ( - updateFn: (data: UpdateData) => Promise<{ success: boolean }>, - data: UpdateData -) => { - try { - const result = await updateFn(data); - if (!result.success) { - // 这里可以添加更具体的错误处理 - } - return result; - } catch (error) { - console.error('更新失败:', error); - return { success: false }; - } -}; - -export default async function ProblemEditorPage({ - params, -}: ProblemEditorPageProps) { - const { problemId } = await params; - - const components: Record = { - description: { - await handleUpdate( - (descriptionData) => updateProblem({ - problemId, - displayId: 0, - description: descriptionData.content - }), - data - ); - }} - />, - solution: { - await handleUpdate( - (solutionData) => updateProblem({ - problemId, - displayId: 0, - solution: solutionData.content - }), - data - ); - }} - />, - detail: { - await handleUpdate( - (detailData) => updateProblem({ - problemId, - displayId: 0, - detail: detailData.content - }), - data - ); - }} - />, - code: { - await handleUpdate( - (codeData) => updateProblem({ - problemId, - displayId: 0, - templates: [{ - language: codeData.language || 'c', // 添加默认值 - content: codeData.content - }] - }), - data - ); - }} - />, - testcase: { - await handleUpdate( - (testcaseData) => updateProblem({ - problemId, - displayId: 0, - testcases: [{ - expectedOutput: testcaseData.content, - inputs: testcaseData.inputs || [] // 添加默认空数组 - }] - }), - data - ); - }} - /> - }; - - return ( -
- -
- ); -} \ No newline at end of file