refactor(pipeline): 路径直接传输 — 统一 ctx 字段名/panel key/step 形参名

This commit is contained in:
DXC
2026-06-03 17:29:41 +08:00
parent 517bb28611
commit 343e316799
99 changed files with 9127 additions and 91 deletions

View File

@ -0,0 +1,51 @@
import { ref, watch, onUnmounted, type Ref } from 'vue'
import { getTaskStatus } from '../api/tasks'
export function useTaskPoller(taskIdRef: Ref<string | null>) {
const status = ref<string>('')
const isPolling = ref(false)
const error = ref<string | null>(null)
const result = ref<any>(null)
let timer: any = null
const start = () => {
if (!taskIdRef.value) return
isPolling.value = true
error.value = null
status.value = 'PENDING'
timer = setInterval(async () => {
try {
const res = await getTaskStatus(taskIdRef.value!)
status.value = res.status
if (res.status === 'SUCCESS') {
result.value = res
stop()
} else if (res.status === 'FAILED') {
error.value = res.error || '任务执行失败'
stop()
}
} catch (e: any) {
error.value = '网络请求失败,请检查后端状态'
stop()
}
}, 2000)
}
const stop = () => {
isPolling.value = false
if (timer) clearInterval(timer)
}
// 监听 Task ID 变化自动开启轮询
watch(taskIdRef, (newVal) => {
stop()
if (newVal) start()
})
// 组件销毁时清理定时器
onUnmounted(() => stop())
return { status, isPolling, error, result, stop }
}