feat(code-runner): implement execution result persistence

This commit is contained in:
cfngc4594 2025-03-01 21:23:44 +08:00
parent f63275334e
commit 164eb3f0f5

View File

@ -15,7 +15,7 @@ export default function RunCode({
className, className,
...props ...props
}: RunCodeProps) { }: RunCodeProps) {
const { language, editor } = useCodeEditorState(); const { language, editor, setResult } = useCodeEditorState();
const [isLoading, setIsLoading] = useState<boolean>(false); const [isLoading, setIsLoading] = useState<boolean>(false);
const handleJudge = async () => { const handleJudge = async () => {
@ -25,8 +25,8 @@ export default function RunCode({
setIsLoading(true); setIsLoading(true);
try { try {
const judgeResult = await judge(language, code); const result = await judge(language, code);
console.log(judgeResult); setResult(result);
} catch (error) { } catch (error) {
console.error("Error occurred while judging the code:"); console.error("Error occurred while judging the code:");
console.error(error); console.error(error);