fix(short-drama-agent-front): 修复图片重复提交与首帧恢复
This commit is contained in:
1 parent
b88ad8770f
commit
ecb0423153
8 files changed
+508
-85
No files matched your search
@@ -13,6 +13,7 @@ import { ImagePlus, RefreshCw } from '@lucide/vue'
|
||||
import { AssetImage } from '../../../components/ui'
|
||||
import { usePolling } from '../../../composables/usePolling'
|
||||
import { useQuery } from '../../../composables/useQuery'
|
||||
import { releaseRecoveredImageRequest } from '../../subject-images/image-request-guard'
|
||||
import { ApiError, errorMessage } from '../../../lib/http'
|
||||
import { candidateDialogWidth } from '../../../lib/candidate-layout'
|
||||
import type { DesignedShot } from '../../storyboard/types'
|
||||
@@ -175,6 +176,21 @@ const currentVideoInput = computed(() =>
|
||||
videoInputQuery.data.value?.shotId === key.value ? videoInputQuery.data.value : null
|
||||
)
|
||||
const keyframes = computed(() => query.data.value?.keyframes ?? [])
|
||||
/** 下载回执丢失或刷新后,只用列表明确保存的恢复结果解除同镜头的保护。 */
|
||||
watch(keyframes, rows => {
|
||||
const shotId = props.shot.shotId
|
||||
for (const item of rows) {
|
||||
if (
|
||||
item.shotId === shotId &&
|
||||
item.status === 'completed' &&
|
||||
item.imageUrl &&
|
||||
item.recoveryRequired === false &&
|
||||
item.canRecoverSavedResult === false &&
|
||||
item.recoveryReason === 'provider_result_recovered'
|
||||
)
|
||||
releaseRecoveredImageRequest('keyframe:' + shotId, item.id, item.providerInputFingerprint)
|
||||
}
|
||||
})
|
||||
const videos = computed(() => query.data.value?.videos ?? [])
|
||||
/** 当前镜头尚未结束的首帧任务数量,包含等待提交和生成中。 */
|
||||
const activeKeyframeCount = computed(
|
||||
@@ -328,6 +344,8 @@ const canGeneratePrompt = computed(
|
||||
const canGenerateKeyframe = computed(
|
||||
() =>
|
||||
!assetBlocked.value &&
|
||||
!query.loading.value &&
|
||||
!!query.data.value &&
|
||||
!keyframes.value.some(item => item.recoveryRequired || ['pending', 'generating'].includes(item.status)) &&
|
||||
!!props.keyframeReadiness &&
|
||||
props.keyframeReadiness.issues.length === 0
|
||||
@@ -453,7 +471,15 @@ async function generateKeyframe(input: GenerateKeyframeInput) {
|
||||
const projectId = props.projectId
|
||||
const accepted = await runOperation(projectId, `生成镜头 ${props.shot.shotNo} 首帧`, async () => {
|
||||
const result = await productionApi.generateKeyframe(shotId, input)
|
||||
if (!result || result.shotId !== shotId) throw new ApiError('首帧生成结果待核对。', 200)
|
||||
if (
|
||||
!result?.id ||
|
||||
result.shotId !== shotId ||
|
||||
result.status !== 'completed' ||
|
||||
!result.imageUrl ||
|
||||
result.recoveryRequired !== false ||
|
||||
result.providerInputFingerprint !== input.expectedPreviewFingerprint
|
||||
)
|
||||
throw new ApiError('首帧生成结果待核对。', 200)
|
||||
})
|
||||
const cause = getOperation(projectId).cause
|
||||
if (props.projectId === projectId && props.shot.shotId === shotId) await refreshAll()
|
||||
@@ -470,8 +496,18 @@ async function recoverSavedKeyframe(item: ShotKeyframe) {
|
||||
const shotId = props.shot.shotId
|
||||
await runOperation(projectId, `恢复已生成首帧 ${item.id}`, async () => {
|
||||
const result = await productionApi.recoverSavedKeyframe(shotId, item.id)
|
||||
if (result.id !== item.id || result.shotId !== shotId || result.status !== 'completed')
|
||||
if (
|
||||
!result ||
|
||||
result.id !== item.id ||
|
||||
result.shotId !== shotId ||
|
||||
result.status !== 'completed' ||
|
||||
!result.imageUrl ||
|
||||
result.recoveryRequired !== false ||
|
||||
result.canRecoverSavedResult !== false ||
|
||||
result.providerInputFingerprint !== item.providerInputFingerprint
|
||||
)
|
||||
throw new Error('下载结果待核对,请刷新候选。')
|
||||
releaseRecoveredImageRequest('keyframe:' + shotId, result.id, result.providerInputFingerprint)
|
||||
})
|
||||
if (projectId === props.projectId && shotId === props.shot.shotId) await refreshAll()
|
||||
}
|
||||
@@ -1082,6 +1118,7 @@ defineExpose({ inspectSpecs, inspecting })
|
||||
:direction="shot.direction"
|
||||
:visual-state="shot.visualState"
|
||||
:disabled="!canGenerateKeyframe"
|
||||
:previous-candidate-ids="keyframes.map(item => item.id)"
|
||||
:submit-generation="generateKeyframe"
|
||||
/>
|
||||
</section>
|
||||
|
||||
Reference in new issue
Block a user