fix(AI提示): 解锁条件前后端对齐,提示不再一点就没
Some checks failed
Deploy / deploy (push) Has been cancelled

「失败 3 次解锁 AI 提示」实际是「在当前这次页面会话里再失败 3 次」:
problemStore.failCount 是个从 0 起数的内存计数器,刷新、切题、跳进跳出就归零,
而后端闸门数的是数据库里的历史失败数,两边根本不是一回事。昨天在这题上撞了
十次墙的学生今天进来照样看不到按钮。

- 数法收成一个 countFailedSubmissions(),题目详情的 myFailedCount 和
  POST /ai/hint 共用。原来详情把「等待/正在评分」也算失败,连点三次提交就能
  把按钮点亮,点下去却回 hint-locked
- 阈值 3 挪进契约 HINT_MIN_FAILURES,两端引用同一个常量
- failCount 改成 myFailedCount + 本次会话增量;在题目页里登录的补拉一次详情,
  否则停在匿名时的 0
- 结果面板改 display-directive="show",不再一收起来就把流式输出中的提示连同
  那次 LLM 调用一起作废;补「上次结果」按钮,原来唯一的重开方式是再提交一次
- prompt 里的判题结果翻成中文,原来拼的是裸状态码,模型不知道 -1 是什么
- system_error 不计入失败数、也不显示按钮:判题机自己崩了不是学生的问题
- 比赛中不给提示,和「求助」按钮同一个口径

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RC5uL72UY9aZFuTvUKe2jv
This commit is contained in:
2026-09-06 07:24:26 -06:00
parent 2e78b6efdf
commit bb0f5ec5ef
10 changed files with 172 additions and 34 deletions

View File

@@ -5,6 +5,7 @@ import { storeToRefs } from "pinia"
import { useProblemStore } from "oj/store/problem"
import { useScreenModeStore } from "shared/store/screenMode"
import { useMyFlowchartStore } from "shared/store/myFlowchart"
import { useUserStore } from "shared/store/user"
// 抽成具名 loader便于进页面时与接口并行预取编辑器 chunk
const loadProblemEditor = () => import("./components/ProblemEditor.vue")
@@ -128,6 +129,21 @@ async function init() {
}
onMounted(init)
watch(() => problemID, init)
// 题目详情里的 myStatus / myFailedCount 是按当前用户算的,而登录不重新挂载这个页面 ——
// 会话过期后直接在题目页登录的机房里最常见的那条路不补拉一次AI 提示的解锁进度
// 就还是匿名时的 0等于白改。只换 problem不走 init那里还会重置分栏模式。
watch(
() => useUserStore().isAuthed,
async (authed) => {
if (!authed || !problem.value) return
try {
problem.value = await getProblem(problemID, contestID)
} catch {
// 拉不到就留着现在这份题面,不要把页面清空
}
},
)
onBeforeUnmount(() => {
problem.value = null
errMsg.value = "无数据"