feat(题目): 判题结果从提交按钮下的浮层挪到左栏「结果」页签——改代码时结果就摆在旁边

原来结果是提交按钮下面的 n-popover:点一下外面就收起、最高 600px、盖住编辑器,
学生没法一边看「正确输出 / 你的输出」一边改代码,还得靠「上次结果」按钮找回来。

- 左栏新增「结果」页签(手机上排在「代码」后面),交上去或者语法检查没过就自动切过去;
  页签标题带状态图标(✕ / ✓ / ! / 判题中转圈),不只靠颜色
- 页签用 show:lazy:切走不卸载,编辑器里的错误标记、AI 提示都留着
- 「题目描述」改叫「题目」;去掉浮层和「上次结果」按钮

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
xuyueandClaude Opus 5.5 committed 2026-09-28 14:21:57 +08:00
1 parent 5cb7cfa924
commit f4db7dc81c
6 files changed
+160 -67

No files matched your search

+30 -4
View File
@@ -11,6 +11,7 @@ import { useSubmissionStore } from "oj/store/submission"
import { useFlowchartStore } from "oj/store/flowchart"
// 判完之后该发生的事(烟花、点评、回题单)。静态引入:它得在第一次判完之前就挂好
import SubmissionEffects from "./components/SubmissionEffects.vue"
import ResultTabLabel from "./components/ResultTabLabel.vue"
// 抽成具名 loader,便于进页面时与接口并行预取编辑器 chunk。
// 题库、比赛、题单三种入口用的是同一个编辑器:原来比赛和题单用的是另一个精简版,
@@ -25,6 +26,7 @@ const ProblemSubmission = defineAsyncComponent(() => import("./components/Proble
const ProblemReaction = defineAsyncComponent(() => import("./components/ProblemReaction.vue"))
const ProblemFlowchart = defineAsyncComponent(() => import("./components/ProblemFlowchart.vue"))
const MyFlowchartTab = defineAsyncComponent(() => import("./components/MyFlowchartTab.vue"))
const ResultPane = defineAsyncComponent(() => import("./components/ResultPane.vue"))
interface Props {
problemID: string
@@ -55,13 +57,15 @@ const canShowFlowchart = computed(
)
const tabOptions = computed(() => {
// 桌面上「结果」紧跟在「题目」后面;手机上编辑器也是一个页签,「结果」排在「代码」后面
const options: string[] = ["content"]
if (!isMobile.value) options.push("result")
if (canShowFlowchart.value) {
options.push("flowchart")
}
if (isMobile.value) {
options.push("editor")
options.push("editor", "result")
}
options.push("info")
if (!contestID) {
@@ -93,6 +97,18 @@ watch(currentTab, (tab) => {
})
})
// 交上去、或者语法检查没过:切到「结果」。提交按钮在编辑器那边,页签归这一页管
const submissionStore = useSubmissionStore()
watch(
() => submissionStore.resultSeq,
() => {
currentTab.value = "result"
},
)
// 结果页签的标题带状态图标(ResultTabLabel),n-tab-pane 的 tab 接受渲染函数
const resultTab = () => h(ResultTabLabel)
watch(
() => myFlowchartStore.showing,
(showing) => {
@@ -175,9 +191,13 @@ watch(
<template #1>
<n-scrollbar style="height: 100%">
<n-tabs v-model:value="currentTab" type="segment">
<n-tab-pane name="content" tab="题目描述">
<n-tab-pane name="content" tab="题目">
<ProblemContent />
</n-tab-pane>
<!-- 切走也不卸载:挂着的错误说明在编辑器里标着红,AI 提示也在渲染 -->
<n-tab-pane name="result" :tab="resultTab" display-directive="show:lazy">
<ResultPane />
</n-tab-pane>
<n-tab-pane v-if="canShowFlowchart" name="flowchart" tab="流程图表">
<ProblemFlowchart />
</n-tab-pane>
@@ -210,9 +230,12 @@ watch(
<template v-else-if="isDesktop && shouldShowProblem">
<n-scrollbar style="max-height: calc(100vh - 92px)">
<n-tabs v-model:value="currentTab" type="segment">
<n-tab-pane name="content" tab="题目描述">
<n-tab-pane name="content" tab="题目">
<ProblemContent />
</n-tab-pane>
<n-tab-pane name="result" :tab="resultTab" display-directive="show:lazy">
<ResultPane />
</n-tab-pane>
<n-tab-pane v-if="canShowFlowchart" name="flowchart" tab="流程图表">
<ProblemFlowchart />
</n-tab-pane>
@@ -234,7 +257,7 @@ watch(
<!-- Mobile -->
<n-tabs v-else v-model:value="currentTab" type="segment">
<n-tab-pane name="content" tab="描述">
<n-tab-pane name="content" tab="题目">
<ProblemContent />
</n-tab-pane>
<n-tab-pane v-if="canShowFlowchart" name="flowchart" tab="流程">
@@ -243,6 +266,9 @@ watch(
<n-tab-pane name="editor" tab="代码">
<ProblemEditor />
</n-tab-pane>
<n-tab-pane name="result" :tab="resultTab" display-directive="show:lazy">
<ResultPane />
</n-tab-pane>
<n-tab-pane name="info" tab="统计" :disabled="!!problemSetId">
<ProblemInfo />
</n-tab-pane>