From ef7aa4457752383ef0ee2062921693e099f557c7 Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Tue, 19 May 2026 04:29:04 -0600 Subject: [PATCH] fix --- src/oj/problem/components/ProblemContent.vue | 2 +- .../problem/components/SubmissionResult.vue | 2 +- src/oj/store/problem.ts | 23 ++++--------------- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/src/oj/problem/components/ProblemContent.vue b/src/oj/problem/components/ProblemContent.vue index 9266862..7df89b9 100644 --- a/src/oj/problem/components/ProblemContent.vue +++ b/src/oj/problem/components/ProblemContent.vue @@ -61,7 +61,7 @@ watch( () => [ problem.value?._id, problem.value?.my_status, - problemStore.totalFailCount, + problemStore.failCount, ], ([, status, failCount]) => { if (status === 0 || (failCount as number) >= 3) { diff --git a/src/oj/problem/components/SubmissionResult.vue b/src/oj/problem/components/SubmissionResult.vue index 9f676c6..7cea1d6 100644 --- a/src/oj/problem/components/SubmissionResult.vue +++ b/src/oj/problem/components/SubmissionResult.vue @@ -51,7 +51,7 @@ const msg = computed(() => { const showAIHint = computed(() => { if (!props.submission) return false return ( - problemStore.totalFailCount >= 3 && + problemStore.failCount >= 3 && props.submission.result !== SubmissionStatus.accepted && props.submission.result !== SubmissionStatus.pending && props.submission.result !== SubmissionStatus.judging && diff --git a/src/oj/store/problem.ts b/src/oj/store/problem.ts index 1ebb42f..ead60ec 100644 --- a/src/oj/store/problem.ts +++ b/src/oj/store/problem.ts @@ -1,19 +1,12 @@ import { defineStore } from "pinia" -import { LANGUAGE, Problem } from "utils/types" +import type { LANGUAGE, Problem } from "utils/types" -/** - * 题目状态管理 Store - * 管理当前题目的信息 - */ export const useProblemStore = defineStore("problem", () => { - // ==================== 状态 ==================== const problem = ref(null) const route = useRoute() - // 本次会话内累计的失败次数(与服务端 my_failed_count 叠加) - const localFailCount = ref(0) + const failCount = ref(0) - // ==================== 计算属性 ==================== const languages = computed(() => { if (route.name === "problem" && problem.value?.allow_flowchart) { return ["Flowchart", ...problem.value?.languages] @@ -21,27 +14,21 @@ export const useProblemStore = defineStore("problem", () => { return problem.value?.languages ?? [] }) - const totalFailCount = computed( - () => (problem.value?.my_failed_count ?? 0) + localFailCount.value, - ) - function incrementFailCount() { - localFailCount.value++ + failCount.value++ } - // 切题时重置 watch( () => problem.value?.id, () => { - localFailCount.value = 0 + failCount.value = 0 }, ) return { problem, - localFailCount, + failCount, languages, - totalFailCount, incrementFailCount, } })