diff --git a/src/oj/problem/components/ProblemContent.vue b/src/oj/problem/components/ProblemContent.vue index f66714e..1bbfbee 100644 --- a/src/oj/problem/components/ProblemContent.vue +++ b/src/oj/problem/components/ProblemContent.vue @@ -47,10 +47,19 @@ async function loadSimilarProblems() { similarLoaded.value = true } +// 切换题目时重置相似推荐状态 +watch( + () => problem.value?._id, + () => { + similarProblems.value = [] + similarLoaded.value = false + }, +) + // AC 或失败次数 >= 3 时加载推荐 watch( - () => [problem.value?.my_status, problemStore.totalFailCount], - ([status, failCount]) => { + () => [problem.value?._id, problem.value?.my_status, problemStore.totalFailCount], + ([, status, failCount]) => { if (status === 0 || (failCount as number) >= 3) { loadSimilarProblems() } diff --git a/src/oj/problem/detail.vue b/src/oj/problem/detail.vue index 71def80..b4a86ac 100644 --- a/src/oj/problem/detail.vue +++ b/src/oj/problem/detail.vue @@ -104,6 +104,7 @@ async function init() { } } onMounted(init) +watch(() => props.problemID, init) onBeforeUnmount(() => { problem.value = null errMsg.value = "无数据"