From fa1d166a48c4d7e16b978af96e4b5e0f22b24b68 Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Thu, 7 May 2026 07:34:18 -0600 Subject: [PATCH] add username for ai analysis --- src/oj/ai/analysis.vue | 28 +++++++++++++++++++++++----- src/oj/api.ts | 12 ++++++------ src/oj/store/ai.ts | 8 +++++--- 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/src/oj/ai/analysis.vue b/src/oj/ai/analysis.vue index c794e88..76275ad 100644 --- a/src/oj/ai/analysis.vue +++ b/src/oj/ai/analysis.vue @@ -5,11 +5,22 @@ 请选择时间范围,智能分析学习情况 - + + + + @@ -64,9 +75,11 @@ import EfficiencyChart from "./components/EfficiencyChart.vue" import AI from "./components/AI.vue" import SolvedTable from "./components/SolvedTable.vue" import { useAIStore } from "../store/ai" +import { useUserStore } from "shared/store/user" import { DURATION_OPTIONS } from "utils/constants" const aiStore = useAIStore() +const userStore = useUserStore() const { isDesktop } = useBreakpoints() @@ -89,6 +102,11 @@ const end = computed(() => { return formatISO(new Date()) }) +function onUsernameChange() { + aiStore.fetchHeatmapData() + aiStore.fetchAnalysisData(start.value, end.value, aiStore.duration) +} + // 获取热力图数据(仅一次) onMounted(() => { aiStore.fetchHeatmapData() diff --git a/src/oj/api.ts b/src/oj/api.ts index 8a77a28..4f0e44d 100644 --- a/src/oj/api.ts +++ b/src/oj/api.ts @@ -287,16 +287,16 @@ export function getTutorials() { return http.get("tutorials") } -export function getAIDetailData(start: string, end: string) { - return http.get("ai/detail", { params: { start, end } }) +export function getAIDetailData(start: string, end: string, username?: string) { + return http.get("ai/detail", { params: { start, end, username } }) } -export function getAIDurationData(end: string, duration: string) { - return http.get("ai/duration", { params: { end, duration } }) +export function getAIDurationData(end: string, duration: string, username?: string) { + return http.get("ai/duration", { params: { end, duration, username } }) } -export function getAIHeatmapData() { - return http.get("ai/heatmap") +export function getAIHeatmapData(username?: string) { + return http.get("ai/heatmap", { params: username ? { username } : {} }) } export function getAILoginSummary() { diff --git a/src/oj/store/ai.ts b/src/oj/store/ai.ts index 27ab04e..a324f7a 100644 --- a/src/oj/store/ai.ts +++ b/src/oj/store/ai.ts @@ -5,6 +5,7 @@ import { getCSRFToken } from "utils/functions" export const useAIStore = defineStore("ai", () => { const duration = ref("months:6") + const targetUsername = ref("") const durationData = ref([]) const detailsData = reactive({ start: "", @@ -28,7 +29,7 @@ export const useAIStore = defineStore("ai", () => { const mdContent = ref("") async function fetchDetailsData(start: string, end: string) { - const res = await getAIDetailData(start, end) + const res = await getAIDetailData(start, end, targetUsername.value || undefined) detailsData.start = res.data.start detailsData.end = res.data.end detailsData.solved = res.data.solved @@ -41,13 +42,13 @@ export const useAIStore = defineStore("ai", () => { } async function fetchDurationData(end: string, duration: string) { - const res = await getAIDurationData(end, duration) + const res = await getAIDurationData(end, duration, targetUsername.value || undefined) durationData.value = res.data } async function fetchHeatmapData() { loading.heatmap = true - const res = await getAIHeatmapData() + const res = await getAIHeatmapData(targetUsername.value || undefined) heatmapData.value = res.data loading.heatmap = false } @@ -155,6 +156,7 @@ export const useAIStore = defineStore("ai", () => { detailsData, heatmapData, duration, + targetUsername, loading, mdContent, }