update
This commit is contained in:
@@ -7,10 +7,6 @@
|
|||||||
</template>
|
</template>
|
||||||
<n-spin :show="aiStore.loading.ai" :delay="50">
|
<n-spin :show="aiStore.loading.ai" :delay="50">
|
||||||
<n-flex align="center" justify="center" class="container">
|
<n-flex align="center" justify="center" class="container">
|
||||||
<template v-if="aiStore.pinnedReport">
|
|
||||||
<MdPreview :model-value="aiStore.pinnedReport.analysis" />
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<n-button
|
<n-button
|
||||||
v-if="!aiStore.mdContent && !aiStore.loading.ai"
|
v-if="!aiStore.mdContent && !aiStore.loading.ai"
|
||||||
type="primary"
|
type="primary"
|
||||||
@@ -24,7 +20,6 @@
|
|||||||
开始分析
|
开始分析
|
||||||
</n-button>
|
</n-button>
|
||||||
<MdPreview v-else :model-value="aiStore.mdContent" />
|
<MdPreview v-else :model-value="aiStore.mdContent" />
|
||||||
</template>
|
|
||||||
</n-flex>
|
</n-flex>
|
||||||
</n-spin>
|
</n-spin>
|
||||||
</n-card>
|
</n-card>
|
||||||
@@ -41,7 +36,11 @@ async function handleAnalyze() {
|
|||||||
if (aiStore.loading.fetching || aiStore.loading.ai) {
|
if (aiStore.loading.fetching || aiStore.loading.ai) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (aiStore.pinnedReport) {
|
||||||
|
await aiStore.simulatePinnedStream()
|
||||||
|
} else {
|
||||||
await aiStore.fetchAIAnalysis()
|
await aiStore.fetchAIAnalysis()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
|||||||
@@ -162,11 +162,35 @@ export const useAIStore = defineStore("ai", () => {
|
|||||||
pinnedReport.value = res.data
|
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<void>((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 {
|
return {
|
||||||
fetchAnalysisData,
|
fetchAnalysisData,
|
||||||
fetchHeatmapData,
|
fetchHeatmapData,
|
||||||
fetchAIAnalysis,
|
fetchAIAnalysis,
|
||||||
fetchPinnedReport,
|
fetchPinnedReport,
|
||||||
|
simulatePinnedStream,
|
||||||
durationData,
|
durationData,
|
||||||
detailsData,
|
detailsData,
|
||||||
heatmapData,
|
heatmapData,
|
||||||
|
|||||||
Reference in New Issue
Block a user