From 6ebf8fe935d2d50aed78330fb2253b070e94bd6c Mon Sep 17 00:00:00 2001 From: cfngc4594 Date: Mon, 3 Mar 2025 18:36:22 +0800 Subject: [PATCH] refactor(problem-submission-page): simplify result destructuring and memo dependencies --- .../playground/@problem/@submission/page.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/app/(app)/playground/@problem/@submission/page.tsx b/src/app/(app)/playground/@problem/@submission/page.tsx index 79f39bd..8e9b801 100644 --- a/src/app/(app)/playground/@problem/@submission/page.tsx +++ b/src/app/(app)/playground/@problem/@submission/page.tsx @@ -2,14 +2,22 @@ import { useMemo } from 'react'; import MdxPreview from "@/components/mdx-preview"; -import { useCodeEditorState } from "@/store/useCodeEditor"; +import { useCodeEditorStore } from "@/store/useCodeEditorStore"; export default function ProblemSubmissionPage() { - const { result } = useCodeEditorState(); + const { result } = useCodeEditorStore(); + const { exitCode, output, executionTime, memoryUsage } = result || {}; const template = useMemo(() => { - return `\`\`\`bash\n${result || ""}\n\`\`\``; - }, [result]); + return ` + ${exitCode || ""} + \`\`\`bash + ${output || ""} + \`\`\` + ${executionTime || ""} + ${memoryUsage || ""} + `; + }, [exitCode, output, executionTime, memoryUsage]); return ; }