fix
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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 &&
|
||||
|
||||
@@ -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<Problem | null>(null)
|
||||
const route = useRoute()
|
||||
|
||||
// 本次会话内累计的失败次数(与服务端 my_failed_count 叠加)
|
||||
const localFailCount = ref(0)
|
||||
const failCount = ref(0)
|
||||
|
||||
// ==================== 计算属性 ====================
|
||||
const languages = computed<LANGUAGE[]>(() => {
|
||||
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,
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user