From 0b627b5157d0d426da805b391772221b05776932 Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Fri, 3 Jul 2026 01:31:08 -0600 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=AE=A1=E7=90=86=E7=AB=AF=20SQL=20?= =?UTF-8?q?=E9=A2=98=E9=9A=90=E8=97=8F=E8=BE=93=E5=85=A5=E8=BE=93=E5=87=BA?= =?UTF-8?q?=E6=8F=8F=E8=BF=B0=E4=B8=8E=E6=A0=B7=E4=BE=8B=E8=A1=A8=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 隐藏 SQL 题的输入/输出描述编辑器 - 隐藏 SQL 题的样例编辑区域 - 跳过 SQL 题的输入输出和样例验证 - SQL 题提交时清空样例数组 Co-Authored-By: Claude Fable 5 --- src/admin/problem/detail.vue | 79 ++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 35 deletions(-) diff --git a/src/admin/problem/detail.vue b/src/admin/problem/detail.vue index a715997..b207105 100644 --- a/src/admin/problem/detail.vue +++ b/src/admin/problem/detail.vue @@ -344,19 +344,20 @@ async function validateProblem() { // 题目 else if ( !problem.value.description || - !problem.value.input_description || - !problem.value.output_description + (!isSQLProblem.value && + (!problem.value.input_description || !problem.value.output_description)) ) { message.error("题目或输入或输出没有填写") hasErrors = true } // 样例 - else if (problem.value.samples.length == 0) { + else if (!isSQLProblem.value && problem.value.samples.length == 0) { message.error("样例没有填写") hasErrors = true } // 样例是空的 else if ( + !isSQLProblem.value && problem.value.samples.some( (sample) => sample.output === "" || sample.input === "", ) @@ -432,12 +433,18 @@ function filterAnswers() { ) } +function filterSamplesForSQL() { + // SQL 题不展示样例;后端 CreateSampleSerializer 也不接受空字符串样例 + if (isSQLProblem.value) problem.value.samples = [] +} + async function submit() { const hasValidationErrors = await validateProblem() if (hasValidationErrors) return filterHint() getTemplate() filterAnswers() + filterSamplesForSQL() syncProblemTags() const api = { "admin problem create": createProblem, @@ -592,45 +599,47 @@ watch( :min-height="300" /> -
- - 测试样例 {{ index + 1 }} - - 删除 {{ index + 1 }} - - - - - - 输入样例 - - - - - - 输出样例 - - - - -
- - 添加用例 - +