fix(流程图): 补上几处静默失败 —— 点了没反应、弹框永久转圈
`utils/api.ts` 的拦截器只对 login-required / account-disabled / permission-denied 弹提示,其余业务错误一律静默 reject。而流程图这一块的调用点基本都没 catch, 于是失败时用户什么都看不到: - **重新判题**:后端会拒掉还在评分中的提交(409 retry-not-allowed),也可能撞上 限流。老师点下去完全没反应,连报错都没有。实测修复前 0 条提示,修复后弹出 「这条还在评分中,等出了结果再重新评分」。 提示按**错误码**分支而不是 match 文案(`utils/api.ts` 里写明的约定)—— 后端文案是英文的,直接弹给老师看不合适。 - **课堂统计**:请求失败后图表停在旧数据上,没有任何迹象表明这次没拉到。 同一批里 `SubmitFlowchart` 的三处(弹框翻页、打开评分详情、加载到编辑器)随 上一个提交一起改了,问题是一样的:前两处失败时 `rendering` 卡在 true,弹框 永久转圈。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -195,7 +195,21 @@ async function rejudge(submissionID: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function retryFlowchart(submissionId: string) {
|
async function retryFlowchart(submissionId: string) {
|
||||||
await retryFlowchartSubmission(submissionId)
|
// 后端会拒掉「还在评分中」的提交(409 retry-not-allowed),也可能撞上限流。
|
||||||
|
// 不兜住的话拦截器静默 reject,老师点下去完全没反应。
|
||||||
|
// 按错误码分支而不是 match 文案(见 utils/api.ts 的约定)——后端文案是英文的,
|
||||||
|
// 直接弹给老师看不合适
|
||||||
|
const retryTips: Record<string, string> = {
|
||||||
|
"retry-not-allowed": "这条还在评分中,等出了结果再重新评分",
|
||||||
|
"too-many-submissions": "操作太频繁了,缓一下再试",
|
||||||
|
"flowchart-not-found": "提交不存在,或者没有权限",
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await retryFlowchartSubmission(submissionId)
|
||||||
|
} catch (err: any) {
|
||||||
|
message.error(retryTips[err?.error] ?? "重新评分失败")
|
||||||
|
return
|
||||||
|
}
|
||||||
message.success("重新评分已提交")
|
message.success("重新评分已提交")
|
||||||
listSubmissions()
|
listSubmissions()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,6 +203,8 @@ interface Props {
|
|||||||
|
|
||||||
const props = defineProps<Props>()
|
const props = defineProps<Props>()
|
||||||
|
|
||||||
|
const message = useMessage()
|
||||||
|
|
||||||
const durationOptions: SelectOption[] = [
|
const durationOptions: SelectOption[] = [
|
||||||
{ label: "10分钟内", value: "minutes:10" },
|
{ label: "10分钟内", value: "minutes:10" },
|
||||||
{ label: "20分钟内", value: "minutes:20" },
|
{ label: "20分钟内", value: "minutes:20" },
|
||||||
@@ -528,12 +530,18 @@ async function handleStatistics() {
|
|||||||
query.duration === "all"
|
query.duration === "all"
|
||||||
? { end }
|
? { end }
|
||||||
: { start: formatISO(sub(current, subOptions.value)), end }
|
: { start: formatISO(sub(current, subOptions.value)), end }
|
||||||
const res = await getFlowchartStatistics(
|
try {
|
||||||
duration,
|
const res = await getFlowchartStatistics(
|
||||||
query.problem,
|
duration,
|
||||||
query.username,
|
query.problem,
|
||||||
)
|
query.username,
|
||||||
Object.assign(data, res)
|
)
|
||||||
|
Object.assign(data, res)
|
||||||
|
} catch (error) {
|
||||||
|
message.error("获取流程图统计失败")
|
||||||
|
console.error("获取流程图统计失败:", error)
|
||||||
|
return
|
||||||
|
}
|
||||||
await nextTick()
|
await nextTick()
|
||||||
renderWordCloud()
|
renderWordCloud()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user