Files
ojnext/src/oj/store/problem.ts
yuetsh 9029e29148 feat: add teaching enhancement features
1. AI personalized hints after 3 failures (streaming SSE)
2. Submission error distribution panel in "my submissions" tab
3. Similar problem recommendations on AC or 3+ failures
4. Admin stuck problems analysis page

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 21:12:47 +08:00

48 lines
1.1 KiB
TypeScript

import { defineStore } from "pinia"
import { 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 languages = computed<LANGUAGE[]>(() => {
if (route.name === "problem" && problem.value?.allow_flowchart) {
return ["Flowchart", ...problem.value?.languages]
}
return problem.value?.languages ?? []
})
const totalFailCount = computed(
() => (problem.value?.my_failed_count ?? 0) + localFailCount.value,
)
function incrementFailCount() {
localFailCount.value++
}
// 切题时重置
watch(
() => problem.value?.id,
() => {
localFailCount.value = 0
},
)
return {
problem,
localFailCount,
languages,
totalFailCount,
incrementFailCount,
}
})