update
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-06-04 08:44:54 -06:00
parent 33b6e35d6b
commit 41c4fdbc5c
5 changed files with 107 additions and 34 deletions

View File

@@ -7,19 +7,24 @@
</template>
<n-spin :show="aiStore.loading.ai" :delay="50">
<n-flex align="center" justify="center" class="container">
<n-button
v-if="!aiStore.mdContent && !aiStore.loading.ai"
type="primary"
size="large"
:loading="aiStore.loading.fetching"
@click="handleAnalyze"
>
<template #icon>
<Icon icon="mingcute:ai-line" />
</template>
开始分析
</n-button>
<MdPreview v-else :model-value="aiStore.mdContent" />
<template v-if="aiStore.pinnedReport">
<MdPreview :model-value="aiStore.pinnedReport.analysis" />
</template>
<template v-else>
<n-button
v-if="!aiStore.mdContent && !aiStore.loading.ai"
type="primary"
size="large"
:loading="aiStore.loading.fetching"
@click="handleAnalyze"
>
<template #icon>
<Icon icon="mingcute:ai-line" />
</template>
开始分析
</n-button>
<MdPreview v-else :model-value="aiStore.mdContent" />
</template>
</n-flex>
</n-spin>
</n-card>
@@ -38,6 +43,12 @@ async function handleAnalyze() {
}
await aiStore.fetchAIAnalysis()
}
onMounted(async () => {
if (!aiStore.targetUsername) {
await aiStore.fetchPinnedReport()
}
})
</script>
<style scoped>
.cool-title {

View File

@@ -308,6 +308,10 @@ export function getAILoginSummary() {
return http.get("ai/login_summary")
}
export function getAIPinnedReport() {
return http.get("ai/pinned")
}
// ==================== 相似题目推荐 ====================
export function getSimilarProblems(problemId: string) {

View File

@@ -1,6 +1,6 @@
import { DetailsData, DurationData } from "utils/types"
import { consumeJSONEventStream } from "utils/stream"
import { getAIDetailData, getAIDurationData, getAIHeatmapData } from "../api"
import { getAIDetailData, getAIDurationData, getAIHeatmapData, getAIPinnedReport } from "../api"
import { getCSRFToken } from "utils/functions"
export const useAIStore = defineStore("ai", () => {
@@ -27,6 +27,7 @@ export const useAIStore = defineStore("ai", () => {
})
const mdContent = ref("")
const pinnedReport = ref<{ analysis: string } | null>(null)
async function fetchDetailsData(start: string, end: string) {
const res = await getAIDetailData(
@@ -156,10 +157,16 @@ export const useAIStore = defineStore("ai", () => {
}
}
async function fetchPinnedReport() {
const res = await getAIPinnedReport()
pinnedReport.value = res.data
}
return {
fetchAnalysisData,
fetchHeatmapData,
fetchAIAnalysis,
fetchPinnedReport,
durationData,
detailsData,
heatmapData,
@@ -167,5 +174,6 @@ export const useAIStore = defineStore("ai", () => {
targetUsername,
loading,
mdContent,
pinnedReport,
}
})