feat(题目): 工具栏加「运行例子」、结果页签加「自己输入」,去掉每个例子旁的「测试」和顶栏的分栏切换
Deploy / deploy (push) Canceled after 0s

- 工具栏「运行例子」:一键用全部例子试跑(Judge0,不算提交),结果进「结果 › 运行例子」,
  每个例子 ✓ / ✕,没对上的沿用答案错误那套中文说明;比赛里只摆输出、不给提示句
  (后端在比赛里故意不做例子对比);SQL 题不给
- 「结果」页签分成提交结果 / 运行例子 / 自己输入三段;「自己输入」顶替顶栏「自测」模式
  那个单独的编辑器
- 试跑出错(编译、运行、超时)给中文说明,Judge0 的英文原文折叠起来
- 例子比对两边都去掉末尾空白:原来只 trim 了运行输出,样例末尾带空格的题永远「不通过」
- 去掉题面里每个例子旁的「测试」、顶栏的「双栏 / 自测 / 题目」切换、EditorForTest 和
  screenMode store

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
xuyueandClaude Opus 5.5 committed 2026-09-28 14:35:58 +08:00
1 parent f4db7dc81c
commit 45505e8384
16 files changed
+562 -374

No files matched your search

@@ -1,34 +1,59 @@
<script setup lang="ts">
import { storeToRefs } from "pinia"
import { useProblemStore } from "oj/store/problem"
import { useSubmissionStore } from "oj/store/submission"
/**
* 左栏「结果」页签的内容:提交前语法检查没过的说明、这一次提交的判题结果,或者空状态。
* 左栏「结果」页签:三段 —— 提交结果 / 运行例子 / 自己输入。
*
* 原来是提交按钮下面的一个浮层(n-popover),点一下外面就收起、最高 600px、盖住编辑器,
* 学生没法一边看「正确输出 / 你的输出」一边改代码。放进左栏页签之后编辑器整列都在,
* 改代码时结果就摆在旁边(见 docs/specs/2026-09-28-problem-page-redesign-design.md)。
* 原来提交结果是提交按钮下面的一个浮层(n-popover),点一下外面就收起、最高 600px、
* 盖住编辑器;运行例子是题面里每个例子旁的「测试」按钮,只给通过 / 不通过、2 秒后复位;
* 自己输入是顶栏「自测」模式里单独的一个编辑器。现在三样都在这一个页签里,
* 编辑器整列都在,改代码时结果就摆在旁边(见 docs/specs/2026-09-28-problem-page-redesign-design.md)。
*/
// 第一次切到「结果」时才加载:它带着 DataTable 和 Markdown 渲染,只看题不提交的人不用付
const SubmissionResult = defineAsyncComponent(() => import("./SubmissionResult.vue"))
const PythonErrorExplain = defineAsyncComponent(() => import("./PythonErrorExplain.vue"))
const SampleRunResult = defineAsyncComponent(() => import("./SampleRunResult.vue"))
const CustomRun = defineAsyncComponent(() => import("./CustomRun.vue"))
const { submission, syntaxErrorInfo } = storeToRefs(useSubmissionStore())
const submissionStore = useSubmissionStore()
const { submission, syntaxErrorInfo, resultSegment } = storeToRefs(submissionStore)
const { problem } = storeToRefs(useProblemStore())
// 试跑走 Judge0,它跑不了 SQL;流程图也没得跑。这两种只留「提交结果」
const canTrial = computed(() => {
const languages = problem.value?.languages ?? []
return !languages.includes("SQL")
})
</script>
<template>
<div class="result-pane">
<n-flex v-if="syntaxErrorInfo" vertical>
<n-alert type="warning" title="代码有语法错误,还没有提交" />
<PythonErrorExplain :err-info="syntaxErrorInfo" />
</n-flex>
<SubmissionResult v-else-if="submission" :submission="submission" />
<n-empty
v-else
class="empty"
description="还没有提交过。写完代码按「提交代码」,结果会出现在这里"
/>
<n-radio-group v-if="canTrial" v-model:value="resultSegment" size="small" class="segments">
<n-radio-button value="submit">提交结果</n-radio-button>
<n-radio-button value="samples">运行例子</n-radio-button>
<n-radio-button value="custom">自己输入</n-radio-button>
</n-radio-group>
<!-- 提交结果用 v-show:切去看运行例子时不卸载,挂着的错误说明在编辑器里标着红 -->
<div v-show="resultSegment === 'submit' || !canTrial">
<n-flex v-if="syntaxErrorInfo" vertical>
<n-alert type="warning" title="代码有语法错误,还没有提交" />
<PythonErrorExplain :err-info="syntaxErrorInfo" />
</n-flex>
<SubmissionResult v-else-if="submission" :submission="submission" />
<n-empty
v-else
class="empty"
description="还没有提交过。写完代码按「提交代码」,结果会出现在这里"
/>
</div>
<template v-if="canTrial">
<SampleRunResult v-if="resultSegment === 'samples'" />
<CustomRun v-else-if="resultSegment === 'custom'" />
</template>
</div>
</template>
@@ -37,6 +62,10 @@ const { submission, syntaxErrorInfo } = storeToRefs(useSubmissionStore())
padding: 4px 0 16px;
}
.segments {
margin-bottom: 14px;
}
.empty {
margin-top: 48px;
}