feat(short-drama-agent-front): 接入有限图片授权与候选修订
This commit is contained in:
1 parent
f6edc4eb70
commit
b15a6011ce
37 files changed
+3569
-76
No files matched your search
@@ -4,6 +4,7 @@ import { imageAuthorizationApi } from '../../image-authorization/api'
|
||||
import { formatMicros } from '../../image-authorization/model'
|
||||
import { NSelect } from 'naive-ui'
|
||||
import KeyframePreviewChecks from './KeyframePreviewChecks.vue'
|
||||
import ModelCapabilities from './ModelCapabilities.vue'
|
||||
import ImageGenerationPreview from '../../subject-images/components/ImageGenerationPreview.vue'
|
||||
import { useImageGenerationPreview, type ImageGenerationSubmission } from '../../subject-images/generation-preview'
|
||||
|
||||
@@ -20,7 +21,7 @@ import type {
|
||||
} from '../../generation-config/types'
|
||||
import GenerationModelControls from '../../generation-config/components/GenerationModelControls.vue'
|
||||
import { AppDialog, FieldLabel } from '../../../components/ui'
|
||||
import { errorMessage } from '../../../lib/http'
|
||||
import { ApiError, errorMessage } from '../../../lib/http'
|
||||
import { productionApi } from '../api'
|
||||
import { directionLabel } from '../../storyboard/model'
|
||||
import type { ShotDirection, ShotVisualState } from '../../storyboard/types'
|
||||
@@ -80,7 +81,9 @@ const imageProvider = ref('')
|
||||
/** 当前用户主动选择的许可,重新打开或切换范围后不保留默认选择。 */
|
||||
const additionalId = ref<string | null>(null)
|
||||
/** 人工追加只属于OpenAI,不改变其它供应方的未知请求保护。 */
|
||||
const canInspectAdditional = computed(() => !!props.additionalAllowed && imageProvider.value === 'openai-image')
|
||||
const canInspectAdditional = computed(
|
||||
() => (!!props.additionalAllowed || !props.disabled) && imageProvider.value === 'openai-image'
|
||||
)
|
||||
/** 仅需要核对原失败请求时读取已有许可,不自动创建。 */
|
||||
const additionalKey = computed(() =>
|
||||
open.value && canInspectAdditional.value ? JSON.stringify([props.projectId, props.shotId]) : ''
|
||||
@@ -101,13 +104,19 @@ const additionalOptions = computed(() =>
|
||||
permit =>
|
||||
permit.status === 'approved' &&
|
||||
permit.remainingRequests > 0 &&
|
||||
additionalQuery.data.value?.requests.some(
|
||||
row =>
|
||||
row.id === permit.input.parentRequestId &&
|
||||
row.input.projectId === props.projectId &&
|
||||
row.input.targetId === props.shotId &&
|
||||
row.input.scope === 'keyframe'
|
||||
)
|
||||
(permit.input.mode === 'bounded'
|
||||
? Date.parse(permit.input.expiresAt) > Date.now() &&
|
||||
permit.targets?.some(
|
||||
target => target.shotId === props.shotId && target.usedRequests < target.maxRequests
|
||||
)
|
||||
: additionalQuery.data.value?.requests.some(
|
||||
row =>
|
||||
row.id ===
|
||||
(permit.input.mode === 'additional' ? permit.input.parentRequestId : undefined) &&
|
||||
row.input.projectId === props.projectId &&
|
||||
row.input.targetId === props.shotId &&
|
||||
row.input.scope === 'keyframe'
|
||||
))
|
||||
)
|
||||
.map(permit => ({
|
||||
label: `${permit.input.approvedBy} · 已用 ${permit.usedRequests} / 剩余 ${permit.remainingRequests} 次`,
|
||||
@@ -120,7 +129,31 @@ const additionalPermit = computed(() =>
|
||||
)
|
||||
/** 原未知费用与预留保持显示。 */
|
||||
const additionalParent = computed(() =>
|
||||
additionalQuery.data.value?.requests.find(row => row.id === additionalPermit.value?.input.parentRequestId)
|
||||
additionalQuery.data.value?.requests.find(
|
||||
row =>
|
||||
row.id ===
|
||||
(additionalPermit.value?.input.mode === 'additional'
|
||||
? additionalPermit.value.input.parentRequestId
|
||||
: undefined)
|
||||
)
|
||||
)
|
||||
/** 有限跨镜许可的本镜计数及原预算保持独立。 */
|
||||
const boundedTarget = computed(() =>
|
||||
additionalPermit.value?.input.mode === 'bounded'
|
||||
? additionalPermit.value.targets?.find(row => row.shotId === props.shotId)
|
||||
: null
|
||||
)
|
||||
/** 原standing预算,不把许可次数显示成另一笔预算。 */
|
||||
const boundedBudget = computed(() =>
|
||||
additionalPermit.value?.input.mode === 'bounded'
|
||||
? additionalQuery.data.value?.authorizations.find(
|
||||
row =>
|
||||
row.id ===
|
||||
(additionalPermit.value?.input.mode === 'bounded'
|
||||
? additionalPermit.value.input.parentAuthorizationId
|
||||
: undefined)
|
||||
)
|
||||
: null
|
||||
)
|
||||
watch(
|
||||
[() => props.projectId, () => props.shotId, open],
|
||||
@@ -146,6 +179,7 @@ const {
|
||||
requiresCostConfirmation,
|
||||
chargeNotice,
|
||||
reusableResult,
|
||||
invalidate: invalidatePreview,
|
||||
loading,
|
||||
submitting,
|
||||
error,
|
||||
@@ -188,7 +222,18 @@ const {
|
||||
return result
|
||||
},
|
||||
reuseResult: props.reuseExisting ? result => props.reuseExisting!(result.previewFingerprint) : undefined,
|
||||
generate: input => props.submitGeneration({ ...input, setPrimary: false })
|
||||
generate: async input => {
|
||||
const outcome = await props.submitGeneration({ ...input, setPrimary: false })
|
||||
if (!outcome.accepted && outcome.cause instanceof ApiError && outcome.cause.status === 409) {
|
||||
await additionalQuery.refresh()
|
||||
if (
|
||||
outcome.cause.code === 'SCENE_CONTINUITY_REVIEW_STALE' ||
|
||||
outcome.cause.message.startsWith('SCENE_CONTINUITY_REVIEW_STALE')
|
||||
)
|
||||
await Promise.allSettled([productionApi.keyframeSpec(props.shotId, undefined, props.projectId)])
|
||||
}
|
||||
return outcome
|
||||
}
|
||||
})
|
||||
|
||||
/** 正式预览返回连续性阻断时,键盘和底栏提交均不可继续。 */
|
||||
@@ -297,8 +342,18 @@ watch(
|
||||
{{ formatMicros(additionalParent.input.reservedMicros) }} · 原账单
|
||||
{{ formatMicros(additionalParent.output?.actualBilledMicros) }}
|
||||
</p>
|
||||
<p v-if="boundedTarget" class="text-sm">
|
||||
本镜已用 {{ boundedTarget.usedRequests }}/{{ boundedTarget.maxRequests }} 次 · 原预算剩余
|
||||
{{ formatMicros(boundedBudget?.remainingMicros) }}。旧未知费用未被核清。
|
||||
</p>
|
||||
</section>
|
||||
<!-- 以下是正式摄影设计与画面状态 -->
|
||||
<ModelCapabilities
|
||||
v-if="open && imageProvider"
|
||||
:shot-id="shotId"
|
||||
:provider="imageProvider"
|
||||
@checked="!$event && invalidatePreview()"
|
||||
/>
|
||||
<NCollapse v-if="direction || visualState" class="mt-5">
|
||||
<NCollapseItem v-if="direction" name="direction" title="当前镜头设计">
|
||||
<p class="text-xs leading-6">{{ directionSummary }}</p>
|
||||
|
||||
Reference in new issue
Block a user