diff --git a/src/oj/ai/components/AI.vue b/src/oj/ai/components/AI.vue
index 46c5686..3decbce 100644
--- a/src/oj/ai/components/AI.vue
+++ b/src/oj/ai/components/AI.vue
@@ -7,24 +7,19 @@
-
-
-
-
-
-
-
-
- 开始分析
-
-
-
+
+
+
+
+ 开始分析
+
+
@@ -41,7 +36,11 @@ async function handleAnalyze() {
if (aiStore.loading.fetching || aiStore.loading.ai) {
return
}
- await aiStore.fetchAIAnalysis()
+ if (aiStore.pinnedReport) {
+ await aiStore.simulatePinnedStream()
+ } else {
+ await aiStore.fetchAIAnalysis()
+ }
}
onMounted(async () => {
diff --git a/src/oj/store/ai.ts b/src/oj/store/ai.ts
index a17989d..a1aa57a 100644
--- a/src/oj/store/ai.ts
+++ b/src/oj/store/ai.ts
@@ -162,11 +162,35 @@ export const useAIStore = defineStore("ai", () => {
pinnedReport.value = res.data
}
+ async function simulatePinnedStream() {
+ if (!pinnedReport.value) return
+ const text = pinnedReport.value.analysis
+ mdContent.value = ""
+ loading.ai = true
+ const CHUNK = 6
+ const DELAY = 18
+ await new Promise((resolve) => {
+ let i = 0
+ function step() {
+ if (i >= text.length) {
+ loading.ai = false
+ resolve()
+ return
+ }
+ mdContent.value += text.slice(i, i + CHUNK)
+ i += CHUNK
+ setTimeout(step, DELAY)
+ }
+ step()
+ })
+ }
+
return {
fetchAnalysisData,
fetchHeatmapData,
fetchAIAnalysis,
fetchPinnedReport,
+ simulatePinnedStream,
durationData,
detailsData,
heatmapData,