feat(short-drama-agent-front): 接入联合修订与图片费用审计
This commit is contained in:
1 parent
87427d9d43
commit
f6edc4eb70
52 files changed
+5060
-516
No files matched your search
@@ -1,4 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import { useQuery } from '../../../composables/useQuery'
|
||||
import { imageAuthorizationApi } from '../../image-authorization/api'
|
||||
import { formatMicros } from '../../image-authorization/model'
|
||||
import { NSelect } from 'naive-ui'
|
||||
import KeyframePreviewChecks from './KeyframePreviewChecks.vue'
|
||||
import ImageGenerationPreview from '../../subject-images/components/ImageGenerationPreview.vue'
|
||||
import { useImageGenerationPreview, type ImageGenerationSubmission } from '../../subject-images/generation-preview'
|
||||
@@ -28,6 +32,8 @@ const props = defineProps<{
|
||||
shotTitle: string
|
||||
projectId: string
|
||||
disabled: boolean
|
||||
/** 原镜头条件仍有效时允许免费核对追加许可,不放开普通未知重发。 */
|
||||
additionalAllowed?: boolean
|
||||
replacePrimary?: boolean
|
||||
/** 当前镜头的正式摄影设计。 */
|
||||
direction?: ShotDirection | null
|
||||
@@ -35,6 +41,8 @@ const props = defineProps<{
|
||||
visualState?: ShotVisualState | null
|
||||
/** 提交前已有候选,用于区分下载恢复与历史候选。 */
|
||||
previousCandidateIds?: readonly string[]
|
||||
/** 免费查看经当前预览核实的已有完整候选,不产生POST。 */
|
||||
reuseExisting?: (fingerprint: string) => Promise<boolean>
|
||||
/** 仅发送已经确认的当前快照。 */
|
||||
submitGeneration: (input: GenerateKeyframeInput) => Promise<ImageGenerationSubmission>
|
||||
}>()
|
||||
@@ -69,6 +77,58 @@ const generationCatalog = ref<GenerationModelCatalog | null>(null)
|
||||
const generationCatalogError = ref('')
|
||||
/** 实际项目及镜头配置解析后的模型。 */
|
||||
const imageProvider = ref('')
|
||||
/** 当前用户主动选择的许可,重新打开或切换范围后不保留默认选择。 */
|
||||
const additionalId = ref<string | null>(null)
|
||||
/** 人工追加只属于OpenAI,不改变其它供应方的未知请求保护。 */
|
||||
const canInspectAdditional = computed(() => !!props.additionalAllowed && imageProvider.value === 'openai-image')
|
||||
/** 仅需要核对原失败请求时读取已有许可,不自动创建。 */
|
||||
const additionalKey = computed(() =>
|
||||
open.value && canInspectAdditional.value ? JSON.stringify([props.projectId, props.shotId]) : ''
|
||||
)
|
||||
/** 当前原项目的有限许可和原unknown历史。 */
|
||||
const additionalQuery = useQuery(additionalKey, async (value, signal) => {
|
||||
if (!value) return null
|
||||
const [projectId] = JSON.parse(value) as [string, string]
|
||||
const result = await imageAuthorizationApi.list(projectId, signal)
|
||||
if (!result || !Array.isArray(result.requests) || !Array.isArray(result.authorizations))
|
||||
throw new Error('原请求与授权记录读取不完整,请重新核对。')
|
||||
return result
|
||||
})
|
||||
/** 只列原镜头已有且未撤销、尚有次数的许可,不自动选中。 */
|
||||
const additionalOptions = computed(() =>
|
||||
(additionalQuery.data.value?.additionalAuthorizations ?? [])
|
||||
.filter(
|
||||
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'
|
||||
)
|
||||
)
|
||||
.map(permit => ({
|
||||
label: `${permit.input.approvedBy} · 已用 ${permit.usedRequests} / 剩余 ${permit.remainingRequests} 次`,
|
||||
value: permit.id
|
||||
}))
|
||||
)
|
||||
/** 已选许可及其原unknown,不改写原范围或金额。 */
|
||||
const additionalPermit = computed(() =>
|
||||
additionalQuery.data.value?.additionalAuthorizations?.find(permit => permit.id === additionalId.value)
|
||||
)
|
||||
/** 原未知费用与预留保持显示。 */
|
||||
const additionalParent = computed(() =>
|
||||
additionalQuery.data.value?.requests.find(row => row.id === additionalPermit.value?.input.parentRequestId)
|
||||
)
|
||||
watch(
|
||||
[() => props.projectId, () => props.shotId, open],
|
||||
() => {
|
||||
additionalId.value = null
|
||||
},
|
||||
{ flush: 'sync' }
|
||||
)
|
||||
/** 本次明确参数。 */
|
||||
const imageGenerationOptions = ref<GenerationOptions>({})
|
||||
/** 项目画幅。 */
|
||||
@@ -76,7 +136,8 @@ const projectAspectRatio = ref<CreativeProfileAspectRatio>('9:16')
|
||||
/** 预览和生成复用当前请求字段,生成时再附加版本及候选标记。 */
|
||||
const generationInput = computed(() => ({
|
||||
provider: imageProvider.value || undefined,
|
||||
generationOptions: imageGenerationOptions.value
|
||||
generationOptions: imageGenerationOptions.value,
|
||||
...(additionalId.value ? { additionalAuthorizationId: additionalId.value } : {})
|
||||
}))
|
||||
/** 首帧与主体图片使用同一套预览确认与未知费用保护。 */
|
||||
const {
|
||||
@@ -84,6 +145,7 @@ const {
|
||||
acknowledged,
|
||||
requiresCostConfirmation,
|
||||
chargeNotice,
|
||||
reusableResult,
|
||||
loading,
|
||||
submitting,
|
||||
error,
|
||||
@@ -100,17 +162,32 @@ const {
|
||||
targetId: props.shotId,
|
||||
exactPreview: true
|
||||
}),
|
||||
recoveryTarget: () => (props.shotId ? 'keyframe:' + props.shotId : ''),
|
||||
additionalAuthorizationId: () => additionalId.value ?? undefined,
|
||||
recoveryTarget: () =>
|
||||
props.shotId
|
||||
? additionalId.value && additionalPermit.value
|
||||
? `keyframe:${props.projectId}:${props.shotId}:additional:${additionalId.value}:used:${additionalPermit.value.usedRequests}`
|
||||
: 'keyframe:' + props.shotId
|
||||
: '',
|
||||
previousCandidateIds: () => props.previousCandidateIds,
|
||||
target: () => JSON.stringify([props.shotId, props.direction, props.visualState]),
|
||||
target: () => JSON.stringify([props.projectId, props.shotId, props.direction, props.visualState]),
|
||||
input: () => generationInput.value,
|
||||
disabled: () => props.disabled || !imageProvider.value,
|
||||
disabled: () =>
|
||||
(props.disabled && !canInspectAdditional.value) ||
|
||||
!imageProvider.value ||
|
||||
(!!additionalId.value &&
|
||||
(imageProvider.value !== 'openai-image' || additionalQuery.loading.value || !!additionalQuery.error.value)),
|
||||
load: async (input, signal) => {
|
||||
const shotId = props.shotId
|
||||
const result = await productionApi.previewKeyframe(shotId, input, signal)
|
||||
const result = await productionApi.previewKeyframe(
|
||||
shotId,
|
||||
{ provider: input.provider, generationOptions: input.generationOptions },
|
||||
signal
|
||||
)
|
||||
if (result?.shotId !== shotId) throw new Error('预览结果与当前镜头不匹配。')
|
||||
return result
|
||||
},
|
||||
reuseResult: props.reuseExisting ? result => props.reuseExisting!(result.previewFingerprint) : undefined,
|
||||
generate: input => props.submitGeneration({ ...input, setPrimary: false })
|
||||
})
|
||||
|
||||
@@ -169,7 +246,7 @@ watch(
|
||||
<AppForm
|
||||
ref="formRef"
|
||||
:model="imageGenerationOptions"
|
||||
:disabled="disabled || submitting"
|
||||
:disabled="(disabled && !canInspectAdditional) || submitting"
|
||||
:reset-key="`${open}:${shotId}`"
|
||||
validate-on-change
|
||||
@submit="submit"
|
||||
@@ -196,6 +273,31 @@ watch(
|
||||
<ContextNotice v-else-if="generationCatalogError" type="warning" :show-icon="false" class="mt-5 text-xs">
|
||||
生成模型目录读取失败:{{ generationCatalogError }}
|
||||
</ContextNotice>
|
||||
<!-- 以下是用户主动选择的原精确计划追加许可,普通unknown不放行。 -->
|
||||
<section v-if="canInspectAdditional" class="workspace-section-stack mt-5">
|
||||
<p class="text-sm">
|
||||
原请求和费用仍未知。只可使用已单独批准的有限许可,重新预览核对精确计划;不会自动追加或消费剩余次数。
|
||||
</p>
|
||||
<NSelect
|
||||
v-model:value="additionalId"
|
||||
clearable
|
||||
:options="additionalOptions"
|
||||
:disabled="submitting || additionalQuery.loading.value"
|
||||
placeholder="主动选择已有人工追加许可(可不选,仅免费预览)"
|
||||
aria-label="本次人工追加许可"
|
||||
/><NButton
|
||||
:loading="additionalQuery.loading.value"
|
||||
:disabled="submitting"
|
||||
@click="additionalQuery.refresh"
|
||||
>刷新追加许可与原请求</NButton
|
||||
>
|
||||
<p v-if="additionalQuery.error.value" role="alert">{{ additionalQuery.error.value }}</p>
|
||||
<p v-if="additionalParent" class="text-sm">
|
||||
原镜头 {{ additionalParent.input.targetId }} · 原型号 {{ additionalParent.input.model }} · 原预留
|
||||
{{ formatMicros(additionalParent.input.reservedMicros) }} · 原账单
|
||||
{{ formatMicros(additionalParent.output?.actualBilledMicros) }}
|
||||
</p>
|
||||
</section>
|
||||
<!-- 以下是正式摄影设计与画面状态 -->
|
||||
<NCollapse v-if="direction || visualState" class="mt-5">
|
||||
<NCollapseItem v-if="direction" name="direction" title="当前镜头设计">
|
||||
@@ -261,7 +363,7 @@ watch(
|
||||
:loading="submitting"
|
||||
@click="formRef?.validate(submit)"
|
||||
type="primary"
|
||||
>确认生成首帧</NButton
|
||||
>{{ reusableResult ? '查看已有同计划候选' : '确认生成首帧' }}</NButton
|
||||
>
|
||||
</template>
|
||||
</AppDialog>
|
||||
|
||||
Reference in new issue
Block a user