import { computed, type Ref } from 'vue' import { useQuery } from '../../composables/useQuery' import { storyboardApi } from '../storyboard/api' /** 仅查询已由当前项目列表确认的镜头,切换目标自动取消旧响应。 */ export function useShotReferences(projectId: Ref, shotId: Ref) { 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 }) }