feat: 单镜头后台任务运行时临时轮询

This commit is contained in:
GouJ committed 2026-09-25 00:49:59 +08:00
1 parent eb7de5c86f
commit c77e8032e5
1 file changed
+18 -3
@@ -57,8 +57,23 @@ const props = defineProps<{
}>()
const emit = defineEmits<{ changed: [] }>()
const key = computed(() => props.shot.shotId)
/** 单镜头资产已有刷新入口,不再定时轮询。 */
const query = usePolling(
/** 仅当前镜头存在后台首帧或视频任务时临时轮询,终态后自动停止。 */
let query!: ReturnType<typeof usePolling<{
keyframes: Awaited<ReturnType<typeof productionApi.listKeyframes>>
videos: Awaited<ReturnType<typeof productionApi.listVideos>>
qualityStatus: Awaited<ReturnType<typeof productionApi.videoQualityStatus>> | null
qualityStatusError: string
inputPlan: Awaited<ReturnType<typeof productionApi.videoInputPlan>> | null
inputPlanError: string
}>>
const assetPollInterval = computed(() => {
const data = query?.data.value
if (!data) return false
const keyframeRunning = data.keyframes.some(item => ['pending', 'generating'].includes(item.status))
const videoRunning = data.videos.some(isActiveVideo)
return keyframeRunning || videoRunning ? 5000 : false
})
query = usePolling(
key,
async (shotId, signal) => {
const [keyframes, videos, qualityState, inputPlanState] = await Promise.all([
@@ -86,7 +101,7 @@ const query = usePolling(
inputPlanError: inputPlanState.error
}
},
false
assetPollInterval
)
/** 单独读取已保存的提示词,查询失败不影响首帧和视频资产展示。 */
const promptQuery = usePolling(key, (shotId, signal) => storyboardApi.videoPrompt(shotId, signal), false)