Files
short-drama-agent-front/src/features/production/useShotReferences.ts
T

17 lines
873 B
TypeScript

import { computed, type Ref } from 'vue'
import { useQuery } from '../../composables/useQuery'
import { storyboardApi } from '../storyboard/api'
/** 仅查询已由当前项目列表确认的镜头,切换目标自动取消旧响应。 */
export function useShotReferences(projectId: Ref<string>, shotId: Ref<string>) {
const key = computed(() => JSON.stringify([projectId.value, shotId.value]))
return useQuery(key, async (value, signal) => {
const [project, shot] = JSON.parse(value) as [string, string]
if (!project || !shot) return null
const result = await storyboardApi.references(shot, signal)
if (!result || result.shotId !== shot || !Array.isArray(result.references) || !Array.isArray(result.missing))
throw new Error('镜头参考素材返回不匹配,请刷新后重试。')
return result
})
}