出题表单:修复 SQL 题崩溃并隐藏流程图区域
流程图区域的"AI 生成"按钮读取 problem.answers 里 language==='Python3' 的 第一项 .code,SQL 题(languages=["SQL"])没有 Python3 答案,[0] 为 undefined,导致模板抛 TypeError 崩溃整个出题页。 流程图功能本身依赖 Python 答案生成 Mermaid 代码,对 SQL 题没有意义, 和已隐藏的"代码规则检查"一样直接整块隐藏(切到 SQL 时顺带重置 allow_flowchart/show_flowchart,避免脏数据)。顺手给禁用态判断加了 可选链,修掉未选 Python3 时同样会崩的潜在问题(如仅选 C/C++ 的题目)。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -202,6 +202,9 @@ watch(
|
|||||||
if (problem.value.ast_rules) {
|
if (problem.value.ast_rules) {
|
||||||
problem.value.ast_rules = null
|
problem.value.ast_rules = null
|
||||||
}
|
}
|
||||||
|
// 流程图依赖 Python 答案生成,对 SQL 没有意义
|
||||||
|
problem.value.allow_flowchart = false
|
||||||
|
problem.value.show_flowchart = false
|
||||||
} else if (problem.value.sql_config) {
|
} else if (problem.value.sql_config) {
|
||||||
problem.value.sql_config = null
|
problem.value.sql_config = null
|
||||||
}
|
}
|
||||||
@@ -844,6 +847,7 @@ watch(
|
|||||||
/>
|
/>
|
||||||
</n-modal>
|
</n-modal>
|
||||||
|
|
||||||
|
<template v-if="!isSQLProblem">
|
||||||
<n-divider />
|
<n-divider />
|
||||||
|
|
||||||
<h2 class="title">流程图区域</h2>
|
<h2 class="title">流程图区域</h2>
|
||||||
@@ -855,7 +859,7 @@ watch(
|
|||||||
type="primary"
|
type="primary"
|
||||||
size="small"
|
size="small"
|
||||||
:disabled="
|
:disabled="
|
||||||
!problem.answers.filter((a) => a.language === 'Python3')[0].code
|
!problem.answers.filter((a) => a.language === 'Python3')[0]?.code
|
||||||
.length
|
.length
|
||||||
"
|
"
|
||||||
:loading="isAIGenerating"
|
:loading="isAIGenerating"
|
||||||
@@ -886,6 +890,7 @@ watch(
|
|||||||
/>
|
/>
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
</n-form>
|
</n-form>
|
||||||
|
</template>
|
||||||
<n-flex style="margin-bottom: 120px" align="center" justify="end">
|
<n-flex style="margin-bottom: 120px" align="center" justify="end">
|
||||||
<n-button type="primary" @click="submit">提交</n-button>
|
<n-button type="primary" @click="submit">提交</n-button>
|
||||||
</n-flex>
|
</n-flex>
|
||||||
|
|||||||
Reference in New Issue
Block a user