add username for ai analysis
This commit is contained in:
@@ -5,12 +5,23 @@
|
||||
<n-flex vertical size="large">
|
||||
<n-flex align="center" justify="space-between">
|
||||
<n-h3 style="margin: 0">请选择时间范围,智能分析学习情况</n-h3>
|
||||
<n-flex align="center">
|
||||
<n-input
|
||||
v-if="userStore.isSuperAdmin"
|
||||
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>
|
||||
<Overview />
|
||||
<n-grid :cols="2" :x-gap="20" :y-gap="20">
|
||||
<n-gi :span="isDesktop ? 1 : 2">
|
||||
@@ -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()
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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<DurationData[]>([])
|
||||
const detailsData = reactive<DetailsData>({
|
||||
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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user