add username for ai analysis
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-07 07:34:18 -06:00
parent f38af4f1fe
commit fa1d166a48
3 changed files with 34 additions and 14 deletions

View File

@@ -5,11 +5,22 @@
<n-flex vertical size="large"> <n-flex vertical size="large">
<n-flex align="center" justify="space-between"> <n-flex align="center" justify="space-between">
<n-h3 style="margin: 0">请选择时间范围智能分析学习情况</n-h3> <n-h3 style="margin: 0">请选择时间范围智能分析学习情况</n-h3>
<n-select <n-flex align="center">
style="width: 140px" <n-input
:options="options" v-if="userStore.isSuperAdmin"
v-model:value="aiStore.duration" v-model:value="aiStore.targetUsername"
/> placeholder="查看指定用户"
clearable
style="width: 140px"
@change="onUsernameChange"
@clear="onUsernameChange"
/>
<n-select
style="width: 140px"
:options="options"
v-model:value="aiStore.duration"
/>
</n-flex>
</n-flex> </n-flex>
<Overview /> <Overview />
<n-grid :cols="2" :x-gap="20" :y-gap="20"> <n-grid :cols="2" :x-gap="20" :y-gap="20">
@@ -64,9 +75,11 @@ import EfficiencyChart from "./components/EfficiencyChart.vue"
import AI from "./components/AI.vue" import AI from "./components/AI.vue"
import SolvedTable from "./components/SolvedTable.vue" import SolvedTable from "./components/SolvedTable.vue"
import { useAIStore } from "../store/ai" import { useAIStore } from "../store/ai"
import { useUserStore } from "shared/store/user"
import { DURATION_OPTIONS } from "utils/constants" import { DURATION_OPTIONS } from "utils/constants"
const aiStore = useAIStore() const aiStore = useAIStore()
const userStore = useUserStore()
const { isDesktop } = useBreakpoints() const { isDesktop } = useBreakpoints()
@@ -89,6 +102,11 @@ const end = computed(() => {
return formatISO(new Date()) return formatISO(new Date())
}) })
function onUsernameChange() {
aiStore.fetchHeatmapData()
aiStore.fetchAnalysisData(start.value, end.value, aiStore.duration)
}
// 获取热力图数据(仅一次) // 获取热力图数据(仅一次)
onMounted(() => { onMounted(() => {
aiStore.fetchHeatmapData() aiStore.fetchHeatmapData()

View File

@@ -287,16 +287,16 @@ export function getTutorials() {
return http.get("tutorials") return http.get("tutorials")
} }
export function getAIDetailData(start: string, end: string) { export function getAIDetailData(start: string, end: string, username?: string) {
return http.get("ai/detail", { params: { start, end } }) return http.get("ai/detail", { params: { start, end, username } })
} }
export function getAIDurationData(end: string, duration: string) { export function getAIDurationData(end: string, duration: string, username?: string) {
return http.get("ai/duration", { params: { end, duration } }) return http.get("ai/duration", { params: { end, duration, username } })
} }
export function getAIHeatmapData() { export function getAIHeatmapData(username?: string) {
return http.get("ai/heatmap") return http.get("ai/heatmap", { params: username ? { username } : {} })
} }
export function getAILoginSummary() { export function getAILoginSummary() {

View File

@@ -5,6 +5,7 @@ import { getCSRFToken } from "utils/functions"
export const useAIStore = defineStore("ai", () => { export const useAIStore = defineStore("ai", () => {
const duration = ref("months:6") const duration = ref("months:6")
const targetUsername = ref("")
const durationData = ref<DurationData[]>([]) const durationData = ref<DurationData[]>([])
const detailsData = reactive<DetailsData>({ const detailsData = reactive<DetailsData>({
start: "", start: "",
@@ -28,7 +29,7 @@ export const useAIStore = defineStore("ai", () => {
const mdContent = ref("") const mdContent = ref("")
async function fetchDetailsData(start: string, end: string) { 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.start = res.data.start
detailsData.end = res.data.end detailsData.end = res.data.end
detailsData.solved = res.data.solved detailsData.solved = res.data.solved
@@ -41,13 +42,13 @@ export const useAIStore = defineStore("ai", () => {
} }
async function fetchDurationData(end: string, duration: string) { 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 durationData.value = res.data
} }
async function fetchHeatmapData() { async function fetchHeatmapData() {
loading.heatmap = true loading.heatmap = true
const res = await getAIHeatmapData() const res = await getAIHeatmapData(targetUsername.value || undefined)
heatmapData.value = res.data heatmapData.value = res.data
loading.heatmap = false loading.heatmap = false
} }
@@ -155,6 +156,7 @@ export const useAIStore = defineStore("ai", () => {
detailsData, detailsData,
heatmapData, heatmapData,
duration, duration,
targetUsername,
loading, loading,
mdContent, mdContent,
} }