From 9e23d28f62b8f1391b380f2a43588e32b26558b9 Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Mon, 12 Oct 2026 10:55:45 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E8=87=AA=E5=AD=A6):=20=E6=95=99=E7=A8=8B?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=9D=97=E8=BE=93=E5=85=A5=E6=A1=86=E7=A9=BA?= =?UTF-8?q?=E7=9D=80=E5=B0=B1=E8=BF=90=E8=A1=8C=EF=BC=8C=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E8=AF=B4=E6=88=90=E3=80=8Cinput()=20=E7=94=A8=E7=9A=84?= =?UTF-8?q?=E6=AC=A1=E6=95=B0=E8=B6=85=E8=BF=87=E4=BA=86=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E7=9A=84=E8=A1=8C=E6=95=B0=E3=80=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- .../src/oj/learn/components/CodeRunBlock.vue | 36 +++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/apps/web/src/oj/learn/components/CodeRunBlock.vue b/apps/web/src/oj/learn/components/CodeRunBlock.vue index 5e292ce..e99dcaa 100644 --- a/apps/web/src/oj/learn/components/CodeRunBlock.vue +++ b/apps/web/src/oj/learn/components/CodeRunBlock.vue @@ -36,7 +36,7 @@ const running = ref(false) type Outcome = | { kind: "output"; text: string } - | { kind: "error"; title: string; message: string; raw: string } + | { kind: "error"; title: string; message: string; raw: string; needInput?: boolean } | { kind: "busy"; message: string } const outcome = ref(null) @@ -85,6 +85,26 @@ function runtimeOutcome( output: string, info: NonNullable | undefined, ): Outcome { + // 读输入读到头了:题目页那句「input() 用的次数超过了输入的行数」是说程序写错了, + // 教程里多半是下面的输入框还空着,要说的是「先填输入」 + if (result === SubmissionStatus.runtime_error && info?.type === "EOFError") { + return input.value.trim() + ? { + kind: "error", + title: "输入不够", + message: + "程序每执行一次 input() 就读一行。输入框里的行数比它要读的少,按一行一个再多填几行。", + raw: cleanRaw(output), + needInput: true, + } + : { + kind: "error", + title: "还没填输入", + message: "程序运行到 input() 在等你输入内容。先在上面的「输入」框里填好,再点运行。", + raw: cleanRaw(output), + needInput: true, + } + } if (result === SubmissionStatus.runtime_error) { return { kind: "error", @@ -185,7 +205,11 @@ async function copyCode() {
-
+
输入