feat: show yearly AC rate chart on problem info page
Some checks failed
Deploy / deploy (build, debian, 22, /root/OJDeploy/data/clientnext) (push) Has been cancelled
Deploy / deploy (build:staging, school, 8822, /root/OJ/data/dist) (push) Has been cancelled

This commit is contained in:
2026-05-11 00:22:47 -06:00
parent ead9af2217
commit 8a6858d6de

View File

@@ -14,6 +14,8 @@ import {
Colors, Colors,
} from "chart.js" } from "chart.js"
import { getProblemBeatRate } from "oj/api" import { getProblemBeatRate } from "oj/api"
import { getProblemYearlyAC, type YearlyACData } from "oj/api"
import ProblemYearlyChart from "./ProblemYearlyChart.vue"
import { useBreakpoints } from "shared/composables/breakpoints" import { useBreakpoints } from "shared/composables/breakpoints"
// 仅注册饼图所需的 Chart.js 组件 // 仅注册饼图所需的 Chart.js 组件
@@ -25,6 +27,7 @@ const { problem } = storeToRefs(problemStore)
const { isDesktop } = useBreakpoints() const { isDesktop } = useBreakpoints()
const beatRate = ref("0") const beatRate = ref("0")
const yearlyACData = ref<YearlyACData[]>([])
const data = computed(() => { const data = computed(() => {
const status = problem.value!.statistic_info const status = problem.value!.statistic_info
@@ -90,7 +93,15 @@ async function getBeatRate() {
beatRate.value = res.data beatRate.value = res.data
} }
onMounted(getBeatRate) async function getYearlyAC() {
const res = await getProblemYearlyAC(problem.value!._id)
yearlyACData.value = res.data
}
onMounted(() => {
getBeatRate()
getYearlyAC()
})
</script> </script>
<template> <template>
@@ -142,6 +153,7 @@ onMounted(getBeatRate)
<div class="pie" v-if="problem && problem.submission_number > 0"> <div class="pie" v-if="problem && problem.submission_number > 0">
<Pie :data="data" :options="options" /> <Pie :data="data" :options="options" />
</div> </div>
<ProblemYearlyChart :data="yearlyACData" />
</template> </template>
<style scoped> <style scoped>
.cards { .cards {