fix: 合并图库吸顶区域并关闭自动刷新
This commit is contained in:
@@ -1,16 +1,29 @@
|
||||
import { computed, type Ref } from 'vue'
|
||||
import { computed, type MaybeRefOrGetter, type Ref } from 'vue'
|
||||
import { usePolling } from '../../composables/usePolling'
|
||||
import { storyboardApi } from '../storyboard/api'
|
||||
|
||||
/** 仅查询已由当前项目列表确认的镜头,切换目标自动取消旧响应。 */
|
||||
export function useShotReferences(projectId: Ref<string>, shotId: Ref<string>) {
|
||||
export function useShotReferences(
|
||||
projectId: Ref<string>,
|
||||
shotId: Ref<string>,
|
||||
interval: MaybeRefOrGetter<number | false> = 6000
|
||||
) {
|
||||
const key = computed(() => JSON.stringify([projectId.value, shotId.value]))
|
||||
return usePolling(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
|
||||
})
|
||||
return usePolling(
|
||||
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
|
||||
},
|
||||
interval
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user