diff --git a/src/oj/problem/components/ProblemSubmission.vue b/src/oj/problem/components/ProblemSubmission.vue index 0b5f9f3..b285e2b 100644 --- a/src/oj/problem/components/ProblemSubmission.vue +++ b/src/oj/problem/components/ProblemSubmission.vue @@ -102,6 +102,7 @@ async function listSubmissions() { } async function getRankOfThisProblem() { + loading.value = true const res = await getRankOfProblem(route.params.problemID ?? "") loading.value = false @@ -114,7 +115,9 @@ async function getRankOfThisProblem() { onMounted(() => { listSubmissions() - getRankOfThisProblem() + if (route.name === "problem") { + getRankOfThisProblem() + } }) watch(query, listSubmissions) diff --git a/src/oj/problem/detail.vue b/src/oj/problem/detail.vue index ca825a3..addb56c 100644 --- a/src/oj/problem/detail.vue +++ b/src/oj/problem/detail.vue @@ -36,6 +36,42 @@ const props = withDefaults(defineProps(), { }) const errMsg = ref("无数据") +const route = useRoute() +const router = useRouter() + +const tabOptions = computed(() => { + const options: string[] = ["content"] + if (isMobile.value) { + options.push("editor") + } + options.push("info") + if (!props.contestID) { + options.push("comment") + } + options.push("submission") + return options +}) + +const currentTab = ref("content") + +watch( + [() => route.query.tab, () => tabOptions.value], + ([rawTab]) => { + const tabs = tabOptions.value + const fallback = tabs[0] ?? "content" + currentTab.value = tabs.includes(rawTab as string) + ? (rawTab as string) + : fallback + }, + { immediate: true }, +) + +watch(currentTab, (tab) => { + if (!tabOptions.value.includes(tab) || route.query.tab === tab) return + router.replace({ + query: { ...route.query, tab }, + }) +}) async function init() { resetScreenMode() @@ -69,7 +105,7 @@ watch(isMobile, (value) => { > - + @@ -84,7 +120,7 @@ watch(isMobile, (value) => { - +