feat: 关闭已有刷新页面的定时轮询
This commit is contained in:
@@ -40,15 +40,20 @@ const props = defineProps<{
|
||||
}>()
|
||||
const emit = defineEmits<{ changed: [] }>()
|
||||
const key = computed(() => props.shot.shotId)
|
||||
const query = usePolling(key, async (shotId, signal) => {
|
||||
const [keyframes, videos] = await Promise.all([
|
||||
productionApi.listKeyframes(shotId, signal),
|
||||
productionApi.listVideos(shotId, signal)
|
||||
])
|
||||
if (keyframes.some(item => item.shotId !== shotId) || videos.some(item => item.shotId !== shotId))
|
||||
throw new Error('资产记录与当前镜头不匹配,请刷新后重试。')
|
||||
return { keyframes, videos }
|
||||
})
|
||||
/** 单镜头资产已有刷新入口,不再定时轮询。 */
|
||||
const query = usePolling(
|
||||
key,
|
||||
async (shotId, signal) => {
|
||||
const [keyframes, videos] = await Promise.all([
|
||||
productionApi.listKeyframes(shotId, signal),
|
||||
productionApi.listVideos(shotId, signal)
|
||||
])
|
||||
if (keyframes.some(item => item.shotId !== shotId) || videos.some(item => item.shotId !== shotId))
|
||||
throw new Error('资产记录与当前镜头不匹配,请刷新后重试。')
|
||||
return { keyframes, videos }
|
||||
},
|
||||
false
|
||||
)
|
||||
const keyframes = computed(() => query.data.value?.keyframes ?? [])
|
||||
const videos = computed(() => query.data.value?.videos ?? [])
|
||||
const currentKeyframe = computed(() => primaryKeyframe(keyframes.value))
|
||||
|
||||
@@ -42,20 +42,25 @@ export function useProduction() {
|
||||
0
|
||||
)
|
||||
const queryKey = computed(() => JSON.stringify([id.value, episodeNo.value, force.value]))
|
||||
const query = usePolling(queryKey, async (key, signal) => {
|
||||
const [projectId, number, overwrite] = JSON.parse(key) as [string, number, boolean]
|
||||
if (!projectId || !number) return null
|
||||
const [directions, prompts, keyframes, videos, videoStatus] = await Promise.all([
|
||||
storyboardApi.directions(projectId, number, signal),
|
||||
productionApi.promptReadiness(projectId, overwrite, signal),
|
||||
productionApi.keyframeReadiness(projectId, overwrite, signal),
|
||||
productionApi.videoReadiness(projectId, overwrite, signal),
|
||||
productionApi.projectVideoStatus(projectId, signal)
|
||||
])
|
||||
if (directions.projectId !== projectId || directions.episodeNo !== number)
|
||||
throw new Error('镜头生产查询返回了不匹配的项目或剧集,请刷新后重试。')
|
||||
return { directions, prompts, keyframes, videos, videoStatus }
|
||||
})
|
||||
/** 生产页已有刷新按钮,就绪状态改为手动更新。 */
|
||||
const query = usePolling(
|
||||
queryKey,
|
||||
async (key, signal) => {
|
||||
const [projectId, number, overwrite] = JSON.parse(key) as [string, number, boolean]
|
||||
if (!projectId || !number) return null
|
||||
const [directions, prompts, keyframes, videos, videoStatus] = await Promise.all([
|
||||
storyboardApi.directions(projectId, number, signal),
|
||||
productionApi.promptReadiness(projectId, overwrite, signal),
|
||||
productionApi.keyframeReadiness(projectId, overwrite, signal),
|
||||
productionApi.videoReadiness(projectId, overwrite, signal),
|
||||
productionApi.projectVideoStatus(projectId, signal)
|
||||
])
|
||||
if (directions.projectId !== projectId || directions.episodeNo !== number)
|
||||
throw new Error('镜头生产查询返回了不匹配的项目或剧集,请刷新后重试。')
|
||||
return { directions, prompts, keyframes, videos, videoStatus }
|
||||
},
|
||||
false
|
||||
)
|
||||
const source = computed(() => sourceEpisodes.value.find(item => item.episodeNo === episodeNo.value))
|
||||
const shots = computed(() => mergeDesignedShots(query.data.value?.directions ?? null, null, source.value))
|
||||
const shot = computed(() => shots.value.find(item => item.shotId === selectedShot.value) ?? shots.value[0])
|
||||
|
||||
Reference in New Issue
Block a user