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
@@ -0,0 +1,464 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onScopeDispose, ref, watch } from 'vue'
|
||||
import { NButton, NCheckbox, NDatePicker, NInput, NInputNumber, NSelect } from 'naive-ui'
|
||||
import WorkspaceSectionHeading from '../../components/ui/WorkspaceSectionHeading.vue'
|
||||
import RawDataDetails from '../../components/ui/RawDataDetails.vue'
|
||||
import { useActionMessage } from '../../components/ui/useActionMessage'
|
||||
import { useQuery } from '../../composables/useQuery'
|
||||
import { ApiError, errorMessage } from '../../lib/http'
|
||||
import { projectsApi } from '../projects/api'
|
||||
import { storyboardApi } from '../storyboard/api'
|
||||
import GenerationModelControls from '../generation-config/components/GenerationModelControls.vue'
|
||||
import { generationConfigApi } from '../generation-config/api'
|
||||
import type { GenerationModelCatalog, GenerationOptions } from '../generation-config/types'
|
||||
import { imageAuthorizationApi } from './api'
|
||||
import { formatMicros } from './model'
|
||||
import type { ImageAuthorizationList, ImageAuthorizationPreview, ImageBoundedTarget } from './types'
|
||||
/** 原授权管理中的有限风险表单,操作由原抽屉固定底栏提交。 */
|
||||
const props = defineProps<{
|
||||
/** 正式项目。 */ projectId: string
|
||||
/** 当前原费用投影。 */ list: ImageAuthorizationList | null
|
||||
/** 正式模型目录。 */ catalog: GenerationModelCatalog | null
|
||||
/** 实际活动锁。 */ disabled: boolean
|
||||
}>()
|
||||
/** 不新增预算面板,写入后刷新原授权与费用历史。 */
|
||||
const emit = defineEmits<{ busy: [value: boolean]; changed: []; refresh: [] }>()
|
||||
/** 用户选择的原standing。 */ const parentId = ref<string | null>(null)
|
||||
/** 明确选中的正式镜头,普通浏览目录不增加勾选。 */ const shotIds = ref<string[]>([])
|
||||
/** 每镜次数不预填。 */ const counts = ref<Record<string, number | null>>({})
|
||||
/** 总次数不预填。 */ const total = ref<number | null>(null)
|
||||
/** 明确有效期。 */ const expires = ref<number | null>(null)
|
||||
/** 本次实际模型参数。 */ const options = ref<GenerationOptions>({})
|
||||
/** 实际批准人。 */ const approvedBy = ref('')
|
||||
/** 本次风险批准说明。 */ const note = ref('')
|
||||
/** 主动接受的旧未知请求,不吞并新unknown。 */ const acceptedIds = ref<string[]>([])
|
||||
/** 浮动费用及原未知风险的独立人工确认。 */ const acknowledged = ref(false)
|
||||
/** 同步操作期间防止重复写入。 */ const saving = ref(false)
|
||||
/** 免费编译期间的就地加载。 */ const preparing = ref(false)
|
||||
/** 当前已冻结的精确费用计划,不保存实际图片载荷。 */ const plans = ref<Array<{
|
||||
/** 正式镜头。 */ shotId: string
|
||||
/** 实际型号。 */ model: string
|
||||
/** 正式Source。 */ sourceFingerprint: string
|
||||
/** 费用计划。 */ planFingerprint: string
|
||||
}> | null>(null)
|
||||
/** 错误不清空用户表单。 */ const error = ref('')
|
||||
/** 相同内容失败后仍使用同一幂等键。 */ const nonce = ref(crypto.randomUUID())
|
||||
/** 免费请求在切范围后失效。 */ let version = 0
|
||||
/** 离开页面后不回填或通知其它项目。 */ let disposed = false
|
||||
onScopeDispose(() => {
|
||||
disposed = true
|
||||
version++
|
||||
})
|
||||
/** 当前原预算和剩余额度。 */ const parent = computed(() =>
|
||||
props.list?.authorizations.find(row => row.id === parentId.value)
|
||||
)
|
||||
/** 只列可用且覆盖首帧的原standing。 */ const parents = computed(
|
||||
() =>
|
||||
props.list?.authorizations
|
||||
.filter(
|
||||
row =>
|
||||
row.input.mode === 'standing' &&
|
||||
row.status === 'approved' &&
|
||||
!row.expired &&
|
||||
row.input.scopes.includes('keyframe')
|
||||
)
|
||||
.map(row => ({
|
||||
label: `${row.input.approvedBy} · ${row.input.models.join(' / ')} · 剩余 ${formatMicros(row.remainingMicros)}`,
|
||||
value: row.id
|
||||
})) ?? []
|
||||
)
|
||||
/** Provider固定OpenAI,型号仅来自正式目录和父批准交集。 */ const catalog = computed(() =>
|
||||
props.catalog
|
||||
? {
|
||||
...props.catalog,
|
||||
images: props.catalog.images.filter(
|
||||
row =>
|
||||
row.provider === 'openai-image' &&
|
||||
row.enabled &&
|
||||
parent.value?.input.models.includes(row.model ?? '')
|
||||
)
|
||||
}
|
||||
: null
|
||||
)
|
||||
/** 本次唯一实际型号,免费计划还会再次核对。 */ const model = computed(() => catalog.value?.images[0]?.model ?? '')
|
||||
/** 当前全部有效费用阻断,必须明确逐项接受。 */ const blockers = computed(
|
||||
() => props.list?.requests.filter(row => props.list?.blockingRequestIds.includes(row.id)) ?? []
|
||||
)
|
||||
/** 正式镜头列表按项目读取,ID不来自自由输入。 */ const targetKey = computed(() => props.projectId)
|
||||
/** 复用原项目及摄影目录GET,不创建资产或计划。 */ const targets = useQuery(targetKey, async (value, signal) => {
|
||||
const [project, profile] = await Promise.all([
|
||||
projectsApi.detail(value, signal),
|
||||
generationConfigApi.profile(value, signal)
|
||||
])
|
||||
if (project.id !== value || !Array.isArray(project.episodes)) throw new Error('当前项目镜头列表无法核对。')
|
||||
const rows = await Promise.all(project.episodes.map(row => storyboardApi.directions(value, row.episode, signal)))
|
||||
if (rows.some(row => row.projectId !== value)) throw new Error('镜头目录不属于当前项目。')
|
||||
return {
|
||||
aspectRatio: profile?.aspectRatio ?? null,
|
||||
items: rows.flatMap(row =>
|
||||
row.beats.flatMap(beat =>
|
||||
beat.shots.map(shot => ({
|
||||
label: `第 ${row.episodeNo} 集 · 镜头 ${beat.beatNo}.${shot.shotNo}`,
|
||||
value: shot.shotId
|
||||
}))
|
||||
)
|
||||
)
|
||||
}
|
||||
})
|
||||
/** 编译范围变化立即废弃旧计划和人工确认。 */ const signature = computed(() =>
|
||||
JSON.stringify([props.projectId, parentId.value, model.value, shotIds.value, options.value])
|
||||
)
|
||||
watch(
|
||||
signature,
|
||||
() => {
|
||||
version++
|
||||
plans.value = null
|
||||
acknowledged.value = false
|
||||
nonce.value = crypto.randomUUID()
|
||||
error.value = ''
|
||||
preparing.value = false
|
||||
},
|
||||
{ flush: 'sync' }
|
||||
)
|
||||
/** 新请求或父预算改变时必须重新接受风险,不把旧确认套给新集合。 */
|
||||
watch(
|
||||
() => JSON.stringify([blockers.value, parent.value]),
|
||||
() => {
|
||||
acceptedIds.value = []
|
||||
acknowledged.value = false
|
||||
},
|
||||
{ flush: 'sync' }
|
||||
)
|
||||
watch(
|
||||
[counts, total, expires, approvedBy, note, acceptedIds],
|
||||
() => {
|
||||
acknowledged.value = false
|
||||
nonce.value = crypto.randomUUID()
|
||||
error.value = ''
|
||||
},
|
||||
{ deep: true, flush: 'sync' }
|
||||
)
|
||||
watch(parentId, () => {
|
||||
acceptedIds.value = []
|
||||
expires.value = null
|
||||
options.value = { ...catalog.value?.images[0]?.defaults }
|
||||
})
|
||||
watch(
|
||||
() => props.projectId,
|
||||
() => {
|
||||
version++
|
||||
parentId.value = null
|
||||
shotIds.value = []
|
||||
counts.value = {}
|
||||
total.value = null
|
||||
expires.value = null
|
||||
approvedBy.value = ''
|
||||
note.value = ''
|
||||
acceptedIds.value = []
|
||||
acknowledged.value = false
|
||||
plans.value = null
|
||||
error.value = ''
|
||||
nonce.value = crypto.randomUUID()
|
||||
},
|
||||
{ flush: 'sync' }
|
||||
)
|
||||
watch(saving, value => emit('busy', value), { flush: 'sync' })
|
||||
/** 原预算、接受集合、逐镜及总次数全部有效,才允许登记;仍不启动生成。 */
|
||||
const canSubmit = computed(() => {
|
||||
const grant = parent.value,
|
||||
rows = plans.value
|
||||
return (
|
||||
!props.disabled &&
|
||||
!saving.value &&
|
||||
!preparing.value &&
|
||||
!targets.loading.value &&
|
||||
!targets.error.value &&
|
||||
!!grant &&
|
||||
grant.status === 'approved' &&
|
||||
!grant.expired &&
|
||||
Date.parse(grant.input.expiresAt) > Date.now() &&
|
||||
grant.remainingRequests > 0 &&
|
||||
grant.remainingMicros >= grant.input.perRequestMicros &&
|
||||
!!rows?.length &&
|
||||
rows.length === shotIds.value.length &&
|
||||
rows.length <= 100 &&
|
||||
blockers.value.length > 0 &&
|
||||
blockers.value.length === props.list?.blockingRequestIds.length &&
|
||||
blockers.value.every(
|
||||
row =>
|
||||
row.status === 'unknown' &&
|
||||
row.input.projectId === props.projectId &&
|
||||
row.input.authorizationId === grant.id &&
|
||||
row.input.model === model.value &&
|
||||
/^[a-f0-9]{64}$/.test(row.inputFingerprint ?? '') &&
|
||||
acceptedIds.value.includes(row.id)
|
||||
) &&
|
||||
acceptedIds.value.length === blockers.value.length &&
|
||||
rows.every(
|
||||
row =>
|
||||
Number.isInteger(counts.value[row.shotId]) &&
|
||||
counts.value[row.shotId]! >= 1 &&
|
||||
counts.value[row.shotId]! <= 100 &&
|
||||
(!grant.input.targetIds || grant.input.targetIds.includes(row.shotId))
|
||||
) &&
|
||||
Number.isInteger(total.value) &&
|
||||
total.value! >= 1 &&
|
||||
total.value! <= 100 &&
|
||||
total.value! <= rows.reduce((sum, row) => sum + (counts.value[row.shotId] ?? 0), 0) &&
|
||||
!!expires.value &&
|
||||
expires.value > Date.now() &&
|
||||
expires.value <= Date.parse(grant.input.expiresAt) &&
|
||||
!!approvedBy.value.trim() &&
|
||||
!!note.value.trim() &&
|
||||
acknowledged.value
|
||||
)
|
||||
})
|
||||
/** 全局NMessage与就地说明并行,原费用保持原样。 */ const message = useActionMessage()
|
||||
/** 用户主动编译所选镜头,来源/计划来自正式免费API。 */
|
||||
async function prepare() {
|
||||
if (
|
||||
preparing.value ||
|
||||
saving.value ||
|
||||
props.disabled ||
|
||||
!parent.value ||
|
||||
!model.value ||
|
||||
!shotIds.value.length ||
|
||||
shotIds.value.length > 100
|
||||
)
|
||||
return
|
||||
const current = ++version,
|
||||
project = props.projectId,
|
||||
ids = [...shotIds.value],
|
||||
parameters = { ...options.value },
|
||||
expectedModel = model.value
|
||||
preparing.value = true
|
||||
plans.value = null
|
||||
acknowledged.value = false
|
||||
error.value = ''
|
||||
try {
|
||||
const rows: ImageAuthorizationPreview[] = []
|
||||
for (const shotId of ids)
|
||||
rows.push(
|
||||
await imageAuthorizationApi.preview(project, {
|
||||
scope: 'keyframe',
|
||||
targetId: shotId,
|
||||
providerName: 'openai-image',
|
||||
generationOptions: parameters
|
||||
})
|
||||
)
|
||||
if (disposed || current !== version) return
|
||||
if (
|
||||
rows.some(
|
||||
(row, index) =>
|
||||
row.provider !== 'openai-image' ||
|
||||
row.model !== expectedModel ||
|
||||
row.context.projectId !== project ||
|
||||
row.context.scope !== 'keyframe' ||
|
||||
row.context.targetId !== ids[index] ||
|
||||
!/^[a-f0-9]{64}$/.test(row.context.sourceFingerprint) ||
|
||||
!/^[a-f0-9]{64}$/.test(row.planFingerprint)
|
||||
)
|
||||
)
|
||||
throw new Error('当前型号或精确费用计划不匹配,请重新核对。')
|
||||
plans.value = rows.map(row => ({
|
||||
shotId: row.context.targetId,
|
||||
model: row.model,
|
||||
sourceFingerprint: row.context.sourceFingerprint,
|
||||
planFingerprint: row.planFingerprint
|
||||
}))
|
||||
} catch (cause) {
|
||||
if (current === version) {
|
||||
error.value = errorMessage(cause)
|
||||
message?.error(error.value)
|
||||
}
|
||||
} finally {
|
||||
if (current === version) preparing.value = false
|
||||
}
|
||||
}
|
||||
/** 底栏仅登记明确批准,不调用图片/模型;409清除预检,保留草稿并刷新正式授权。 */
|
||||
async function submit() {
|
||||
if (!canSubmit.value || !plans.value || !parent.value) return
|
||||
if (!expires.value || expires.value <= Date.now() || Date.parse(parent.value.input.expiresAt) <= Date.now()) {
|
||||
acknowledged.value = false
|
||||
error.value = '本次许可或原授权已到期,请重新核对有效期。'
|
||||
message?.error(error.value)
|
||||
return
|
||||
}
|
||||
const project = props.projectId,
|
||||
body = {
|
||||
mode: 'bounded' as const,
|
||||
idempotencyKey: nonce.value,
|
||||
parentAuthorizationId: parent.value.id,
|
||||
acceptedUnknownRequests: blockers.value.map(row => ({
|
||||
requestId: row.id,
|
||||
inputFingerprint: row.inputFingerprint!
|
||||
})),
|
||||
provider: 'openai-image' as const,
|
||||
model: model.value,
|
||||
targets: plans.value.map(
|
||||
row =>
|
||||
({
|
||||
shotId: row.shotId,
|
||||
sourceFingerprint: row.sourceFingerprint,
|
||||
planFingerprint: row.planFingerprint,
|
||||
generationOptions: { ...options.value },
|
||||
maxRequests: counts.value[row.shotId]!
|
||||
}) satisfies ImageBoundedTarget
|
||||
),
|
||||
maxRequests: total.value!,
|
||||
expiresAt: new Date(expires.value!).toISOString(),
|
||||
acknowledgeUnknownPriorBilling: true as const,
|
||||
acknowledgeVariableBilling: true as const,
|
||||
approvedBy: approvedBy.value.trim(),
|
||||
approvalNote: note.value.trim()
|
||||
}
|
||||
saving.value = true
|
||||
try {
|
||||
const result = await imageAuthorizationApi.create(project, body)
|
||||
if (disposed || project !== props.projectId) return
|
||||
acknowledged.value = false
|
||||
message?.info(
|
||||
result.status === 'revoked'
|
||||
? '原有限许可已撤销,不能领取。'
|
||||
: '有限许可已登记,未生成图片;旧未知费用与预留仍保留。'
|
||||
)
|
||||
emit('changed')
|
||||
} catch (cause) {
|
||||
if (!disposed && project === props.projectId) {
|
||||
error.value = errorMessage(cause)
|
||||
message?.error(error.value)
|
||||
if (cause instanceof ApiError && cause.status === 409) {
|
||||
plans.value = null
|
||||
acknowledged.value = false
|
||||
emit('refresh')
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
/** 复用原设置固定底栏。 */ defineExpose({ canSubmit, saving, submit, submitLabel: '登记有限风险许可' })
|
||||
</script>
|
||||
<template>
|
||||
<!-- 以下是原预算内有限风险接受,所有批准字段由用户明确填写。 -->
|
||||
<section class="workspace-section-stack" aria-label="有限跨镜风险许可">
|
||||
<WorkspaceSectionHeading
|
||||
title="接受旧费用风险,有限继续"
|
||||
description="使用原预算;旧未知请求、预留和费用阻断继续保留,不代表账单已核清。"
|
||||
/>
|
||||
<div class="workspace-form-field">
|
||||
<span>原持续授权</span
|
||||
><NSelect
|
||||
v-model:value="parentId"
|
||||
:options="parents"
|
||||
:disabled="saving || disabled"
|
||||
aria-label="有限许可原授权"
|
||||
placeholder="选择原持续授权预算"
|
||||
/>
|
||||
</div>
|
||||
<p v-if="parent" class="text-sm">
|
||||
原预算 {{ formatMicros(parent.input.budgetMicros) }} · 已记账及未结预留
|
||||
{{ formatMicros(parent.accountedMicros) }} · 剩余 {{ formatMicros(parent.remainingMicros) }} · 单次预留
|
||||
{{ formatMicros(parent.input.perRequestMicros) }} · 剩余 {{ parent.remainingRequests }} 次
|
||||
</p>
|
||||
<GenerationModelControls
|
||||
v-if="catalog?.images.length && targets.data.value?.aspectRatio"
|
||||
type="image"
|
||||
:catalog="catalog"
|
||||
provider="openai-image"
|
||||
:options="options"
|
||||
:aspect-ratio="targets.data.value.aspectRatio"
|
||||
:disabled="saving || disabled"
|
||||
@update:options="options = $event"
|
||||
/>
|
||||
<p v-else-if="parent" class="text-sm">原授权型号未在当前OpenAI目录中启用。</p>
|
||||
<div class="workspace-form-field">
|
||||
<span>具体镜头</span
|
||||
><NSelect
|
||||
v-model:value="shotIds"
|
||||
:options="targets.data.value?.items ?? []"
|
||||
multiple
|
||||
:loading="targets.loading.value"
|
||||
:disabled="saving || disabled"
|
||||
aria-label="有限许可镜头"
|
||||
/>
|
||||
</div>
|
||||
<p v-if="targets.error.value" role="alert">{{ targets.error.value }}</p>
|
||||
<NButton
|
||||
class="self-start"
|
||||
:disabled="saving || disabled || !parent || !model || !shotIds.length"
|
||||
:loading="preparing"
|
||||
@click="prepare"
|
||||
>免费核对逐镜费用计划</NButton
|
||||
>
|
||||
<article v-for="row in plans ?? []" :key="row.shotId" class="workspace-section-stack">
|
||||
<p class="text-sm">
|
||||
{{ targets.data.value?.items.find(target => target.value === row.shotId)?.label }} · OpenAI /
|
||||
{{ row.model }}
|
||||
</p>
|
||||
<RawDataDetails :value="row" title="当前来源与精确费用计划" />
|
||||
<label class="workspace-form-field"
|
||||
><span>本镜次数(1~100)</span
|
||||
><NInputNumber
|
||||
v-model:value="counts[row.shotId]"
|
||||
:min="1"
|
||||
:max="100"
|
||||
:precision="0"
|
||||
:disabled="saving"
|
||||
:aria-label="`镜头 ${row.shotId} 批准次数`"
|
||||
/></label>
|
||||
</article>
|
||||
<label class="workspace-form-field"
|
||||
><span>总次数(1~100)</span
|
||||
><NInputNumber
|
||||
v-model:value="total"
|
||||
:min="1"
|
||||
:max="100"
|
||||
:precision="0"
|
||||
:disabled="saving || disabled"
|
||||
aria-label="有限许可总次数"
|
||||
/></label>
|
||||
<div class="workspace-form-field">
|
||||
<span>有效期(不晚于原授权)</span
|
||||
><NDatePicker
|
||||
v-model:value="expires"
|
||||
type="datetime"
|
||||
clearable
|
||||
:disabled="saving || disabled"
|
||||
aria-label="有限许可到期时间"
|
||||
/>
|
||||
</div>
|
||||
<p v-if="!blockers.length" class="text-sm">当前没有需接受的未知阻断,请使用原有效授权。</p>
|
||||
<article v-for="row in blockers" :key="row.id" class="space-y-2 text-sm">
|
||||
<p>
|
||||
原未知请求 {{ row.id }} · {{ row.input.model }} · 预留 {{ formatMicros(row.input.reservedMicros) }} ·
|
||||
账单 {{ formatMicros(row.output?.actualBilledMicros) }}
|
||||
</p>
|
||||
<NCheckbox
|
||||
:checked="acceptedIds.includes(row.id)"
|
||||
:disabled="saving || row.status !== 'unknown'"
|
||||
@update:checked="
|
||||
acceptedIds = $event ? [...acceptedIds, row.id] : acceptedIds.filter(id => id !== row.id)
|
||||
"
|
||||
>我明确接受此原请求费用仍未知</NCheckbox
|
||||
>
|
||||
</article>
|
||||
<label class="workspace-form-field"
|
||||
><span>批准人</span
|
||||
><NInput v-model:value="approvedBy" :maxlength="200" :disabled="saving" aria-label="有限许可批准人"
|
||||
/></label>
|
||||
<label class="workspace-form-field"
|
||||
><span>批准说明</span
|
||||
><NInput
|
||||
v-model:value="note"
|
||||
type="textarea"
|
||||
:maxlength="2000"
|
||||
:disabled="saving"
|
||||
aria-label="有限许可批准说明"
|
||||
/></label>
|
||||
<NCheckbox v-model:checked="acknowledged" :disabled="saving || disabled"
|
||||
>我已核对原未知费用、每镜计划及次数;接受按Token浮动计费,单次实际费用可能超过预留。本许可只供逐镜主动操作,不自动用完剩余次数。</NCheckbox
|
||||
>
|
||||
<p v-if="error" role="alert" class="text-sm">{{ error }}</p>
|
||||
</section>
|
||||
</template>
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import ImageBillingAuditPanel from './ImageBillingAuditPanel.vue'
|
||||
import BoundedAuthorizationFields from './BoundedAuthorizationFields.vue'
|
||||
import { computed, onScopeDispose, ref, watch } from 'vue'
|
||||
import { NButton, NCheckbox, NDatePicker, NInput, NInputNumber, NSelect, NCollapse, NCollapseItem } from 'naive-ui'
|
||||
import { useQuery } from '../../composables/useQuery'
|
||||
@@ -52,6 +53,10 @@ function emptyAuthorizationDraft() {
|
||||
}
|
||||
/** 用户明确填写的持续授权草稿。 */
|
||||
const draft = ref(emptyAuthorizationDraft())
|
||||
/** 原授权页面中的登记模式,不增加新页面或预算。 */
|
||||
const registrationMode = ref<'standing' | 'bounded'>('standing')
|
||||
/** 有限许可仍由同一固定底栏提交。 */
|
||||
const boundedPanel = ref<InstanceType<typeof BoundedAuthorizationFields> | null>(null)
|
||||
/** 原设置抽屉内的费用审计模式,不叠加新主界面。 */
|
||||
const auditRequestId = ref('')
|
||||
/** 同一固定底栏提交当前图片审计。 */
|
||||
@@ -97,18 +102,22 @@ const submitLabel = computed(
|
||||
? '确认撤销授权'
|
||||
: additionalRequestId.value
|
||||
? '登记人工有限追加许可'
|
||||
: '登记有限持续授权')
|
||||
: registrationMode.value === 'bounded'
|
||||
? '登记有限风险许可'
|
||||
: '登记有限持续授权')
|
||||
)
|
||||
/** 读取失败时保守禁止写入,空表单允许主动校验。 */
|
||||
const canSave = computed(() =>
|
||||
auditRequestId.value
|
||||
? !!auditPanel.value?.canSubmit
|
||||
: !props.disabled &&
|
||||
!saving.value &&
|
||||
!!query.data.value &&
|
||||
!query.loading.value &&
|
||||
!query.error.value &&
|
||||
(revokeId.value !== '' || additionalRequestId.value !== '' || !!modelOptions.value.length)
|
||||
: registrationMode.value === 'bounded' && !revokeId.value && !additionalRequestId.value
|
||||
? !!boundedPanel.value?.canSubmit
|
||||
: !props.disabled &&
|
||||
!saving.value &&
|
||||
!!query.data.value &&
|
||||
!query.loading.value &&
|
||||
!query.error.value &&
|
||||
(revokeId.value !== '' || additionalRequestId.value !== '' || !!modelOptions.value.length)
|
||||
)
|
||||
watch(saving, value => emit('busy', value), { flush: 'sync' })
|
||||
watch(
|
||||
@@ -126,6 +135,10 @@ async function save() {
|
||||
await auditPanel.value?.submit()
|
||||
return
|
||||
}
|
||||
if (registrationMode.value === 'bounded' && !revokeId.value && !additionalRequestId.value) {
|
||||
await boundedPanel.value?.submit()
|
||||
return
|
||||
}
|
||||
const project = props.projectId
|
||||
if (revokeId.value) {
|
||||
if (!revocation.value.revokedBy.trim() || !revocation.value.reason.trim()) {
|
||||
@@ -257,6 +270,7 @@ watch(
|
||||
() => props.projectId,
|
||||
() => {
|
||||
draft.value = emptyAuthorizationDraft()
|
||||
registrationMode.value = 'standing'
|
||||
revocation.value = { revokedBy: '', reason: '' }
|
||||
validation.value = ''
|
||||
auditRequestId.value = ''
|
||||
@@ -303,6 +317,18 @@ defineExpose({ save, canSave, submitLabel })
|
||||
<NButton class="self-start" :loading="query.loading.value" :disabled="saving" @click="query.refresh"
|
||||
>刷新授权与请求</NButton
|
||||
>
|
||||
<div class="workspace-form-field">
|
||||
<span>登记方式</span
|
||||
><NSelect
|
||||
v-model:value="registrationMode"
|
||||
:disabled="saving"
|
||||
:options="[
|
||||
{ label: '有限持续授权', value: 'standing' },
|
||||
{ label: '接受旧费用风险,有限继续', value: 'bounded' }
|
||||
]"
|
||||
aria-label="图片授权登记方式"
|
||||
/>
|
||||
</div>
|
||||
<p v-if="query.loading.value && !query.data.value" role="status">正在读取授权…</p>
|
||||
<p v-if="query.error.value" role="alert" class="text-sm text-muted">{{ query.error.value }}</p>
|
||||
<p v-if="query.data.value?.billingBlocked" class="surface-inset p-4 text-sm" role="status">
|
||||
@@ -408,8 +434,8 @@ defineExpose({ save, canSave, submitLabel })
|
||||
<!-- 以下是原精确计划的人工追加次数和撤销,原unknown仍保留。 -->
|
||||
<section v-if="query.data.value?.additionalAuthorizations?.length" class="workspace-section-stack">
|
||||
<WorkspaceSectionHeading
|
||||
title="人工有限追加许可"
|
||||
description="只适用原精确计划,不增加预算;一次成功后停止,不自动消费剩余次数。"
|
||||
title="人工有限许可"
|
||||
description="只适用已批准的镜头与精确计划,使用原预算;每次由用户主动操作,不自动消费剩余次数。"
|
||||
/>
|
||||
<article
|
||||
v-for="permit in query.data.value.additionalAuthorizations"
|
||||
@@ -428,7 +454,23 @@ defineExpose({ save, canSave, submitLabel })
|
||||
{{ permit.remainingRequests }} 次
|
||||
</p>
|
||||
<p v-if="permit.status === 'revoked'">剩余次数不可领取。</p>
|
||||
<p>原请求 {{ permit.input.parentRequestId }} · 批准人 {{ permit.input.approvedBy }}</p>
|
||||
<p v-else-if="permit.remainingRequests <= 0">次数已用尽,不可再次领取。</p>
|
||||
<p>
|
||||
{{ permit.input.mode === 'bounded' ? '有限跨镜风险许可' : '同计划人工追加' }} · 批准人
|
||||
{{ permit.input.approvedBy }}
|
||||
</p>
|
||||
<p v-if="permit.input.mode === 'additional'">原请求 {{ permit.input.parentRequestId }}</p>
|
||||
<template v-else
|
||||
><p>
|
||||
原持续授权 {{ permit.input.parentAuthorizationId }} · 到期
|
||||
{{ new Date(permit.input.expiresAt).toLocaleString()
|
||||
}}{{ Date.parse(permit.input.expiresAt) <= Date.now() ? ' · 已到期,不可领取' : '' }}
|
||||
</p>
|
||||
<p v-for="target in permit.targets ?? []" :key="target.shotId">
|
||||
镜头 {{ target.shotId }} · 已用 {{ target.usedRequests }}/{{ target.maxRequests }} 次 · 剩余
|
||||
{{ Math.max(0, target.maxRequests - target.usedRequests) }} 次
|
||||
</p></template
|
||||
>
|
||||
<RawDataDetails :value="permit" title="追加许可与原计划详情" /><NButton
|
||||
v-if="permit.status === 'approved'"
|
||||
:disabled="saving || disabled"
|
||||
@@ -508,6 +550,17 @@ defineExpose({ save, canSave, submitLabel })
|
||||
>取消追加许可登记</NButton
|
||||
>
|
||||
</section>
|
||||
<BoundedAuthorizationFields
|
||||
v-else-if="registrationMode === 'bounded'"
|
||||
ref="boundedPanel"
|
||||
:project-id="projectId"
|
||||
:list="query.data.value"
|
||||
:catalog="catalog.data.value"
|
||||
:disabled="disabled || query.loading.value || !!query.error.value"
|
||||
@busy="saving = $event"
|
||||
@changed="auditChanged"
|
||||
@refresh="query.refresh"
|
||||
/>
|
||||
<!-- 以下是用户明确填写的有限持续授权,不预填金额、次数及日期 -->
|
||||
<section v-else class="workspace-section-stack">
|
||||
<WorkspaceSectionHeading
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { request } from '../../lib/http'
|
||||
import type {
|
||||
ImageAdditionalAuthorizationInput,
|
||||
ImageBoundedAuthorizationInput,
|
||||
ImageAuthorizationInput,
|
||||
ImageAuthorizationList,
|
||||
ImageAuthorizationPreview,
|
||||
@@ -40,8 +41,10 @@ export const imageAuthorizationApi = {
|
||||
* @param input 本次不可变批准
|
||||
* @returns 原授权标识及状态
|
||||
*/
|
||||
create: (projectId: string, input: ImageAuthorizationInput | ImageAdditionalAuthorizationInput) =>
|
||||
request<{ authorizationId: string; status: string }>(root(projectId), { method: 'POST', body: input }),
|
||||
create: (
|
||||
projectId: string,
|
||||
input: ImageAuthorizationInput | ImageAdditionalAuthorizationInput | ImageBoundedAuthorizationInput
|
||||
) => request<{ authorizationId: string; status: string }>(root(projectId), { method: 'POST', body: input }),
|
||||
/**
|
||||
* 撤销未来领取并保留原件。
|
||||
* @param projectId 正式项目
|
||||
|
||||
@@ -123,6 +123,7 @@ export function imageChargeEligibility(
|
||||
? {
|
||||
allowed: true,
|
||||
reusable: false,
|
||||
expiresAt: grant.input.expiresAt,
|
||||
message: `本次使用已批准的 OpenAI 图片授权,剩余 ${formatMicros(grant.remainingMicros)},可请求 ${grant.remainingRequests} 次。最终额度以提交时核验为准。`
|
||||
}
|
||||
: {
|
||||
@@ -173,7 +174,11 @@ export function additionalImageEligibility(
|
||||
planFingerprint: string
|
||||
) {
|
||||
const permit = list.additionalAuthorizations?.find(row => row.id === permitId)
|
||||
const parent = list.requests.find(row => row.id === permit?.input.parentRequestId)
|
||||
if (permit?.input.mode === 'bounded')
|
||||
return boundedImageEligibility(list, permitId, projectId, targetId, model, sourceFingerprint, planFingerprint)
|
||||
const parent = list.requests.find(
|
||||
row => row.id === (permit?.input.mode === 'additional' ? permit.input.parentRequestId : undefined)
|
||||
)
|
||||
const grant = list.authorizations.find(row => row.id === parent?.input.authorizationId)
|
||||
if (
|
||||
!permit ||
|
||||
@@ -221,6 +226,91 @@ export function additionalImageEligibility(
|
||||
return {
|
||||
allowed: true,
|
||||
reusable: false,
|
||||
expiresAt: grant.input.expiresAt,
|
||||
message: `人工追加许可:已用 ${permit.usedRequests} 次,剩余 ${permit.remainingRequests} 次。原未知请求和预留保持;仅本次主动生成,不会自动用完剩余次数。`
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 核对bounded总/逐镜次数、固定来源、原预算和本次仍被覆盖的未知费用,最终领取由服务端事务裁决。
|
||||
* @param list 原项目费用投影
|
||||
* @param permitId 用户主动选中的许可
|
||||
* @param projectId 原项目
|
||||
* @param shotId 本镜头
|
||||
* @param model 当前实际型号
|
||||
* @param source 当前正式来源
|
||||
* @param plan 当前精确费用计划
|
||||
* @returns 准入说明,不代表核清、质量或采用
|
||||
*/
|
||||
export function boundedImageEligibility(
|
||||
list: ImageAuthorizationList,
|
||||
permitId: string,
|
||||
projectId: string,
|
||||
shotId: string,
|
||||
model: string,
|
||||
source: string,
|
||||
plan: string
|
||||
) {
|
||||
const permit = list.additionalAuthorizations?.find(row => row.id === permitId)
|
||||
if (!permit || permit.input.mode !== 'bounded')
|
||||
return { allowed: false, reusable: false, message: '请主动选择有效的有限许可。' }
|
||||
const input = permit.input,
|
||||
grant = list.authorizations.find(row => row.id === input.parentAuthorizationId),
|
||||
target = permit.targets?.find(row => row.shotId === shotId)
|
||||
if (
|
||||
permit.status !== 'approved' ||
|
||||
!Number.isSafeInteger(permit.remainingRequests) ||
|
||||
permit.remainingRequests < 1 ||
|
||||
!(Date.parse(input.expiresAt) > Date.now()) ||
|
||||
input.provider !== 'openai-image' ||
|
||||
input.model !== model ||
|
||||
!target ||
|
||||
target.sourceFingerprint !== source ||
|
||||
target.planFingerprint !== plan ||
|
||||
!Number.isSafeInteger(target.usedRequests) ||
|
||||
target.usedRequests < 0 ||
|
||||
target.usedRequests >= target.maxRequests ||
|
||||
!grant ||
|
||||
grant.input.mode !== 'standing' ||
|
||||
grant.status !== 'approved' ||
|
||||
grant.expired ||
|
||||
!(Date.parse(grant.input.expiresAt) > Date.now()) ||
|
||||
Date.parse(input.expiresAt) > Date.parse(grant.input.expiresAt) ||
|
||||
!grant.input.models.includes(model) ||
|
||||
!grant.input.scopes.includes('keyframe') ||
|
||||
(grant.input.targetIds && !grant.input.targetIds.includes(shotId)) ||
|
||||
grant.remainingRequests < 1 ||
|
||||
grant.remainingMicros < grant.input.perRequestMicros
|
||||
)
|
||||
return {
|
||||
allowed: false,
|
||||
reusable: false,
|
||||
message: '有限许可已失效、用尽,或镜头、型号、来源、计划与原预算不匹配,请刷新核对。'
|
||||
}
|
||||
const blockers = list.requests.filter(row => list.blockingRequestIds.includes(row.id))
|
||||
if (
|
||||
blockers.length !== list.blockingRequestIds.length ||
|
||||
blockers.some(
|
||||
row =>
|
||||
row.status !== 'unknown' ||
|
||||
row.input.projectId !== projectId ||
|
||||
row.input.authorizationId !== grant.id ||
|
||||
row.input.model !== model ||
|
||||
!row.inputFingerprint ||
|
||||
!input.acceptedUnknownRequests.some(
|
||||
accepted => accepted.requestId === row.id && accepted.inputFingerprint === row.inputFingerprint
|
||||
)
|
||||
)
|
||||
)
|
||||
return {
|
||||
allowed: false,
|
||||
reusable: false,
|
||||
message: '出现未被明确接受的未知费用或在途请求,已停止本许可后续领取。'
|
||||
}
|
||||
return {
|
||||
allowed: true,
|
||||
reusable: false,
|
||||
expiresAt: input.expiresAt,
|
||||
message: `有限许可:本镜已用 ${target.usedRequests}/${target.maxRequests} 次,总剩余 ${permit.remainingRequests} 次。使用原持续授权预算;旧未知费用仍保留,仅执行本次主动操作。`
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ export interface ImageAuthorizationInput {
|
||||
|
||||
/** 原始图片请求与费用回执。 */
|
||||
export interface ImageChargeRequest {
|
||||
/** 服务端计算的原输入SHA,用于明确接受旧未知请求。 */ inputFingerprint?: string
|
||||
/** 原请求标识。 */ id: string
|
||||
/** 原执行状态。 */ status: string
|
||||
/** 当前有效审计,不覆盖原状态、用量或账单。 */ billingAudit?: {
|
||||
@@ -58,11 +59,17 @@ export interface ImageAuthorizationList {
|
||||
/** 人工有限追加许可,不增加原预算。 */ additionalAuthorizations?: Array<{
|
||||
/** 正式追加许可。 */ id: string
|
||||
/** approved或revoked等真实状态。 */ status: string
|
||||
/** 原不可变批准及服务端父输入摘要。 */ input: ImageAdditionalAuthorizationInput & {
|
||||
/** 原不可变批准及服务端父输入摘要。 */ input: (
|
||||
| ImageAdditionalAuthorizationInput
|
||||
| ImageBoundedAuthorizationInput
|
||||
) & {
|
||||
/** 原完整输入摘要。 */ parentInputFingerprint: string
|
||||
}
|
||||
/** 已领取的模型请求次数。 */ usedRequests: number
|
||||
/** 尚可人工领取次数。 */ remainingRequests: number
|
||||
/** bounded逐镜正式计数,旧additional为null或缺省。 */ targets?: Array<
|
||||
ImageBoundedTarget & { /** 已领取次数。 */ usedRequests: number }
|
||||
> | null
|
||||
}>
|
||||
/** 服务端计算的授权投影。 */ authorizations: Array<{
|
||||
/** 原批准记录。 */ id: string
|
||||
@@ -118,3 +125,33 @@ export interface ImageAdditionalAuthorizationInput {
|
||||
/** 实际批准人。 */ approvedBy: string
|
||||
/** 批准说明。 */ approvalNote: string
|
||||
}
|
||||
|
||||
/** 单镜白名单来自原免费费用计划,不接受浏览器自行拼接来源。 */
|
||||
export interface ImageBoundedTarget {
|
||||
/** 正式镜头。 */ shotId: string
|
||||
/** 当前来源。 */ sourceFingerprint: string
|
||||
/** 精确费用计划,区别于生图Preview。 */ planFingerprint: string
|
||||
/** 本次正式参数。 */ generationOptions?: Record<string, unknown>
|
||||
/** 可选实际宽度。 */ width?: number
|
||||
/** 可选实际高度。 */ height?: number
|
||||
/** 人工批准的本镜次数。 */ maxRequests: number
|
||||
}
|
||||
/** 明确接受旧未知费用的有限跨镜许可,不新增预算或清除旧账。 */
|
||||
export interface ImageBoundedAuthorizationInput {
|
||||
/** 跨镜有限模式。 */ mode: 'bounded'
|
||||
/** 不可变批准幂等键。 */ idempotencyKey: string
|
||||
/** 原standing批准。 */ parentAuthorizationId: string
|
||||
/** 用户接受的原未知请求及正式输入版本。 */ acceptedUnknownRequests: Array<{
|
||||
/** 原请求。 */ requestId: string
|
||||
/** 原输入SHA。 */ inputFingerprint: string
|
||||
}>
|
||||
/** 固定供应方。 */ provider: 'openai-image'
|
||||
/** 固定单一实际型号。 */ model: string
|
||||
/** 逐镜精确白名单。 */ targets: ImageBoundedTarget[]
|
||||
/** 总次数。 */ maxRequests: number
|
||||
/** 不晚于原standing的有效期。 */ expiresAt: string
|
||||
/** 明确接受旧未知费用。 */ acknowledgeUnknownPriorBilling: true
|
||||
/** 接受单次浮动计费。 */ acknowledgeVariableBilling: true
|
||||
/** 实际批准人。 */ approvedBy: string
|
||||
/** 批准范围说明。 */ approvalNote: string
|
||||
}
|
||||
@@ -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。
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
import { userFacingText } from '../../../lib/user-facing-text'
|
||||
import { computed } from 'vue'
|
||||
import { NButton, NCheckbox, NInput, NInputNumber, NSelect, NTag } from 'naive-ui'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { NButton, NCheckbox, NCollapse, NCollapseItem, NInput, NInputNumber, NSelect, NTag } from 'naive-ui'
|
||||
import RawDataDetails from '../../../components/ui/RawDataDetails.vue'
|
||||
import { AppDialog, AssetImage } from '../../../components/ui'
|
||||
import ContextNotice from '../../../components/ui/ContextNotice.vue'
|
||||
import FeedbackMessage from '../../../components/ui/FeedbackMessage.vue'
|
||||
import { useMotionRevision } from '../useMotionRevision'
|
||||
import { formatDate } from '../../../lib/format'
|
||||
|
||||
@@ -31,7 +33,6 @@ const {
|
||||
preview,
|
||||
error,
|
||||
notice,
|
||||
saved,
|
||||
pending,
|
||||
blocked,
|
||||
formBlocked,
|
||||
@@ -42,16 +43,48 @@ const {
|
||||
/** 版本选项包含来源、创建时间及真实生效标记。 */
|
||||
const options = computed(() =>
|
||||
(state.context.data.value?.history.revisions ?? []).map(item => ({
|
||||
label: `${item.isActive ? '生效 · ' : ''}${item.source === 'manual' ? '人工修订' : 'AI 原始'} · ${formatDate(item.createdAt)} · ${item.revisionId}`,
|
||||
label: `${item.isActive ? '已采用 · ' : ''}${item.source === 'manual' ? '人工修订' : item.source === 'failed_candidate' ? '失败候选根(原质量失败)' : 'AI 原始'} · ${formatDate(item.createdAt)}`,
|
||||
value: item.revisionId
|
||||
}))
|
||||
)
|
||||
/** 结构错误与非阻断预警分别展示,不将预警当作通过资格。 */
|
||||
const previewMessages = computed(() => [
|
||||
...(preview.value?.formalIssues ?? []),
|
||||
...(preview.value?.schemaIssues ?? []).map(item => `${item.path}:${item.message}`),
|
||||
...(preview.value?.timelineIssues ?? []).map(item => item.message),
|
||||
...(preview.value?.actionDensityIssues ?? []).map(item => item.message)
|
||||
])
|
||||
/** 完整交互原文按需编辑,未填写新事实时保持空数组。 */
|
||||
const interactionsText = ref('[]')
|
||||
/** 复制新版本时同步原交互;普通阶段编辑不改写原交互字段。 */
|
||||
watch(
|
||||
draft,
|
||||
() => {
|
||||
interactionsText.value = JSON.stringify(draft.value.interactions ?? [], null, 2)
|
||||
state.interactionError.value = ''
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
/**
|
||||
* 保留未完成的JSON输入,只有完整对象数组才进入正式草稿。
|
||||
* @param value 用户编辑的完整交互JSON
|
||||
*/
|
||||
function updateInteractions(value: string) {
|
||||
interactionsText.value = value
|
||||
try {
|
||||
const parsed: unknown = JSON.parse(value)
|
||||
if (
|
||||
!Array.isArray(parsed) ||
|
||||
parsed.length > 12 ||
|
||||
parsed.some(row => !row || typeof row !== 'object' || Array.isArray(row))
|
||||
)
|
||||
throw new Error()
|
||||
draft.value.interactions = parsed
|
||||
state.interactionError.value = ''
|
||||
} catch {
|
||||
state.interactionError.value = '请提供完整交互对象数组,最多12项;没有交互时填写[]。'
|
||||
}
|
||||
}
|
||||
/** 任务返回问题可能是视觉问题或门禁说明,按实际描述展示。 */
|
||||
const taskIssues = computed(() =>
|
||||
Array.isArray(record.value?.result?.issues)
|
||||
@@ -118,6 +151,8 @@ function updateRefs(index: number, value: string) {
|
||||
wide
|
||||
>
|
||||
<div class="motion-revision-layout">
|
||||
<FeedbackMessage v-if="error" :message="error" />
|
||||
<FeedbackMessage v-if="notice" :message="notice" type="info" />
|
||||
<ContextNotice v-if="state.context.error.value || error" type="error" :show-icon="false">{{
|
||||
state.context.error.value || error
|
||||
}}</ContextNotice>
|
||||
@@ -134,6 +169,11 @@ function updateRefs(index: number, value: string) {
|
||||
>刷新版本与主首帧</NButton
|
||||
>
|
||||
</div>
|
||||
<RawDataDetails
|
||||
v-if="state.context.data.value"
|
||||
:value="state.context.data.value.history"
|
||||
title="完整修订历史与采用指针"
|
||||
/>
|
||||
<label v-if="options.length" class="motion-revision-field">
|
||||
<span>编辑来源</span>
|
||||
<NSelect
|
||||
@@ -144,7 +184,13 @@ function updateRefs(index: number, value: string) {
|
||||
@update:value="state.select($event)"
|
||||
/>
|
||||
</label>
|
||||
<p v-else class="motion-revision-description">尚未初始化版本历史,首次保存会封存原始 AI 规划。</p>
|
||||
<p v-else class="motion-revision-description">
|
||||
{{
|
||||
state.requiresCandidate.value
|
||||
? '尚无正式原计划,可只读核对原失败候选后承接人工修订。'
|
||||
: '尚未初始化版本历史,首次保存会封存原始 AI 规划。'
|
||||
}}
|
||||
</p>
|
||||
<div class="motion-revision-source">
|
||||
<div v-if="state.context.data.value?.primary?.imageUrl" class="motion-revision-thumbnail">
|
||||
<AssetImage
|
||||
@@ -161,11 +207,81 @@ function updateRefs(index: number, value: string) {
|
||||
</div>
|
||||
<div>
|
||||
<dt>当前生效版本</dt>
|
||||
<dd>{{ state.context.data.value?.history.activeRevisionId ?? 'AI 原始规划' }}</dd>
|
||||
<dd>
|
||||
{{
|
||||
state.context.data.value?.history.activeRevisionId ??
|
||||
(state.context.data.value?.preview.motionPlanAvailable
|
||||
? 'AI 原始规划'
|
||||
: '尚无正式采用版本')
|
||||
}}
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</div>
|
||||
</section>
|
||||
<!-- 以下是原失败Task/Workflow/质量及公开回执,读取和载入均不保存或启动模型。 -->
|
||||
<section
|
||||
v-if="state.requiresCandidate.value || state.failedCandidate.value || state.candidateOrigin.value"
|
||||
class="workspace-section-stack"
|
||||
aria-label="原失败动作候选"
|
||||
>
|
||||
<h3 class="text-sm font-semibold">原失败动作候选</h3>
|
||||
<template v-if="state.requiresCandidate.value">
|
||||
<label class="workspace-form-field"
|
||||
><span>原Task(可选,留空查当前任务)</span
|
||||
><NInput
|
||||
v-model:value="state.failedTaskId.value"
|
||||
:disabled="blocked || state.candidateLoading.value"
|
||||
aria-label="原失败动作Task"
|
||||
/></label>
|
||||
<NButton
|
||||
class="self-start"
|
||||
:loading="state.candidateLoading.value"
|
||||
:disabled="blocked"
|
||||
@click="state.readCandidate"
|
||||
>读取原失败候选</NButton
|
||||
>
|
||||
</template>
|
||||
<p v-if="state.failedCandidate.value" class="text-sm">
|
||||
原Task {{ state.failedCandidate.value.taskId }} · 原Workflow
|
||||
{{ state.failedCandidate.value.executionId }} · 原质量
|
||||
{{ state.failedCandidate.value.status === 'failed' ? '未通过' : '不可作为当前失败候选' }}
|
||||
</p>
|
||||
<RawDataDetails
|
||||
v-if="state.failedCandidate.value"
|
||||
:value="state.failedCandidate.value"
|
||||
title="原模型候选、质量与公开回执"
|
||||
/>
|
||||
<RawDataDetails
|
||||
v-if="state.candidateOrigin.value"
|
||||
:value="state.candidateOrigin.value"
|
||||
title="失败根版本来源证明"
|
||||
/>
|
||||
<NButton
|
||||
v-if="state.candidateOrigin.value && !state.failedCandidate.value"
|
||||
class="self-start"
|
||||
:loading="state.candidateLoading.value"
|
||||
:disabled="blocked"
|
||||
@click="state.readOriginCandidate"
|
||||
>查看原失败任务回执</NButton
|
||||
>
|
||||
<NButton
|
||||
v-if="state.requiresCandidate.value && state.candidateReady.value"
|
||||
class="self-start"
|
||||
:disabled="blocked"
|
||||
@click="state.useCandidate"
|
||||
>载入人工草稿</NButton
|
||||
>
|
||||
<NCheckbox
|
||||
v-if="state.requiresCandidate.value && state.candidateReady.value"
|
||||
v-model:checked="state.failedAcknowledged.value"
|
||||
:disabled="blocked"
|
||||
>我已核对完整人工草稿与原失败来源;只保存人工子版本,原候选仍未通过,不启动起点审核或采用。</NCheckbox
|
||||
>
|
||||
</section>
|
||||
<p v-if="state.revision.value?.source === 'failed_candidate'" class="text-sm">
|
||||
这是原质量失败的根版本,不能直接起点审核或正式采用。修改后可保存人工子版本。
|
||||
</p>
|
||||
<!-- 以下是完整阶段表单模块,长文本独占一行,短字段共用两列 -->
|
||||
<section
|
||||
v-for="(beat, index) in draft.beats"
|
||||
@@ -250,12 +366,43 @@ function updateRefs(index: number, value: string) {
|
||||
:aria-label="`阶段 ${index + 1} 收尾状态`"
|
||||
/>
|
||||
</label>
|
||||
<label
|
||||
v-if="beat.performedActionIds"
|
||||
class="motion-revision-field motion-revision-field-wide workspace-form-field"
|
||||
><span>实际执行动作ID(原始绑定)</span
|
||||
><NInput
|
||||
:value="beat.performedActionIds.join(', ')"
|
||||
:disabled="formBlocked"
|
||||
@update:value="
|
||||
beat.performedActionIds = $event
|
||||
.split(/[,,\n]/)
|
||||
.map(value => value.trim())
|
||||
.filter(Boolean)
|
||||
"
|
||||
:aria-label="`阶段 ${index + 1} 执行动作ID`"
|
||||
/></label>
|
||||
</div>
|
||||
</section>
|
||||
<div class="motion-revision-section-action">
|
||||
<NButton :disabled="blocked || draft.beats.length >= 5" @click="addBeat">添加动作阶段</NButton>
|
||||
<span class="motion-revision-description">{{ draft.beats.length }} / 5 个阶段</span>
|
||||
</div>
|
||||
<!-- 以下是完整物理交互的高级原文编辑,不新增第二套时间轴。 -->
|
||||
<NCollapse
|
||||
><NCollapseItem name="interactions" title="物理交互(完整原文)"
|
||||
><div class="workspace-section-stack">
|
||||
<NInput
|
||||
:value="interactionsText"
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 4, maxRows: 15 }"
|
||||
:disabled="formBlocked"
|
||||
aria-label="完整物理交互JSON"
|
||||
@update:value="updateInteractions"
|
||||
/>
|
||||
<p v-if="state.interactionError.value" role="alert">{{ state.interactionError.value }}</p>
|
||||
</div></NCollapseItem
|
||||
></NCollapse
|
||||
>
|
||||
<!-- 以下是整体约束与修改原因模块,标签和删除按钮分别对齐 -->
|
||||
<section class="workspace-panel motion-revision-section" aria-label="整体动作约束">
|
||||
<div class="motion-revision-section-heading">
|
||||
@@ -301,19 +448,41 @@ function updateRefs(index: number, value: string) {
|
||||
<!-- 以下是免费预检查结果模块,与收费校验证据分开 -->
|
||||
<section v-if="preview" class="motion-revision-feedback" aria-label="免费预检查结果">
|
||||
<h3>预检查结果</h3>
|
||||
<p>{{ preview.valid ? '结构检查通过,仍须视觉校验;尚不可激活。' : '结构检查未通过,请修改草稿。' }}</p>
|
||||
<p>
|
||||
{{
|
||||
preview.valid
|
||||
? '正式文字预检通过,起点像素仍待独立审核;尚未采用。'
|
||||
: '预检未通过,请修改草稿。'
|
||||
}}
|
||||
</p>
|
||||
<p v-for="(message, index) in previewMessages" :key="index">{{ userFacingText(message) }}</p>
|
||||
<p v-if="preview.startStatePlan">
|
||||
本精确起点计划最多 {{ preview.startStatePlan.proposedMaximumProviderRequests }} 次 · 拟新增
|
||||
{{ preview.startStatePlan.additionalProviderRequests }} 次 · 费用
|
||||
{{ preview.startStatePlan.feeEstimate.amount ?? '未知' }}
|
||||
{{ preview.startStatePlan.feeEstimate.currency }}
|
||||
</p>
|
||||
<RawDataDetails
|
||||
v-if="preview.source"
|
||||
:value="{
|
||||
source: preview.source,
|
||||
sourceFingerprint: preview.sourceFingerprint,
|
||||
previewFingerprint: preview.previewFingerprint,
|
||||
startStatePlan: preview.startStatePlan
|
||||
}"
|
||||
title="当前来源、版本与精确起点计划"
|
||||
/>
|
||||
</section>
|
||||
<!-- 以下是收费视觉校验与激活模块,费用说明和操作成组排列 -->
|
||||
<section class="workspace-panel motion-revision-section" aria-label="动作起点视觉校验">
|
||||
<h3>起点视觉校验</h3>
|
||||
<p class="motion-revision-description">检查修订与当前主首帧是否一致,会消耗模型额度。</p>
|
||||
<NCheckbox v-model:checked="acknowledged" :disabled="blocked || !saved"
|
||||
<NCheckbox v-model:checked="acknowledged" :disabled="!state.canValidate.value"
|
||||
>我已确认本次起点视觉校验的模型费用和修订范围。</NCheckbox
|
||||
>
|
||||
<div class="motion-revision-validation-actions">
|
||||
<NButton
|
||||
:disabled="blocked || !saved || !acknowledged || !state.context.data.value?.primary"
|
||||
:disabled="!state.canValidate.value || !acknowledged || !state.context.data.value?.primary"
|
||||
@click="state.validate"
|
||||
>启动起点视觉校验</NButton
|
||||
>
|
||||
@@ -345,7 +514,7 @@ function updateRefs(index: number, value: string) {
|
||||
<div class="motion-revision-footer">
|
||||
<div class="motion-revision-save-actions">
|
||||
<NButton :disabled="blocked" :loading="pending" @click="state.precheck">免费预检查</NButton>
|
||||
<NButton :disabled="blocked || preview?.valid !== true" @click="state.save">保存为新修订</NButton>
|
||||
<NButton :disabled="!state.canSave.value" @click="state.save">保存为新修订</NButton>
|
||||
</div>
|
||||
<NButton @click="open = false">关闭</NButton>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import RawDataDetails from '../../../components/ui/RawDataDetails.vue'
|
||||
import type { ShotContinuityEvidence } from '../generation-spec.types'
|
||||
/** Storyboard及首帧共用正式人工规划依据,不复制或改写尾态与质量。 */
|
||||
const props = defineProps<{ /** 当前正式编译的连续性证据。 */ continuity?: ShotContinuityEvidence | null }>()
|
||||
/** 仅完整、匹配紧邻镜头的正式规划记录可显示确认;其余状态仍由服务端门禁决定。 */
|
||||
const transition = computed(() => {
|
||||
const value = props.continuity?.sceneTransition
|
||||
return value?.basis === 'confirmed_plan' &&
|
||||
value.verifiedVideoEndState === false &&
|
||||
value.previousShotId === props.continuity?.previousShotId &&
|
||||
value.subjectRef &&
|
||||
value.subjectFormId &&
|
||||
/^[a-f0-9]{64}$/.test(value.fingerprint) &&
|
||||
/^[a-f0-9]{64}$/.test(value.requestFingerprint)
|
||||
? value
|
||||
: null
|
||||
})
|
||||
</script>
|
||||
<template>
|
||||
<!-- 以下是人工规划确认与尚未验证的视频末态,使用中性展示。 -->
|
||||
<section v-if="transition" class="space-y-2 text-xs" aria-label="人工规划衔接">
|
||||
<p>人工规划衔接已确认,视频末态尚未验证</p>
|
||||
<RawDataDetails :value="transition" title="衔接规划来源详情" />
|
||||
</section>
|
||||
</template>
|
||||
@@ -1,6 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
import VisualStateContinuity from './VisualStateContinuity.vue'
|
||||
import JointDraftReviewPanel from './JointDraftReviewPanel.vue'
|
||||
import ShotDesign from './ShotDesign.vue'
|
||||
import SceneTransitionEvidence from './SceneTransitionEvidence.vue'
|
||||
import KeyframeCard from '../../production/components/KeyframeCard.vue'
|
||||
import KeyframeValidationHistory from '../../production/components/KeyframeValidationHistory.vue'
|
||||
import { jointDraftDifferences } from '../joint-review'
|
||||
import DirectionCameraFields from './DirectionCameraFields.vue'
|
||||
import DirectionStageReview from './DirectionStageReview.vue'
|
||||
import { computed, onScopeDispose, ref, watch } from 'vue'
|
||||
@@ -13,6 +18,8 @@ import { ApiError, errorMessage } from '../../../lib/http'
|
||||
import { formatDate } from '../../../lib/format'
|
||||
import { userFacingText } from '../../../lib/user-facing-text'
|
||||
import { productionApi } from '../../production/api'
|
||||
import { imageAuthorizationApi } from '../../image-authorization/api'
|
||||
import type { KeyframeGenerationPreview } from '../../production/types'
|
||||
import KeyframePreviewChecks from '../../production/components/KeyframePreviewChecks.vue'
|
||||
import ImageGenerationPreview from '../../subject-images/components/ImageGenerationPreview.vue'
|
||||
import { preparationApi } from '../../storyboard-preparation/api'
|
||||
@@ -118,6 +125,34 @@ const savingDraft = ref(false)
|
||||
const providerEdited = ref(false)
|
||||
/** 编辑保存的原稿时,保留其模型参数和显式尺寸。 */
|
||||
const editingSavedInput = ref<DraftProviderInput | null>()
|
||||
/** 只在首次读取回填,来源刷新不得覆盖人工构图。 */
|
||||
const cameraInitialized = ref(false)
|
||||
/** 同一摄影抽屉内按需展开正式内容、历史与图片。 */
|
||||
const cameraExpanded = ref<string[]>([])
|
||||
/** 图片历史只读定位,不启动审核或晋升。 */
|
||||
const cameraHistoryAssetId = ref('')
|
||||
/** 正式Source变化后重新读取每张原图的当前质量,原机器记录不改写。 */
|
||||
const cameraReviewRevision = ref(0)
|
||||
/** 摄影正式采用后的新来源预览,不能沿用旧草案指纹生图。 */
|
||||
const cameraFormalPreview = ref<KeyframeGenerationPreview | null>(null)
|
||||
/** 费用计划仅显示当前身份/来源,不等同授权或核清。 */
|
||||
const cameraFeePlan = ref<Record<string, unknown> | null>(null)
|
||||
/** 免费后续核对失败不改写已经成功的摄影采用事实。 */
|
||||
const cameraAdoptionNotice = ref('')
|
||||
/** 用户主动展开时才查询已有候选,不把未执行计划构造成图片。 */
|
||||
const cameraAssetKey = computed(() =>
|
||||
key.value && props.shot.direction && props.shot.visualState && cameraExpanded.value.includes('camera-assets')
|
||||
? key.value
|
||||
: ''
|
||||
)
|
||||
/** 候选列表只来自正式资产GET,保留失败/未知/Primary全部历史。 */
|
||||
const cameraAssets = useQuery(cameraAssetKey, async (value, signal) => {
|
||||
if (!value) return []
|
||||
const [, shotId] = JSON.parse(value) as [string, string]
|
||||
const rows = await productionApi.listKeyframes(shotId, signal)
|
||||
if (!Array.isArray(rows) || rows.some(row => row.shotId !== shotId)) throw new Error('图片候选不属于当前镜头。')
|
||||
return rows
|
||||
})
|
||||
/** 当前可查看的原稿,保留过期草案的全部内容。 */
|
||||
const savedDraftText = computed(() =>
|
||||
savedDraft.data.value ? JSON.stringify(savedDraft.data.value.draft, null, 2) : ''
|
||||
@@ -146,6 +181,16 @@ const formalQuery = useQuery(key, async (value, signal) => {
|
||||
throw new Error('无法核对当前镜头的正式摄影和即时状态。')
|
||||
return { keyframe, generation, shot: { ...props.shot, direction, visualState } }
|
||||
})
|
||||
watch(
|
||||
[() => formalQuery.data.value?.keyframe.formalSourceFingerprint, formalQuery.error],
|
||||
([value, error], [previous]) => {
|
||||
if (error || (value && previous && value !== previous)) {
|
||||
cameraFormalPreview.value = null
|
||||
cameraFeePlan.value = null
|
||||
cameraReviewRevision.value++
|
||||
}
|
||||
}
|
||||
)
|
||||
/** 只允许目录中当前启用的模型。 */
|
||||
const configuration = useQuery(key, async (id, signal) => {
|
||||
if (!id) return null
|
||||
@@ -157,6 +202,34 @@ const configuration = useQuery(key, async (id, signal) => {
|
||||
})
|
||||
/** 正式场景衔接证据;不会用前镜首帧冒充尾态。 */
|
||||
const continuity = computed(() => formalQuery.data.value?.generation.continuity)
|
||||
/** 原摄影修订事件仅只读展示,不能回写历史。 */
|
||||
const cameraHistory = computed<unknown[]>(() => {
|
||||
try {
|
||||
const raw = JSON.parse(formalQuery.data.value?.shot.direction?.rawJson ?? 'null')
|
||||
return Array.isArray(raw?.cameraRevisionHistory) ? raw.cameraRevisionHistory : []
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
})
|
||||
/** 普通摄影完整差异,保存草案中的越界项也不能隐藏。 */
|
||||
const cameraDifferences = computed(() => {
|
||||
const value = formalQuery.data.value,
|
||||
fingerprint = preflight.data.value?.current.evidence.shotFingerprint
|
||||
if (!value || !fingerprint || mode.value !== 'camera') return []
|
||||
const before = draftFromFormal(value.shot, value.keyframe, fingerprint)
|
||||
const after =
|
||||
useSaved.value && savedDraft.data.value
|
||||
? savedDraft.data.value.draft
|
||||
: {
|
||||
...before,
|
||||
direction: {
|
||||
...before.direction,
|
||||
composition: composition.value,
|
||||
cameraPosition: cameraPosition.value
|
||||
}
|
||||
}
|
||||
return jointDraftDifferences(before, after)
|
||||
})
|
||||
/** 使用现有镜头目录将前镜编号转换为用户可见坐标。 */
|
||||
const previousShot = computed(() => props.shots.find(item => item.shotId === continuity.value?.previousShotId))
|
||||
/** 只列出服务提供同形态、可填写的正式前镜场景状态。 */
|
||||
@@ -224,6 +297,14 @@ watch(
|
||||
{ flush: 'sync' }
|
||||
)
|
||||
watch(key, () => {
|
||||
cameraInitialized.value = false
|
||||
cameraExpanded.value = []
|
||||
cameraHistoryAssetId.value = ''
|
||||
cameraFormalPreview.value = null
|
||||
cameraFeePlan.value = null
|
||||
cameraAdoptionNotice.value = ''
|
||||
composition.value = ''
|
||||
cameraPosition.value = ''
|
||||
useSaved.value = false
|
||||
draftConflict.value = false
|
||||
providerEdited.value = false
|
||||
@@ -321,8 +402,10 @@ watch(
|
||||
{ flush: 'sync' }
|
||||
)
|
||||
watch(formalQuery.data, value => {
|
||||
composition.value = value?.shot.direction?.composition ?? ''
|
||||
cameraPosition.value = value?.shot.direction?.cameraPosition ?? ''
|
||||
if (!value || cameraInitialized.value) return
|
||||
composition.value = value.shot.direction?.composition ?? ''
|
||||
cameraPosition.value = value.shot.direction?.cameraPosition ?? ''
|
||||
cameraInitialized.value = true
|
||||
})
|
||||
watch(configuration.data, value => {
|
||||
const model = value?.catalog.images.find(item => item.enabled && item.provider === value.profile.imageProvider)
|
||||
@@ -335,6 +418,8 @@ const canPreview = computed(
|
||||
() =>
|
||||
!!preflight.data.value?.current.evidence.shotFingerprint &&
|
||||
!preflight.error.value &&
|
||||
!preflight.loading.value &&
|
||||
!formalQuery.loading.value &&
|
||||
(useSaved.value
|
||||
? savedDraft.data.value?.status === 'current' && !savedDraft.error.value
|
||||
: (!!provider.value || (!providerEdited.value && editingSavedInput.value !== undefined)) &&
|
||||
@@ -511,7 +596,13 @@ async function loadPreview() {
|
||||
}
|
||||
}
|
||||
} catch (cause) {
|
||||
if (!controller.signal.aborted) message?.error(errorMessage(cause))
|
||||
if (!controller.signal.aborted) {
|
||||
message?.error(errorMessage(cause))
|
||||
if (cause instanceof ApiError && cause.status === 409) {
|
||||
void formalQuery.refresh()
|
||||
void preflight.refresh()
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (!controller.signal.aborted) previewing.value = false
|
||||
}
|
||||
@@ -541,8 +632,56 @@ async function adopt() {
|
||||
if (projectId !== props.projectId || selection.shotId !== props.shot.shotId) return
|
||||
if (ok) {
|
||||
message?.success('已采用当前镜头的审核结果')
|
||||
open.value = false
|
||||
emit('changed')
|
||||
if (mode.value === 'camera' && formal.value) {
|
||||
cameraAdoptionNotice.value = '摄影修订已正式采用;旧图及原审核保留,新来源仍需独立图片授权和质量审核。'
|
||||
clearPreview()
|
||||
await Promise.all([formalQuery.refresh(), savedDraft.refresh(), preflight.refresh()])
|
||||
try {
|
||||
const fresh = await productionApi.previewKeyframe(
|
||||
selection.shotId,
|
||||
{
|
||||
provider: selection.provider,
|
||||
generationOptions: selection.generationOptions,
|
||||
width: selection.width,
|
||||
height: selection.height
|
||||
},
|
||||
undefined,
|
||||
projectId
|
||||
)
|
||||
if (projectId !== props.projectId || selection.shotId !== props.shot.shotId || !open.value) return
|
||||
if (fresh.shotId !== selection.shotId) throw new Error('正式预览与当前镜头不匹配。')
|
||||
cameraFormalPreview.value = fresh
|
||||
if (fresh.provider === 'openai-image') {
|
||||
const plan = await imageAuthorizationApi.preview(projectId, {
|
||||
scope: 'keyframe',
|
||||
targetId: selection.shotId,
|
||||
providerName: fresh.provider,
|
||||
generationOptions: selection.generationOptions,
|
||||
width: selection.width,
|
||||
height: selection.height
|
||||
})
|
||||
if (projectId !== props.projectId || selection.shotId !== props.shot.shotId || !open.value)
|
||||
return
|
||||
if (
|
||||
plan.context.projectId !== projectId ||
|
||||
plan.context.targetId !== selection.shotId ||
|
||||
plan.model !== fresh.model
|
||||
)
|
||||
throw new Error('当前费用计划与正式预览不匹配。')
|
||||
cameraFeePlan.value = {
|
||||
provider: plan.provider,
|
||||
model: plan.model,
|
||||
context: plan.context,
|
||||
planFingerprint: plan.planFingerprint,
|
||||
billingBlocked: plan.authorization.billingBlocked
|
||||
}
|
||||
}
|
||||
} catch (cause) {
|
||||
message?.warning('摄影已采用,正式预览仍需核对:' + errorMessage(cause))
|
||||
}
|
||||
if (cameraAssetKey.value) await cameraAssets.refresh()
|
||||
} else open.value = false
|
||||
} else {
|
||||
const operation = getOperation(projectId)
|
||||
if (operation.cause instanceof ApiError && operation.cause.status === 409) {
|
||||
@@ -618,6 +757,93 @@ async function adopt() {
|
||||
</section>
|
||||
<p v-else-if="preflight.loading.value" role="status" class="text-sm text-muted">正在读取正式审核状态…</p>
|
||||
<NButton v-if="preflight.error.value" @click="preflight.refresh">重新读取审核状态</NButton>
|
||||
<!-- 以下是原摄影、完整差异及历史,只读按需展开,不创建第二套摄影编辑器。 -->
|
||||
<template v-if="formal">
|
||||
<NButton
|
||||
class="self-start"
|
||||
:disabled="saving || savingDraft"
|
||||
:loading="formalQuery.loading.value"
|
||||
@click="formalQuery.refresh"
|
||||
>刷新正式摄影与来源</NButton
|
||||
>
|
||||
<p v-if="formalQuery.error.value" role="alert" class="text-sm">{{ formalQuery.error.value }}</p>
|
||||
<NCollapse v-model:expanded-names="cameraExpanded">
|
||||
<NCollapseItem name="camera-formal" title="当前正式摄影与状态"
|
||||
><ShotDesign
|
||||
v-if="formalQuery.data.value && !formalQuery.error.value"
|
||||
:shot="formalQuery.data.value.shot"
|
||||
/></NCollapseItem>
|
||||
<NCollapseItem name="camera-history" title="摄影修订历史"
|
||||
><p v-if="!cameraHistory.length" class="text-sm text-muted">暂无摄影修订记录。</p>
|
||||
<RawDataDetails
|
||||
v-for="(event, index) in cameraHistory"
|
||||
:key="index"
|
||||
:value="event"
|
||||
:title="`第 ${index + 1} 次摄影修订`"
|
||||
/></NCollapseItem>
|
||||
<NCollapseItem name="camera-assets" title="已有图片与质量(只读)">
|
||||
<p v-if="cameraAssets.loading.value" role="status">正在读取原图片与审核…</p>
|
||||
<p v-if="cameraAssets.error.value" role="alert">{{ cameraAssets.error.value }}</p>
|
||||
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-3">
|
||||
<KeyframeCard
|
||||
v-for="item in cameraAssets.data.value ?? []"
|
||||
:key="item.id"
|
||||
:item="item"
|
||||
:project-id="projectId"
|
||||
:shot-id="shot.shotId"
|
||||
:shot-no="shot.shotNo"
|
||||
:stale="false"
|
||||
:blocked="true"
|
||||
:validation-passed="null"
|
||||
:review-revision="cameraReviewRevision"
|
||||
:confirming="false"
|
||||
readonly
|
||||
@history="cameraHistoryAssetId = item.id"
|
||||
/>
|
||||
</div>
|
||||
<KeyframeValidationHistory
|
||||
v-if="cameraHistoryAssetId"
|
||||
:key="cameraHistoryAssetId + ':' + cameraReviewRevision"
|
||||
:project-id="projectId"
|
||||
:shot-id="shot.shotId"
|
||||
:keyframe-id="cameraHistoryAssetId"
|
||||
initial-open
|
||||
:disabled="true"
|
||||
/>
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
<SceneTransitionEvidence
|
||||
v-if="!formalQuery.error.value && !formalQuery.loading.value"
|
||||
:continuity="continuity"
|
||||
/>
|
||||
<section
|
||||
v-if="mode === 'camera' && cameraDifferences.length"
|
||||
class="workspace-section-stack"
|
||||
aria-label="摄影完整差异"
|
||||
>
|
||||
<WorkspaceSectionHeading :title="`完整字段差异(${cameraDifferences.length}项)`" />
|
||||
<article v-for="(item, index) in cameraDifferences" :key="index" class="space-y-2 text-sm">
|
||||
<h4>{{ item.label }}</h4>
|
||||
<p class="whitespace-pre-wrap wrap-anywhere">修改前:{{ item.before || '(空)' }}</p>
|
||||
<p class="whitespace-pre-wrap wrap-anywhere">修改后:{{ item.after || '(空)' }}</p>
|
||||
</article>
|
||||
</section>
|
||||
<p v-if="cameraAdoptionNotice" role="status" class="text-sm">{{ cameraAdoptionNotice }}</p>
|
||||
<ImageGenerationPreview
|
||||
v-if="cameraFormalPreview"
|
||||
:preview="cameraFormalPreview"
|
||||
:loading="false"
|
||||
error=""
|
||||
stale-notice=""
|
||||
display-only
|
||||
/>
|
||||
<KeyframePreviewChecks v-if="cameraFormalPreview" :preview="cameraFormalPreview" />
|
||||
<RawDataDetails
|
||||
v-if="cameraFeePlan"
|
||||
:value="cameraFeePlan"
|
||||
title="新来源费用计划(不代表授权或核清)"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<!-- 以下是服务端待审草案、版本和保留的原稿 -->
|
||||
<section class="space-y-3 text-sm">
|
||||
@@ -813,6 +1039,14 @@ async function adopt() {
|
||||
|
||||
<!-- 以下是已冻结的草案、场景几何依据及实际模型输入 -->
|
||||
<section v-if="reviewed && previewDisplay" class="space-y-4 text-sm">
|
||||
<RawDataDetails
|
||||
:value="{
|
||||
formalSourceFingerprint: reviewed.selection.expectedCurrentFormalSourceFingerprint,
|
||||
currentDerivedFingerprint: reviewed.preview.currentDerivedFingerprint,
|
||||
adjacentDerivedVersions: reviewed.preview.adjacentDerivedVersions
|
||||
}"
|
||||
title="当前与相邻镜头版本"
|
||||
/>
|
||||
<WorkspaceSectionHeading title="草案预览" description="采用后可预览正式首帧。" />
|
||||
<NTag size="small" :bordered="false">{{
|
||||
reviewed.preview.productionGate.ready ? '项目制作已就绪' : '项目制作未就绪'
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import RawDataDetails from '../../../components/ui/RawDataDetails.vue'
|
||||
import SceneTransitionEvidence from './SceneTransitionEvidence.vue'
|
||||
import { userFacingText } from '../../../lib/user-facing-text'
|
||||
import FeedbackMessage from '../../../components/ui/FeedbackMessage.vue'
|
||||
|
||||
@@ -73,6 +74,7 @@ async function load(kind: 'references' | 'spec') {
|
||||
controllers[kind] = controller
|
||||
busy.value[kind] = true
|
||||
errors.value[kind] = ''
|
||||
if (kind === 'spec') spec.value = null
|
||||
try {
|
||||
if (kind === 'references') {
|
||||
const result = await storyboardApi.references(shotId, controller.signal)
|
||||
@@ -211,6 +213,7 @@ function exportResult(kind: 'spec' | 'prompt') {
|
||||
><NButton @click="exportResult('spec')" text size="small"><Download :size="13" />导出方案</NButton>
|
||||
</div>
|
||||
<RawDataDetails :value="spec" title="完整生成方案(高级)" />
|
||||
<SceneTransitionEvidence :continuity="spec.continuity" />
|
||||
</template>
|
||||
</section>
|
||||
<section>
|
||||
|
||||
@@ -68,6 +68,16 @@ export interface ShotGenerationSpec {
|
||||
|
||||
/** 编译时读取的相邻镜头证据,首态与尾态分别记录。 */
|
||||
export interface ShotContinuityEvidence {
|
||||
/** 正式采用的有界人工规划,只解释场景文本差异,不证明真实视频末态。 */
|
||||
sceneTransition?: {
|
||||
/** 同集紧邻前镜。 */ previousShotId: string
|
||||
/** 唯一共享场景。 */ subjectRef: string
|
||||
/** 正式场景形态。 */ subjectFormId: string
|
||||
/** 依据来自人工规划。 */ basis: 'confirmed_plan'
|
||||
/** 当前来源与邻镜版本。 */ fingerprint: string
|
||||
/** 原联合采用批次。 */ requestFingerprint: string
|
||||
/** 尚未验证真实视频末态。 */ verifiedVideoEndState: false
|
||||
}
|
||||
/** 同集紧邻前镜。 */ previousShotId: string
|
||||
/** 是否共用场景。 */ sameScene: boolean
|
||||
/** 单独确认的前镜尾态。 */
|
||||
|
||||
@@ -1,10 +1,35 @@
|
||||
import type { MotionPlan, MotionRevision, MotionRevisionHistory, MotionRevisionPreview } from './motion-revision'
|
||||
import type {
|
||||
MotionPlan,
|
||||
MotionRevision,
|
||||
MotionRevisionHistory,
|
||||
MotionRevisionPreview,
|
||||
FailedMotionCandidate
|
||||
} from './motion-revision'
|
||||
import type { WorkflowExecutionStart } from '../workflows/execution.types'
|
||||
import { request } from '../../lib/http'
|
||||
import type { MotionPlanAudit, MotionPlanPreview } from './motion.types'
|
||||
|
||||
/** 动作查询与修订入口;只有明确启动视觉校验会调用模型。 */
|
||||
export const motionApi = {
|
||||
/**
|
||||
* 免费发现本镜原受控任务,不登记批准或恢复执行。
|
||||
* @param shotId 原镜头
|
||||
* @returns 当前计划内最近任务身份
|
||||
*/
|
||||
candidatePlan: (shotId: string) =>
|
||||
request<{ shotId: string; projectId: string; latestTask: { taskId: string; executionId: string } | null }>(
|
||||
`/storyboard-shots/${encodeURIComponent(shotId)}/video-prompt/preview`
|
||||
),
|
||||
/**
|
||||
* 只读原失败任务、质量、解析候选和公开回执,不重试原模型。
|
||||
* @param shotId 原镜头
|
||||
* @param taskId 原Task
|
||||
* @returns 原公开执行证据
|
||||
*/
|
||||
candidate: (shotId: string, taskId: string) =>
|
||||
request<FailedMotionCandidate>(
|
||||
`/storyboard-shots/${encodeURIComponent(shotId)}/video-prompt/executions/${encodeURIComponent(taskId)}`
|
||||
),
|
||||
/**
|
||||
* 查询真实修订历史。
|
||||
* @param shotId 镜头 ID
|
||||
@@ -19,12 +44,16 @@ export const motionApi = {
|
||||
* 免费检查完整草稿,不激活版本。
|
||||
* @param shotId 镜头 ID
|
||||
* @param motionPlan 完整规划
|
||||
* @param expectedSourceFingerprint 用户已经核对的来源
|
||||
* @returns 结构检查与预警
|
||||
*/
|
||||
previewRevision: (shotId: string, motionPlan: MotionPlan) =>
|
||||
previewRevision: (shotId: string, motionPlan: MotionPlan, expectedSourceFingerprint?: string) =>
|
||||
request<MotionRevisionPreview>(
|
||||
`/storyboard-shots/${encodeURIComponent(shotId)}/motion-plan/revisions/preview`,
|
||||
{ method: 'POST', body: { motionPlan } }
|
||||
{
|
||||
method: 'POST',
|
||||
body: { motionPlan, ...(expectedSourceFingerprint ? { expectedSourceFingerprint } : {}) }
|
||||
}
|
||||
),
|
||||
/**
|
||||
* 保存不可变修订,不调用模型。
|
||||
@@ -34,7 +63,17 @@ export const motionApi = {
|
||||
*/
|
||||
saveRevision: (
|
||||
shotId: string,
|
||||
input: { motionPlan: MotionPlan; parentRevisionId: string | null; reason: string | null }
|
||||
input: {
|
||||
motionPlan: MotionPlan
|
||||
parentRevisionId: string | null
|
||||
reason: string | null
|
||||
/** 首次明确承接原失败候选。 */ failedCandidate?: {
|
||||
/** 原Task。 */ taskId: string
|
||||
/** 当前源。 */ expectedSourceFingerprint: string
|
||||
/** 本次预检。 */ expectedPreviewFingerprint: string
|
||||
/** 人工确认原失败。 */ acknowledgeFailedCandidate: true
|
||||
}
|
||||
}
|
||||
) =>
|
||||
request<MotionRevision>(`/storyboard-shots/${encodeURIComponent(shotId)}/motion-plan/revisions`, {
|
||||
method: 'POST',
|
||||
@@ -50,9 +89,15 @@ export const motionApi = {
|
||||
validateRevision: (
|
||||
shotId: string,
|
||||
revisionId: string,
|
||||
input: { primaryKeyframeId: string; expectedRevisionId: string | null }
|
||||
input: {
|
||||
primaryKeyframeId: string
|
||||
expectedRevisionId: string | null
|
||||
/** 原精确起点计划。 */ expectedPlanFingerprint: string
|
||||
}
|
||||
) =>
|
||||
request<WorkflowExecutionStart & { willCallModel: true }>(
|
||||
request<
|
||||
WorkflowExecutionStart & { willCallModel: boolean; /** 服务端复用原任务,不再次收费。 */ reused?: boolean }
|
||||
>(
|
||||
`/storyboard-shots/${encodeURIComponent(shotId)}/motion-plan/revisions/${encodeURIComponent(revisionId)}/start-state-validation/start`,
|
||||
{ method: 'POST', body: input }
|
||||
),
|
||||
|
||||
@@ -4,6 +4,8 @@ import type { WorkflowExecution } from '../workflows/execution.types'
|
||||
|
||||
/** 可编辑的完整动作规划,与后端 schema 一致。 */
|
||||
export interface MotionPlan {
|
||||
/** 完整物理交互按正式Schema保留;高级编辑由服务端免费预检裁决。 */
|
||||
interactions?: Array<Record<string, unknown>>
|
||||
/** 一至五个动作阶段。 */
|
||||
beats: MotionBeat[]
|
||||
/** 一至八条整体运动约束。 */
|
||||
@@ -16,7 +18,17 @@ export interface MotionRevision {
|
||||
/** 所属镜头。 */
|
||||
shotId: string
|
||||
/** 修订来源。 */
|
||||
source: 'ai_original' | 'manual'
|
||||
source: 'ai_original' | 'manual' | 'failed_candidate'
|
||||
/** 失败根的来源证明;人工子版本为null,不能把根reason JSON当人工说明。 */
|
||||
candidateOrigin?: {
|
||||
/** 原任务。 */ taskId: string
|
||||
/** 原Workflow。 */ workflowExecutionId: string
|
||||
/** 原批准。 */ authorizationId: string
|
||||
/** 原来源。 */ sourceFingerprint: string
|
||||
/** 原证据。 */ evidenceFingerprint: string
|
||||
/** 原回执。 */ receiptFingerprint: string
|
||||
/** 原质量仍失败。 */ originalBusinessStatus: 'failed'
|
||||
} | null
|
||||
/** 实际父版本。 */
|
||||
parentRevisionId: string | null
|
||||
/** 修改原因。 */
|
||||
@@ -45,6 +57,18 @@ export interface MotionRevisionHistory {
|
||||
}
|
||||
/** 免费预检查不授予激活权限。 */
|
||||
export interface MotionRevisionPreview {
|
||||
/** 当前正式确定性问题,不能只检查结构。 */ formalIssues?: string[]
|
||||
/** 当前正式来源。 */ sourceFingerprint?: string
|
||||
/** 本次完整草案及模型输入版本。 */ previewFingerprint?: string
|
||||
/** 免费文字检查不证明起点像素。 */ startStateStatus?: 'required_unknown'
|
||||
/** 当前源及像素/事实只读证据。 */ source?: {
|
||||
/** 原项目。 */ projectId: string
|
||||
/** 当前生效版本。 */ activeRevisionId: string | null
|
||||
/** 当前主首帧。 */ primaryKeyframeId: string
|
||||
/** 原完整事实。 */ facts: unknown
|
||||
/** 其它正式源证据。 */ [key: string]: unknown
|
||||
}
|
||||
/** 免费精确起点计划;缺失时禁止启动起点Vision或采用。 */ startStatePlan?: MotionStartStatePlan | null
|
||||
/** 镜头 ID。 */
|
||||
shotId: string
|
||||
/** 仅结构合法。 */
|
||||
@@ -66,6 +90,44 @@ export interface MotionRevisionPreview {
|
||||
/** 不修改资产。 */
|
||||
willModifyAssets: false
|
||||
}
|
||||
|
||||
/** 原起点免费计划,模型请求身份与费用确认绑定。 */
|
||||
export interface MotionStartStatePlan {
|
||||
/** 正式计划版本。 */ version: 1
|
||||
/** 当前主首帧。 */ primaryKeyframeId: string
|
||||
/** 当前预期采用指针,可为空。 */ expectedRevisionId: string | null
|
||||
/** 已保存动作版本的内容。 */ motionPlanFingerprint: string
|
||||
/** 精确计划SHA,启动不得用顶层Preview替代。 */ fingerprint: string
|
||||
/** 当前正式来源。 */ sourceFingerprint: string
|
||||
/** 计划状态。 */ status: 'ready' | 'reusable' | 'blocked'
|
||||
/** 本次可执行性。 */ executionAvailable: boolean
|
||||
/** 最大拟调用数。 */ proposedMaximumProviderRequests: number
|
||||
/** 当前新增调用数。 */ additionalProviderRequests: number
|
||||
/** 当前费用未知,不推断为0。 */ feeEstimate: {
|
||||
/** 币种。 */ currency: string
|
||||
/** 尚无实际用量。 */ amount: number | null
|
||||
/** 原因。 */ reason: string
|
||||
}
|
||||
/** 实际脱敏模型请求及其它原始证据。 */ [key: string]: unknown
|
||||
}
|
||||
/** 原受控Prompt执行的公开只读回执,不含未公开的原SDK文本。 */
|
||||
export interface FailedMotionCandidate {
|
||||
/** 原Task。 */ taskId: string
|
||||
/** 原Workflow。 */ executionId: string
|
||||
/** 原镜头。 */ shotId: string
|
||||
/** 当前源是否匹配。 */ current: boolean
|
||||
/** 原业务质量状态。 */ status: string
|
||||
/** 原批准计划。 */ plan: { /** 原项目。 */ projectId: string; /** 原其它完整计划。 */ [key: string]: unknown }
|
||||
/** 原失败质量。 */ qualityFailure: {
|
||||
/** 原阶段。 */ phase?: string
|
||||
/** 原问题。 */ [key: string]: unknown
|
||||
} | null
|
||||
/** 原已解析模型观察,保留失败不盖通过。 */ observations: {
|
||||
/** 完整原失败候选。 */ motion_plan?: MotionPlan
|
||||
/** 其它公开观察。 */ [key: string]: unknown
|
||||
}
|
||||
/** 原请求脱敏快照、用量和公开回执元数据。 */ [key: string]: unknown
|
||||
}
|
||||
/** 起点视觉校验的实际问题结构。 */
|
||||
export interface MotionValidationIssue {
|
||||
/** 起点冲突种类。 */
|
||||
@@ -131,6 +193,7 @@ export function motionEvidenceCurrent(
|
||||
execution?.status === 'completed' &&
|
||||
execution.workflowName === 'motion-plan-start-state-validation' &&
|
||||
revision &&
|
||||
revision.source !== 'failed_candidate' &&
|
||||
primary?.imageUrl &&
|
||||
primary.status === 'completed' &&
|
||||
primary.isPrimary &&
|
||||
|
||||
@@ -8,6 +8,7 @@ export interface MotionIssue {
|
||||
|
||||
/** 已保存动作阶段;时间和动作均来自后端,不在前端补造。 */
|
||||
export interface MotionBeat {
|
||||
/** 真实已执行动作ID,原样保留,不根据文本猜测。 */ performedActionIds?: string[]
|
||||
startSecond: number
|
||||
endSecond: number
|
||||
action: string
|
||||
|
||||
@@ -5,7 +5,12 @@ import { productionApi } from '../production/api'
|
||||
import { useWorkflowExecution } from '../workflows/execution'
|
||||
import { getOperation, runOperation } from '../workflows/operations'
|
||||
import { ApiError, errorMessage } from '../../lib/http'
|
||||
import { motionEvidenceCurrent, type MotionPlan, type MotionRevisionPreview } from './motion-revision'
|
||||
import {
|
||||
motionEvidenceCurrent,
|
||||
type MotionPlan,
|
||||
type MotionRevisionPreview,
|
||||
type FailedMotionCandidate
|
||||
} from './motion-revision'
|
||||
|
||||
/**
|
||||
* 管理一个镜头的完整草稿、免费预检、保存和付费视觉任务;切镜后丢弃迟到 UI 更新。
|
||||
@@ -60,6 +65,16 @@ export function useMotionRevision(
|
||||
const draft = ref<MotionPlan>({ beats: [], globalMotionConstraints: [] })
|
||||
/** 人工修改原因。 */
|
||||
const reason = ref('')
|
||||
/** 原失败Task可由正式免费计划发现,也可粘贴真实ID只读核对。 */
|
||||
const failedTaskId = ref('')
|
||||
/** 原模型候选、质量和Workflow公开回执,始终与人工草稿分开。 */
|
||||
const failedCandidate = ref<FailedMotionCandidate | null>(null)
|
||||
/** 用户确认承接原失败,而不是将其改为通过。 */
|
||||
const failedAcknowledged = ref(false)
|
||||
/** 只读候选查询就地加载,不启动原Workflow。 */
|
||||
const candidateLoading = ref(false)
|
||||
/** 完整交互JSON的输入错误保留在编辑器中。 */
|
||||
const interactionError = ref('')
|
||||
/** 只保留当前草稿的免费预检查。 */
|
||||
const preview = ref<MotionRevisionPreview | null>(null)
|
||||
/** 明确确认视觉模型费用。 */
|
||||
@@ -81,10 +96,39 @@ export function useMotionRevision(
|
||||
const revision = computed(
|
||||
() => context.data.value?.history.revisions.find(item => item.revisionId === selectedId.value) ?? null
|
||||
)
|
||||
/** 沿真实父版本追溯失败根,重新打开人工子版本后仍可核对原任务,不改写原质量。 */
|
||||
const candidateOrigin = computed(() => {
|
||||
const rows = context.data.value?.history.revisions ?? [],
|
||||
seen = new Set<string>()
|
||||
let row = revision.value
|
||||
while (row && !seen.has(row.revisionId)) {
|
||||
if (row.candidateOrigin) return row.candidateOrigin
|
||||
seen.add(row.revisionId)
|
||||
row = rows.find(parent => parent.revisionId === row?.parentRevisionId) ?? null
|
||||
}
|
||||
return null
|
||||
})
|
||||
/** 草稿与所选修订内容保持一致才可校验或激活。 */
|
||||
const saved = computed(
|
||||
() => !!revision.value && JSON.stringify(draft.value) === JSON.stringify(revision.value.motionPlan)
|
||||
)
|
||||
/** 无正式原计划且尚无历史时,必须显式承接当前失败候选。 */
|
||||
const requiresCandidate = computed(
|
||||
() =>
|
||||
context.data.value?.preview.motionPlanAvailable === false &&
|
||||
context.data.value.history.revisions.length === 0
|
||||
)
|
||||
/** 原Task必须仍属于同项目同镜头、当前Motion阶段失败且有完整原候选。 */
|
||||
const candidateReady = computed(
|
||||
() =>
|
||||
failedCandidate.value?.shotId === props.shotId &&
|
||||
failedCandidate.value.taskId === failedTaskId.value.trim() &&
|
||||
failedCandidate.value.plan?.projectId === props.projectId &&
|
||||
failedCandidate.value.current &&
|
||||
failedCandidate.value.status === 'failed' &&
|
||||
failedCandidate.value.qualityFailure?.phase === 'motion_plan' &&
|
||||
!!failedCandidate.value.observations?.motion_plan
|
||||
)
|
||||
/** 项目已有请求或后台任务时禁止重复发起。 */
|
||||
const pending = computed(() => getOperation(props.projectId).pending)
|
||||
/** 自动核对输入期间允许继续填写草稿,不让定时查询打断输入焦点。 */
|
||||
@@ -105,6 +149,11 @@ export function useMotionRevision(
|
||||
() =>
|
||||
saved.value &&
|
||||
!invalidated.value &&
|
||||
revision.value?.source !== 'failed_candidate' &&
|
||||
!!preview.value?.sourceFingerprint &&
|
||||
!!record.value?.result?.plan &&
|
||||
(record.value.result.plan as { sourceFingerprint?: string }).sourceFingerprint ===
|
||||
preview.value.sourceFingerprint &&
|
||||
motionEvidenceCurrent(
|
||||
record.value,
|
||||
revision.value,
|
||||
@@ -114,6 +163,39 @@ export function useMotionRevision(
|
||||
)
|
||||
/** 查询与请求进行中临时禁用提交,不把有效证据误显示为失效。 */
|
||||
const canActivate = computed(() => !blocked.value && evidenceValid.value)
|
||||
/** 保存与正式采用独立;缺候选证据或交互输入不合法时不写入。 */
|
||||
const canSave = computed(
|
||||
() =>
|
||||
!blocked.value &&
|
||||
!interactionError.value &&
|
||||
preview.value?.valid === true &&
|
||||
(!requiresCandidate.value ||
|
||||
(candidateReady.value &&
|
||||
failedAcknowledged.value &&
|
||||
!!reason.value.trim() &&
|
||||
/^[a-f0-9]{64}$/.test(preview.value.sourceFingerprint ?? '') &&
|
||||
/^[a-f0-9]{64}$/.test(preview.value.previewFingerprint ?? '')))
|
||||
)
|
||||
/** 只能启动已保存的非失败根版本,且必须有当前精确起点计划。 */
|
||||
const canValidate = computed(
|
||||
() =>
|
||||
!blocked.value &&
|
||||
saved.value &&
|
||||
revision.value?.source !== 'failed_candidate' &&
|
||||
!!preview.value?.valid &&
|
||||
!!preview.value.startStatePlan &&
|
||||
preview.value.source?.projectId === props.projectId &&
|
||||
preview.value.source.primaryKeyframeId === context.data.value?.primary?.id &&
|
||||
/^[a-f0-9]{64}$/.test(preview.value.sourceFingerprint ?? '') &&
|
||||
preview.value.startStatePlan.version === 1 &&
|
||||
preview.value.startStatePlan.sourceFingerprint === preview.value.sourceFingerprint &&
|
||||
preview.value.startStatePlan.primaryKeyframeId === context.data.value?.primary?.id &&
|
||||
preview.value.startStatePlan.expectedRevisionId === context.data.value?.history.activeRevisionId &&
|
||||
preview.value.startStatePlan.motionPlanFingerprint === revision.value?.fingerprint &&
|
||||
/^[a-f0-9]{64}$/.test(preview.value.startStatePlan.fingerprint) &&
|
||||
['ready', 'reusable'].includes(preview.value.startStatePlan.status) &&
|
||||
(preview.value.startStatePlan.status === 'reusable' || preview.value.startStatePlan.executionAvailable)
|
||||
)
|
||||
/** 当前版本和主首帧输入变化也撤销费用确认及旧证据。 */
|
||||
const binding = computed(() =>
|
||||
JSON.stringify([
|
||||
@@ -126,10 +208,21 @@ export function useMotionRevision(
|
||||
if (old && old !== '[null,null,null]') invalidated.value = true
|
||||
acknowledged.value = false
|
||||
})
|
||||
/** 更换待核对Task只撤销承接确认,保留人工草稿等待新来源。 */
|
||||
watch(
|
||||
failedTaskId,
|
||||
() => {
|
||||
failedAcknowledged.value = false
|
||||
preview.value = null
|
||||
invalidated.value = true
|
||||
},
|
||||
{ flush: 'sync' }
|
||||
)
|
||||
watch(
|
||||
draft,
|
||||
() => {
|
||||
preview.value = null
|
||||
failedAcknowledged.value = false
|
||||
acknowledged.value = false
|
||||
if (!copying) invalidated.value = true
|
||||
},
|
||||
@@ -143,6 +236,10 @@ export function useMotionRevision(
|
||||
error.value = ''
|
||||
notice.value = ''
|
||||
acknowledged.value = false
|
||||
failedTaskId.value = ''
|
||||
failedCandidate.value = null
|
||||
failedAcknowledged.value = false
|
||||
interactionError.value = ''
|
||||
})
|
||||
/**
|
||||
* 复制所选版本或真实 AI 规划;改变来源后须重新取得视觉证据。
|
||||
@@ -173,6 +270,7 @@ export function useMotionRevision(
|
||||
select(
|
||||
value.history.activeRevisionId ??
|
||||
value.history.originalRevisionId ??
|
||||
value.history.revisions.findLast(row => row.source === 'manual')?.revisionId ??
|
||||
value.history.revisions.at(-1)?.revisionId ??
|
||||
'',
|
||||
true
|
||||
@@ -211,6 +309,7 @@ export function useMotionRevision(
|
||||
error.value = errorMessage(cause)
|
||||
if (cause instanceof ApiError && cause.status === 409) {
|
||||
invalidated.value = true
|
||||
preview.value = null
|
||||
acknowledged.value = false
|
||||
await context.refresh()
|
||||
changed()
|
||||
@@ -222,45 +321,73 @@ export function useMotionRevision(
|
||||
}
|
||||
/** 免费检查本次完整草稿;编辑或切镜后丢弃迟到回执。 */
|
||||
async function precheck() {
|
||||
if (interactionError.value) return
|
||||
const shotId = props.shotId
|
||||
const plan = JSON.parse(JSON.stringify(draft.value)) as MotionPlan
|
||||
const signature = JSON.stringify(plan)
|
||||
await perform('免费检查动作修订', async () => {
|
||||
const result = await motionApi.previewRevision(shotId, plan)
|
||||
const result = await motionApi.previewRevision(
|
||||
shotId,
|
||||
{ ...plan, interactions: plan.interactions ?? [] },
|
||||
preview.value?.sourceFingerprint
|
||||
)
|
||||
if (!disposed && props.shotId === shotId && signature === JSON.stringify(draft.value)) {
|
||||
if (result.shotId !== shotId) throw new Error('预检查回执与镜头不匹配。')
|
||||
if (result.shotId !== shotId || (result.source && result.source.projectId !== props.projectId))
|
||||
throw new Error('预检查回执与当前项目或镜头不匹配。')
|
||||
preview.value = result
|
||||
}
|
||||
})
|
||||
}
|
||||
/** 保存必须先获得当前草稿的结构通过结果,不激活或调用模型。 */
|
||||
async function save() {
|
||||
if (preview.value?.valid !== true) return
|
||||
if (!canSave.value) return
|
||||
const target = identity.value
|
||||
const shotId = props.shotId
|
||||
const plan = JSON.parse(JSON.stringify(draft.value)) as MotionPlan
|
||||
const plan = {
|
||||
...JSON.parse(JSON.stringify(draft.value)),
|
||||
interactions: draft.value.interactions ?? []
|
||||
} as MotionPlan
|
||||
const parentRevisionId = selectedId.value || null
|
||||
const failed = requiresCandidate.value
|
||||
? {
|
||||
taskId: failedCandidate.value!.taskId,
|
||||
expectedSourceFingerprint: preview.value!.sourceFingerprint!,
|
||||
expectedPreviewFingerprint: preview.value!.previewFingerprint!,
|
||||
acknowledgeFailedCandidate: true as const
|
||||
}
|
||||
: undefined
|
||||
await perform('保存动作修订', async () => {
|
||||
const result = await motionApi.saveRevision(shotId, {
|
||||
motionPlan: plan,
|
||||
parentRevisionId,
|
||||
reason: reason.value.trim() || null
|
||||
reason: reason.value.trim() || null,
|
||||
...(failed ? { failedCandidate: failed } : {})
|
||||
})
|
||||
if (result.shotId !== shotId || result.source !== 'manual' || result.isActive || !result.revisionId)
|
||||
throw new Error('保存回执不是当前镜头的未生效人工版本。')
|
||||
if (disposed || identity.value !== target) return
|
||||
await context.refresh()
|
||||
select(result.revisionId)
|
||||
notice.value = '修订已保存,尚未生效;请确认模型费用后校验。'
|
||||
failedAcknowledged.value = false
|
||||
notice.value = '人工修订已保存,尚未采用。重新免费预检后,可另行确认起点视觉费用;未自动启动任何模型。'
|
||||
})
|
||||
}
|
||||
/** 用户确认费用后重新读取首帧与生效指针,再启动视觉模型。 */
|
||||
async function validate() {
|
||||
if (!acknowledged.value || !saved.value || !revision.value || !context.data.value?.primary) return
|
||||
if (
|
||||
!acknowledged.value ||
|
||||
!canValidate.value ||
|
||||
!revision.value ||
|
||||
!context.data.value?.primary ||
|
||||
!preview.value?.startStatePlan
|
||||
)
|
||||
return
|
||||
const target = identity.value
|
||||
const selected = revision.value
|
||||
const originalProjectId = props.projectId
|
||||
const expectedBinding = binding.value
|
||||
const frozenPlan = preview.value.startStatePlan.fingerprint,
|
||||
sourceFingerprint = preview.value.sourceFingerprint
|
||||
acknowledged.value = false
|
||||
await perform('校验动作修订起点', async () => {
|
||||
await context.refresh()
|
||||
@@ -274,11 +401,27 @@ export function useMotionRevision(
|
||||
throw new Error('主首帧或生效版本已变化,请刷新并重新确认费用。')
|
||||
const primary = context.data.value?.primary
|
||||
if (!primary?.imageUrl) throw new Error('尚无有效主首帧,不能启动视觉校验。')
|
||||
const latest = await motionApi.previewRevision(selected.shotId, selected.motionPlan, sourceFingerprint)
|
||||
if (disposed || identity.value !== target) return
|
||||
if (
|
||||
!latest.valid ||
|
||||
latest.startStatePlan?.fingerprint !== frozenPlan ||
|
||||
!['ready', 'reusable'].includes(latest.startStatePlan.status) ||
|
||||
(latest.startStatePlan.status === 'ready' && !latest.startStatePlan.executionAvailable)
|
||||
) {
|
||||
preview.value = latest
|
||||
throw new Error('精确起点计划已变化或尚不可执行,请重新核对并确认费用。')
|
||||
}
|
||||
preview.value = latest
|
||||
const result = await motionApi.validateRevision(selected.shotId, selected.revisionId, {
|
||||
primaryKeyframeId: primary.id,
|
||||
expectedRevisionId: context.data.value!.history.activeRevisionId
|
||||
expectedRevisionId: context.data.value!.history.activeRevisionId,
|
||||
expectedPlanFingerprint: frozenPlan
|
||||
})
|
||||
if (!result.executionId || result.willCallModel !== true)
|
||||
if (
|
||||
!result.executionId ||
|
||||
(result.willCallModel !== true && !(result.willCallModel === false && result.reused === true))
|
||||
)
|
||||
throw new Error('未返回有效视觉校验任务,请刷新,勿重复提交。')
|
||||
if (!disposed && identity.value === target) invalidated.value = false
|
||||
await execution.track(result.executionId, originalProjectId)
|
||||
@@ -324,8 +467,72 @@ export function useMotionRevision(
|
||||
: '此版本已生效。'
|
||||
})
|
||||
}
|
||||
/** 主动读取原候选,只展示原失败证据,不自动载入或保存。 */
|
||||
async function readCandidate() {
|
||||
if (blocked.value || candidateLoading.value) return
|
||||
const target = identity.value,
|
||||
shotId = props.shotId,
|
||||
projectId = props.projectId
|
||||
candidateLoading.value = true
|
||||
error.value = ''
|
||||
failedAcknowledged.value = false
|
||||
failedCandidate.value = null
|
||||
try {
|
||||
let taskId = failedTaskId.value.trim()
|
||||
if (!taskId) {
|
||||
const plan = await motionApi.candidatePlan(shotId)
|
||||
if (plan.shotId !== shotId || plan.projectId !== projectId || !plan.latestTask?.taskId)
|
||||
throw new Error('当前镜头没有可核对的原任务。')
|
||||
taskId = plan.latestTask.taskId
|
||||
}
|
||||
const original = await motionApi.candidate(shotId, taskId)
|
||||
if (disposed || identity.value !== target) return
|
||||
if (original.taskId !== taskId || original.shotId !== shotId || original.plan?.projectId !== projectId)
|
||||
throw new Error('原任务不属于当前项目或镜头。')
|
||||
failedCandidate.value = original
|
||||
failedTaskId.value = taskId
|
||||
if (!candidateReady.value) error.value = '原任务不是当前可承接的动作质量失败候选,仅保留只读记录。'
|
||||
} catch (cause) {
|
||||
if (!disposed && target === identity.value) error.value = errorMessage(cause)
|
||||
} finally {
|
||||
if (target === identity.value) candidateLoading.value = false
|
||||
}
|
||||
}
|
||||
/** 从已保存失败根读取原公开回执,不将历史候选重新载入人工草稿或恢复模型执行。 */
|
||||
async function readOriginCandidate() {
|
||||
if (!candidateOrigin.value || blocked.value || candidateLoading.value) return
|
||||
failedTaskId.value = candidateOrigin.value.taskId
|
||||
await readCandidate()
|
||||
}
|
||||
/** 将原失败候选显式载入人工草稿,原Task/质量/回执保持失败。 */
|
||||
function useCandidate() {
|
||||
if (!candidateReady.value || !failedCandidate.value?.observations.motion_plan || blocked.value) return
|
||||
copying = true
|
||||
selectedId.value = ''
|
||||
draft.value = JSON.parse(JSON.stringify(failedCandidate.value.observations.motion_plan))
|
||||
copying = false
|
||||
preview.value = null
|
||||
reason.value = ''
|
||||
acknowledged.value = false
|
||||
failedAcknowledged.value = false
|
||||
invalidated.value = true
|
||||
notice.value = '已载入人工草稿,原候选仍为失败;请修改并免费预检。'
|
||||
}
|
||||
return {
|
||||
context,
|
||||
canSave,
|
||||
canValidate,
|
||||
failedTaskId,
|
||||
failedCandidate,
|
||||
failedAcknowledged,
|
||||
candidateLoading,
|
||||
requiresCandidate,
|
||||
candidateReady,
|
||||
candidateOrigin,
|
||||
readOriginCandidate,
|
||||
interactionError,
|
||||
readCandidate,
|
||||
useCandidate,
|
||||
selectedId,
|
||||
draft,
|
||||
reason,
|
||||
|
||||
@@ -136,7 +136,28 @@ export function useImageGenerationPreview<Input extends object, Preview extends
|
||||
/** 过期说明在新预览返回后仍保留,提醒再次确认。 */
|
||||
const staleNotice = ref('')
|
||||
/** 当前预览的 OpenAI 准入结论,未知时不允许收费。 */
|
||||
const charge = shallowRef<{ allowed: boolean; reusable: boolean; message: string } | null>(null)
|
||||
const charge = shallowRef<{
|
||||
allowed: boolean
|
||||
reusable: boolean
|
||||
message: string
|
||||
/** 实际批准期限,不延长服务端授权。 */ expiresAt?: string
|
||||
} | null>(null)
|
||||
/** 面板停留期间到期也撤销旧成功预检,不等用户再次发送请求。 */
|
||||
let expiryTimer: ReturnType<typeof setTimeout> | undefined
|
||||
watch(
|
||||
charge,
|
||||
value => {
|
||||
clearTimeout(expiryTimer)
|
||||
if (!value?.expiresAt || !value.allowed || value.reusable) return
|
||||
const delay = Date.parse(value.expiresAt) - Date.now()
|
||||
if (delay >= 0 && delay <= 2_147_483_647)
|
||||
expiryTimer = setTimeout(() => {
|
||||
invalidate()
|
||||
staleNotice.value = '本次授权已到期,请重新核对许可与费用计划。'
|
||||
}, delay)
|
||||
},
|
||||
{ flush: 'sync' }
|
||||
)
|
||||
/** 授权保存或撤销使打开的预览失效。 */
|
||||
const authorizationRevision = useProjectGenerationRevision()
|
||||
/** 有效授权内无需逐张收费确认,其它供应方仍独立确认。 */
|
||||
@@ -176,11 +197,11 @@ export function useImageGenerationPreview<Input extends object, Preview extends
|
||||
revision++
|
||||
controller?.abort()
|
||||
preview.value = null
|
||||
charge.value = null
|
||||
acknowledged.value = false
|
||||
loading.value = false
|
||||
error.value = ''
|
||||
staleNotice.value = ''
|
||||
charge.value = null
|
||||
}
|
||||
watch(key, invalidate, { flush: 'sync' })
|
||||
onBeforeUnmount(invalidate)
|
||||
@@ -193,6 +214,7 @@ export function useImageGenerationPreview<Input extends object, Preview extends
|
||||
const abort = new AbortController()
|
||||
controller = abort
|
||||
preview.value = null
|
||||
charge.value = null
|
||||
acknowledged.value = false
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
@@ -272,6 +294,11 @@ export function useImageGenerationPreview<Input extends object, Preview extends
|
||||
|
||||
/** 明确提交一次;预览过期只重读预览,绝不自动重新生成。 */
|
||||
async function submit() {
|
||||
if (charge.value?.expiresAt && Date.parse(charge.value.expiresAt) <= Date.now() && !reusableResult.value) {
|
||||
invalidate()
|
||||
staleNotice.value = '本次授权已到期,请重新核对许可与费用计划。'
|
||||
return
|
||||
}
|
||||
if (!canSubmit.value || !preview.value) return
|
||||
if (reusableResult.value && options.reuseResult) {
|
||||
submitting.value = true
|
||||
@@ -321,6 +348,17 @@ export function useImageGenerationPreview<Input extends object, Preview extends
|
||||
}
|
||||
acknowledged.value = false
|
||||
charge.value = null
|
||||
if (
|
||||
result.cause instanceof ApiError &&
|
||||
result.cause.status === 409 &&
|
||||
(result.cause.code === 'SCENE_CONTINUITY_REVIEW_STALE' ||
|
||||
result.cause.message.startsWith('SCENE_CONTINUITY_REVIEW_STALE'))
|
||||
) {
|
||||
invalidate()
|
||||
staleNotice.value = '衔接规划来源已变化,请核对当前来源并重新预览;原输入已保留。'
|
||||
error.value = errorMessage(result.cause)
|
||||
return
|
||||
}
|
||||
if (
|
||||
result.cause instanceof ApiError &&
|
||||
result.cause.status === 409 &&
|
||||
@@ -347,6 +385,7 @@ export function useImageGenerationPreview<Input extends object, Preview extends
|
||||
staleNotice,
|
||||
recoveryNotice,
|
||||
canSubmit,
|
||||
invalidate,
|
||||
loadPreview,
|
||||
submit
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user