From 344ccd7a44b3400208a630d8d12ea80d6fcddb92 Mon Sep 17 00:00:00 2001 From: yanlongqi Date: Sat, 8 Nov 2025 07:06:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E9=A2=98=E5=BA=93?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E9=80=89=E9=A1=B9=E8=A7=A3=E6=9E=90=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 调整选项解析条件判断顺序,先检查题型再检查选项数据 - 避免非选择题类型尝试解析不存在的选项字段 - 确保简答题和论述题不会误处理选项数据 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- web/src/pages/QuestionManagement.tsx | 92 ++++++++++++++++++++-------- 1 file changed, 66 insertions(+), 26 deletions(-) diff --git a/web/src/pages/QuestionManagement.tsx b/web/src/pages/QuestionManagement.tsx index 81c2439..9254a99 100644 --- a/web/src/pages/QuestionManagement.tsx +++ b/web/src/pages/QuestionManagement.tsx @@ -161,14 +161,16 @@ const QuestionManagement: React.FC = () => { // 解析选项(仅选择题和多选题需要) let options: Record | undefined - if (values.options && (values.type === 'multiple-choice' || values.type === 'multiple-selection')) { - // 将数组格式转换为对象格式 { "A": "选项A", "B": "选项B" } - options = values.options.reduce((acc: Record, opt: any) => { - if (opt && opt.key && opt.value) { - acc[opt.key] = opt.value - } - return acc - }, {}) + if (values.type === 'multiple-choice' || values.type === 'multiple-selection') { + if (values.options && values.options.length > 0) { + // 将数组格式转换为对象格式 { "A": "选项A", "B": "选项B" } + options = values.options.reduce((acc: Record, opt: any) => { + if (opt && opt.key && opt.value) { + acc[opt.key] = opt.value + } + return acc + }, {}) + } } // 构建请求数据 @@ -284,8 +286,8 @@ const QuestionManagement: React.FC = () => { rules={[{ required: true, message: '请选择答案' }]} > - 正确 - 错误 + 正确 + 错误 ) @@ -339,12 +341,28 @@ const QuestionManagement: React.FC = () => { )} - - + prevValues.options !== currentValues.options}> + {({ getFieldValue }) => { + const options = getFieldValue('options') || [] + const optionsList = options + .filter((opt: any) => opt && opt.key) + .map((opt: any) => ({ + label: `${opt.key}. ${opt.value || '(请先填写选项内容)'}`, + value: opt.key, + })) + return ( + + + prevValues.options !== currentValues.options}> + {({ getFieldValue }) => { + const options = getFieldValue('options') || [] + const optionsList = options + .filter((opt: any) => opt && opt.key) + .map((opt: any) => ({ + label: `${opt.key}. ${opt.value || '(请先填写选项内容)'}`, + value: opt.key, + })) + return ( + +