fix
This commit is contained in:
@@ -61,7 +61,7 @@ watch(
|
|||||||
() => [
|
() => [
|
||||||
problem.value?._id,
|
problem.value?._id,
|
||||||
problem.value?.my_status,
|
problem.value?.my_status,
|
||||||
problemStore.totalFailCount,
|
problemStore.failCount,
|
||||||
],
|
],
|
||||||
([, status, failCount]) => {
|
([, status, failCount]) => {
|
||||||
if (status === 0 || (failCount as number) >= 3) {
|
if (status === 0 || (failCount as number) >= 3) {
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ const msg = computed(() => {
|
|||||||
const showAIHint = computed(() => {
|
const showAIHint = computed(() => {
|
||||||
if (!props.submission) return false
|
if (!props.submission) return false
|
||||||
return (
|
return (
|
||||||
problemStore.totalFailCount >= 3 &&
|
problemStore.failCount >= 3 &&
|
||||||
props.submission.result !== SubmissionStatus.accepted &&
|
props.submission.result !== SubmissionStatus.accepted &&
|
||||||
props.submission.result !== SubmissionStatus.pending &&
|
props.submission.result !== SubmissionStatus.pending &&
|
||||||
props.submission.result !== SubmissionStatus.judging &&
|
props.submission.result !== SubmissionStatus.judging &&
|
||||||
|
|||||||
@@ -1,19 +1,12 @@
|
|||||||
import { defineStore } from "pinia"
|
import { defineStore } from "pinia"
|
||||||
import { LANGUAGE, Problem } from "utils/types"
|
import type { LANGUAGE, Problem } from "utils/types"
|
||||||
|
|
||||||
/**
|
|
||||||
* 题目状态管理 Store
|
|
||||||
* 管理当前题目的信息
|
|
||||||
*/
|
|
||||||
export const useProblemStore = defineStore("problem", () => {
|
export const useProblemStore = defineStore("problem", () => {
|
||||||
// ==================== 状态 ====================
|
|
||||||
const problem = ref<Problem | null>(null)
|
const problem = ref<Problem | null>(null)
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|
||||||
// 本次会话内累计的失败次数(与服务端 my_failed_count 叠加)
|
const failCount = ref(0)
|
||||||
const localFailCount = ref(0)
|
|
||||||
|
|
||||||
// ==================== 计算属性 ====================
|
|
||||||
const languages = computed<LANGUAGE[]>(() => {
|
const languages = computed<LANGUAGE[]>(() => {
|
||||||
if (route.name === "problem" && problem.value?.allow_flowchart) {
|
if (route.name === "problem" && problem.value?.allow_flowchart) {
|
||||||
return ["Flowchart", ...problem.value?.languages]
|
return ["Flowchart", ...problem.value?.languages]
|
||||||
@@ -21,27 +14,21 @@ export const useProblemStore = defineStore("problem", () => {
|
|||||||
return problem.value?.languages ?? []
|
return problem.value?.languages ?? []
|
||||||
})
|
})
|
||||||
|
|
||||||
const totalFailCount = computed(
|
|
||||||
() => (problem.value?.my_failed_count ?? 0) + localFailCount.value,
|
|
||||||
)
|
|
||||||
|
|
||||||
function incrementFailCount() {
|
function incrementFailCount() {
|
||||||
localFailCount.value++
|
failCount.value++
|
||||||
}
|
}
|
||||||
|
|
||||||
// 切题时重置
|
|
||||||
watch(
|
watch(
|
||||||
() => problem.value?.id,
|
() => problem.value?.id,
|
||||||
() => {
|
() => {
|
||||||
localFailCount.value = 0
|
failCount.value = 0
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
problem,
|
problem,
|
||||||
localFailCount,
|
failCount,
|
||||||
languages,
|
languages,
|
||||||
totalFailCount,
|
|
||||||
incrementFailCount,
|
incrementFailCount,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user