refactor: 推理对比超时与打字机展示改进

抽取 withTimeout 替代 Promise.race 超时控制,对比结果新增打字机逐字渲染与清理,推理聊天参数与列表类型同步收敛。
This commit is contained in:
caoxiaozhu
2026-07-16 11:03:25 +08:00
parent 5a040366da
commit ab9e87f948
4 changed files with 83 additions and 42 deletions

View File

@@ -1,8 +1,9 @@
<script setup lang="ts">
import { ref, reactive, computed, onMounted, onUnmounted } from 'vue'
import { ref, reactive, computed, onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'
import PageCard from '@/components/PageCard.vue'
import { usePolling } from '@/composables/usePolling'
import { getCompare } from '@/api/modules/compare'
import type { CompareTask, LoadedModel } from '@/types'
@@ -11,7 +12,6 @@ const router = useRouter()
const taskId = route.params.id as string
const task = ref<CompareTask | null>(null)
let pollTimer: ReturnType<typeof setInterval> | null = null
const form = reactive({
systemPrompt: '',
@@ -73,13 +73,11 @@ function handleSubmit() {
window.open(url, '_blank')
}
onMounted(() => {
loadTask()
pollTimer = setInterval(loadTask, 5000)
})
const { start: startPolling } = usePolling(loadTask, 5000, { immediate: false })
onUnmounted(() => {
if (pollTimer) clearInterval(pollTimer)
onMounted(async () => {
await loadTask()
startPolling()
})
</script>