feat(short-drama-agent-front): 接入有限图片授权与候选修订

This commit is contained in:
GJ committed 2026-11-18 11:52:36 +08:00
1 parent f6edc4eb70
commit b15a6011ce
37 files changed
+3569 -76

No files matched your search

+3 -2
View File
@@ -174,9 +174,10 @@ export const productionApi = {
input: Pick<GenerateKeyframeInput, 'provider' | 'width' | 'height'> & {
/** 已保存草案中的原模型参数。 */ generationOptions?: Record<string, unknown>
},
signal?: AbortSignal
signal?: AbortSignal,
projectId?: string
) =>
request<KeyframeGenerationPreview>(`${shotPath(shotId)}/keyframe/preview`, {
request<KeyframeGenerationPreview>(keyframeScope(`${shotPath(shotId)}/keyframe/preview`, projectId), {
method: 'POST',
signal,
body: input
@@ -8,7 +8,11 @@ import { productionMessage } from '../production-messages'
import { useKeyframeVision } from '../keyframe-vision'
import { computed, ref, watch } from 'vue'
import SourceReviewDrawer from './SourceReviewDrawer.vue'
import { useEffectiveKeyframeQuality, effectiveQualityLabels } from '../effective-keyframe-quality'
import {
useEffectiveKeyframeQuality,
effectiveQualityLabels,
keyframeQualitySummary
} from '../effective-keyframe-quality'
import { NButton, NTag } from 'naive-ui'
import { AssetImage, AssetOpenLink, StatusBadge } from '../../../components/ui'
import { formatDate } from '../../../lib/format'
@@ -17,6 +21,7 @@ import type { ShotKeyframe } from '../types'
/** 首帧卡片统一主图标识、质量结论和晋升限制。 */
const props = defineProps<{
/** 摄影审核只读嵌入,保留图片与历史入口,不开放生成/编辑/采用。 */ readonly?: boolean
item: ShotKeyframe
/** 正式项目归属,用于查询候选审核。 */
projectId?: string
@@ -104,6 +109,7 @@ const qualityActionLabel = computed(() =>
const canSelect = computed(
() =>
props.item.status === 'completed' &&
!props.readonly &&
!!props.item.imageUrl &&
props.item.source !== 'provider_variant' &&
!props.item.isPrimary &&
@@ -159,6 +165,12 @@ const canSelect = computed(
>
</div>
<!-- 以下是候选的来源、画幅与后台审核状态 -->
<p
v-if="effectiveStatus === 'stale' && reviewQuery.data.value && !reviewQuery.error.value"
class="mt-2 text-xs text-muted"
>
{{ keyframeQualitySummary(reviewQuery.data.value.qualityDecision, effectiveStatus) }}
</p>
<p v-if="item.provider || item.model" class="mt-2 wrap-anywhere text-xs text-muted">
{{ [item.provider, item.model].filter(Boolean).join(' / ') }}
</p>
@@ -205,7 +217,7 @@ const canSelect = computed(
}}
</p>
<NButton
v-if="item.canRecoverSavedResult"
v-if="item.canRecoverSavedResult && !readonly"
class="mt-2"
size="small"
:disabled="blocked || recovering"
@@ -216,7 +228,11 @@ const canSelect = computed(
<p class="mt-2 text-[10px] text-muted">{{ formatDate(item.createdAt) }}</p>
<!-- 以下是集中排列的首帧辅助图标操作,提示与无障碍名称一致 -->
<div v-if="item.status === 'completed' && item.imageUrl" class="mt-4 flex flex-wrap items-center gap-2">
<WorkspaceActionTooltip placement="top" v-if="item.isPrimary && projectId" label="按当前来源人工复核">
<WorkspaceActionTooltip
placement="top"
v-if="item.isPrimary && projectId && !readonly"
label="按当前来源人工复核"
>
<NButton
square
class="workspace-action-button icon-button"
@@ -225,7 +241,11 @@ const canSelect = computed(
><ClipboardCheck :size="17"
/></NButton>
</WorkspaceActionTooltip>
<WorkspaceActionTooltip placement="top" v-if="!wrongCanvas && !stale" :label="qualityActionLabel">
<WorkspaceActionTooltip
placement="top"
v-if="!wrongCanvas && !stale && !readonly"
:label="qualityActionLabel"
>
<NButton
square
class="workspace-action-button icon-button"
@@ -236,7 +256,7 @@ const canSelect = computed(
</WorkspaceActionTooltip>
<WorkspaceActionTooltip
placement="top"
v-if="item.source !== 'provider_variant' && !wrongCanvas && !stale"
v-if="item.source !== 'provider_variant' && !wrongCanvas && !stale && !readonly"
label="编辑此首帧"
>
<NButton
@@ -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>
@@ -3,6 +3,7 @@ import { computed } from 'vue'
import { NCollapse, NCollapseItem, NTag } from 'naive-ui'
import { userFacingText } from '../../../lib/user-facing-text'
import type { KeyframeGenerationPreview } from '../types'
import SceneTransitionEvidence from '../../storyboard/components/SceneTransitionEvidence.vue'
/** 只展示服务端返回的画幅、尺寸和一致性门禁。 */
const props = defineProps<{
@@ -33,6 +34,7 @@ const size = computed(() => {
>连续性待确认 · 暂不能生成</NTag
>
</div>
<SceneTransitionEvidence :continuity="preview.continuity" />
<!-- 以下是具体待确认主体与规格检查问题 -->
<ul v-if="preview.continuity?.reviewIssues.length" class="text-muted">
<li v-for="issue in preview.continuity.reviewIssues" :key="issue.subjectRef + issue.code">
@@ -5,10 +5,18 @@ import FeedbackMessage from '../../../components/ui/FeedbackMessage.vue'
import ContextNotice from '../../../components/ui/ContextNotice.vue'
import { computed, ref, watch } from 'vue'
import { NButton, NInput } from 'naive-ui'
import { NButton, NInput, NCollapse, NCollapseItem } from 'naive-ui'
import RawDataDetails from '../../../components/ui/RawDataDetails.vue'
import { useQuery } from '../../../composables/useQuery'
import { imageAuthorizationApi } from '../../image-authorization/api'
import { formatMicros } from '../../image-authorization/model'
import { errorMessage } from '../../../lib/http'
import ReadonlyInspection from '../../../components/ui/ReadonlyInspection.vue'
import { useEffectiveKeyframeQuality, effectiveQualityLabels } from '../effective-keyframe-quality'
import {
useEffectiveKeyframeQuality,
effectiveQualityLabels,
keyframeQualitySummary
} from '../effective-keyframe-quality'
import { formatDate } from '../../../lib/format'
import { physicalRetryTarget, submitKeyframeVision, useKeyframeVision } from '../keyframe-vision'
import KeyframeExecutionHistory from './KeyframeExecutionHistory.vue'
@@ -43,6 +51,35 @@ const key = computed(() =>
? JSON.stringify([props.projectId, props.shotId, props.keyframeId])
: ''
)
/** 原图片的来源及费用仅在用户展开时读取,不把本镜其它图片或未执行计划混入。 */
const generationExpanded = ref<string[]>([])
/** 查询同时冻结项目、Shot及图片身份,切换旧图片后不回填其它候选费用。 */
const generationKey = computed(() =>
props.projectId && key.value && generationExpanded.value.includes('generation-records') ? key.value : ''
)
/** 复用原图片账本GET与历史详情,不提供核清、重试或新授权入口。 */
const generationRecords = useQuery(generationKey, async (value, signal) => {
if (!value) return []
const [projectId, shotId, candidateId] = JSON.parse(value) as [string, string, string]
const list = await imageAuthorizationApi.list(projectId, signal)
return list.requests.filter(
row =>
row.input.projectId === projectId &&
row.input.scope === 'keyframe' &&
row.input.targetId === shotId &&
row.input.candidateId === candidateId
)
})
watch(key, () => {
generationExpanded.value = []
})
/** 原执行标签只说明模型请求状态,不用于推导图片质量或账单。 */
const generationStatusLabels: Record<string, string> = {
unknown: '结果或费用未知',
completed: '执行完成',
running: '进行中',
failed: '执行失败'
}
/** 独立打开历史后恢复后台观察。 */
const visionKey = computed(() =>
key.value
@@ -296,8 +333,35 @@ const records = computed(() =>
}
"
>
<!-- 以下是当前选中旧图片的原来源、请求及费用;不修改任何历史或核清状态。 -->
<NCollapse v-if="projectId" v-model:expanded-names="generationExpanded" class="mb-4">
<NCollapseItem name="generation-records" title="原图片生成来源与费用">
<p v-if="generationRecords.loading.value" role="status">正在读取原图片请求…</p>
<p v-else-if="generationRecords.error.value" role="alert">{{ generationRecords.error.value }}</p>
<p v-else-if="!generationRecords.data.value?.length" class="text-xs text-muted">
未找到此图片的原OpenAI费用记录;不据此推断费用为0。
</p>
<article
v-for="row in generationRecords.data.value ?? []"
:key="row.id"
class="my-3 space-y-2 text-xs wrap-anywhere"
>
<p>原请求 {{ row.id }} · {{ generationStatusLabels[row.status] ?? '待确认' }}</p>
<p>
原预留 {{ formatMicros(row.input.reservedMicros) }} · 公开用量价
{{ formatMicros(row.output?.usageCostMicros) }} · 实际账单
{{ formatMicros(row.output?.actualBilledMicros) }}
</p>
<p v-if="row.billingAudit?.released">费用已核清;原执行、机器质量及主首帧状态保持独立。</p>
<RawDataDetails :value="row" title="原模型、来源、精确计划与回执" />
</article>
</NCollapseItem>
</NCollapse>
<section v-if="review" class="panel p-3 text-xs leading-6">
<p class="font-semibold">当前质量复核</p>
<p v-if="reviewQuery.status.value === 'stale'">
{{ keyframeQualitySummary(review.qualityDecision, 'stale') }}
</p>
<p>历史机器结论:{{ terminatedReview ? '已终止,无有效结论' : decisionLabel(review.qualityDecision) }}</p>
<p>当前状态:{{ effectiveQualityLabels[reviewQuery.status.value] }}</p>
<p v-if="review.manualReview">
@@ -17,10 +17,17 @@ const props = defineProps<{
/** 本次选择的图片模型,未提供时读取后端默认。 */
provider?: string
}>()
/** 当前检查期间及失败时撤销关联入口的旧预检,不授予其它门禁。 */
const emit = defineEmits<{ checked: [valid: boolean] }>()
/** 正式公开的Provider限制,能力编译失败时仍保留。 */
const providers = ref<ImageProviderCapability[] | null>(null)
/** 仅当前镜头及模型本次检查的实际结果。 */
const capability = ref<ShotProviderCapability | null>(null)
/** 当前能力阻断的业务原因。 */
const error = ref('')
/** 本次免费检查的就地加载。 */
const loading = ref(false)
/** 切换范围或卸载后丢弃迟到结果。 */
let revision = 0
onScopeDispose(() => {
revision++
@@ -30,6 +37,7 @@ watch([() => props.shotId, () => props.provider], () => {
revision++
providers.value = null
capability.value = null
emit('checked', false)
error.value = ''
loading.value = false
})
@@ -41,17 +49,23 @@ async function inspect() {
const provider = props.provider
loading.value = true
error.value = ''
capability.value = null
emit('checked', false)
try {
const list = await qualityApi.providers()
if (version !== revision) return
const result = shotId ? await qualityApi.capability(shotId, undefined, provider) : null
if (version !== revision) return
if (!Array.isArray(list) || list.some(item => !item.capabilities?.references))
throw new Error('模型能力接口返回不完整。')
providers.value = list
const result = shotId ? await qualityApi.capability(shotId, undefined, provider) : null
if (version !== revision) return
capability.value = result
emit('checked', result?.valid === true)
} catch (cause) {
if (version === revision) error.value = errorMessage(cause)
if (version === revision) {
capability.value = null
error.value = errorMessage(cause)
}
} finally {
if (version === revision) loading.value = false
}
@@ -61,12 +75,13 @@ async function inspect() {
<section class="mt-4 text-xs">
<NButton size="small" :loading="loading" :disabled="loading" @click="inspect">查看模型限制</NButton>
<FeedbackMessage v-if="error" :message="error" />
<p v-if="error" role="alert" class="mt-3 text-muted">{{ error }}</p>
<template v-if="providers">
<p v-if="!providers.some(item => item.active)" class="mt-2 text-danger">
没有可用的图片模型,请先到项目配置中选择模型。
</p>
<p v-for="item in providers" :key="item.provider" class="mt-2">
{{ item.provider }} · {{ item.active ? '当前启用' : '已注册' }} ·
{{ item.provider }} · {{ item.active ? '默认推荐' : '已注册' }} ·
{{
!item.capabilities.references.supported
? '不支持参考图'
@@ -86,5 +101,6 @@ async function inspect() {
本次计划输入 {{ capability.plannedReferenceCount }} 张 · 转为文字约束
{{ capability.omittedReferenceCount ?? 0 }} 张
</p>
<p v-if="capability?.valid" class="mt-2 text-muted">仅证明参考输入可编译,费用、连续性与质量仍需分别核对。</p>
</section>
</template>
@@ -359,6 +359,8 @@ function openShotKeyframeQuality() {
}
/** 当前查看历史的候选 ID;历史记录在独立弹窗内按候选隔离。 */
const historyKeyframeId = ref('')
/** 候选弹窗离场后再打开原图历史,避免两个焦点约束同时存在。 */
const pendingHistoryKeyframeId = ref('')
/** 历史候选画幅或来源失效时保留浏览、禁止人工采用。 */
const historyBlocked = computed(() => {
const item = keyframes.value.find(candidate => candidate.id === historyKeyframeId.value)
@@ -381,9 +383,20 @@ const visionHistoryRef = ref<InstanceType<typeof KeyframeValidationHistory> | nu
* @param keyframeId 需要查看历史的首帧 ID
*/
function openKeyframeHistory(keyframeId: string) {
if (candidatesOpen.value) {
pendingHistoryKeyframeId.value = keyframeId
candidatesOpen.value = false
return
}
historyKeyframeId.value = keyframeId
historyOpen.value = true
}
/** 候选管理关闭完成才交接至同镜头原图历史;切镜时待打开目标会清空。 */
function openPendingKeyframeHistory() {
const id = pendingHistoryKeyframeId.value
pendingHistoryKeyframeId.value = ''
if (id && !disposed) openKeyframeHistory(id)
}
const confirmingKeyframe = ref('')
const confirmingVideo = ref('')
const inspecting = ref(false)
@@ -439,6 +452,13 @@ const primaryQualityBlocked = computed(() => {
return !status || status === 'failed' || status === 'needs_review' || status === 'unknown'
})
const reviewRevision = ref(0)
/** 静态摄影/开拍状态改变时只刷新质量投影,不隐藏原Primary或删除历史图。 */
watch(
() => JSON.stringify([props.projectId, props.shot.shotId, props.shot.direction, props.shot.visualState]),
(_value, previous) => {
if (previous) reviewRevision.value++
}
)
/** 审核后强制更新每张卡片的数据库质量状态。 */
async function refreshAfterReview() {
reviewRevision.value += 1
@@ -486,6 +506,7 @@ watch(key, () => {
confirmingKeyframe.value = ''
historyOpen.value = false
historyKeyframeId.value = ''
pendingHistoryKeyframeId.value = ''
confirmingVideo.value = ''
videoCandidatesOpen.value = false
videoHistoryOpen.value = false
@@ -1160,6 +1181,7 @@ defineExpose({ inspectSpecs, inspecting })
title="首帧候选管理"
description="通过检查或人工复核后可设为主首帧。"
:width="keyframeCandidatesWidth"
@closed="openPendingKeyframeHistory"
>
<!-- 候选图片和对应的人工复核入口按相同候选 ID 分组。 -->
<div v-if="keyframeCandidates.length" class="asset-candidate-grid mt-4">
@@ -14,6 +14,20 @@ export const effectiveQualityLabels: Record<EffectiveKeyframeQualityStatus, stri
manual_accepted: '人工已接受',
unknown: '质量待确认'
}
/**
* 历史机器审核与当前有效来源分开展示,不把改源当新图Passed。
* @param machine 原机器结论
* @param current 当前服务端有效状态
* @returns 普通用户可读的组合摘要
*/
export function keyframeQualitySummary(
machine: EffectiveKeyframeQualityStatus,
current: EffectiveKeyframeQualityStatus
) {
if (current === 'stale' && machine === 'failed') return '历史审核未通过,当前来源已变化'
if (current === 'stale' && ['passed', 'manual_accepted'].includes(machine)) return '历史审核通过,当前来源已变化'
return effectiveQualityLabels[current]
}
/**
* 按项目、镜头、候选读取有效质量,执行及来源证据变化后重新回读,绝不采用工作流的历史 Passed。