feat(short-drama-agent-front): 接入人工动作修订与视频版本权限

This commit is contained in:
GJ committed 2026-10-14 13:44:02 +08:00
1 parent 7a60db3ced
commit fa76165960
38 files changed
+2003 -158

No files matched your search

@@ -1,4 +1,5 @@
<script setup lang="ts">
import { videoOperationAllowed } from '../video-permissions'
import FeedbackMessage from '../../../components/ui/FeedbackMessage.vue'
import ContextNotice from '../../../components/ui/ContextNotice.vue'
@@ -20,6 +21,8 @@ import { generationConfigApi } from '../../generation-config/api'
import type { GenerationOptions } from '../../generation-config/types'
import { useQuery } from '../../../composables/useQuery'
import ModelCapabilities from './ModelCapabilities.vue'
import { productionApi } from '../api'
import type { ShotVideo } from '../types'
/** 单素材与当前集质量生成共用一个按需打开的面板,默认小批量且不自动调用模型。 */
const props = defineProps<{
@@ -29,6 +32,10 @@ const props = defineProps<{
target: QualityTarget | null
/** 上游状态阻断 */
disabled: boolean
/** 当前候选的公开权限,更新后撤销费用确认。 */
video?: ShotVideo | null
/** 明确修复入口的初始动作,不代替费用确认。 */
initialAction?: 'validate' | 'repair'
}>()
/** 质量面板的open状态,随目标更新。 */
const open = defineModel<boolean>('open', { default: false })
@@ -37,9 +44,42 @@ const emit = defineEmits<{ changed: []; locate: [shotId: string]; started: [exec
const { key, session, operation, execution, blocked, run } = useQuality(
props,
() => open.value,
() => emit('changed'),
() => {
emit('changed')
void videoQuery.refresh()
},
id => emit('started', id)
)
/** 质量弹窗重新读取所选候选自身的权限,不以会话历史代替后端事实。 */
const videoKey = computed(() =>
open.value && props.target?.kind === 'video' ? JSON.stringify([props.target.shotId, props.target.assetId]) : ''
)
/** 按正式镜头和候选 ID 查询公开权限。 */
const videoQuery = useQuery(videoKey, async (value, signal) => {
if (!value) return null
const [shotId, assetId] = JSON.parse(value) as [string, string]
const items = await productionApi.listVideos(shotId, signal)
const item = items.find(video => video.id === assetId && video.shotId === shotId)
if (!item) throw new Error('当前视频不存在,请刷新候选。')
return item
})
/**
* 独立读取和外层最新资产均不得明确拒绝本候选操作。
* @param requested 请求的质量操作
* @returns 当前是否可以进入费用确认后的提交
*/
function canUseVideoAction(requested: 'validate' | 'repair') {
return (
!videoQuery.loading.value &&
!videoQuery.error.value &&
(!props.video || videoOperationAllowed(props.video, requested)) &&
videoOperationAllowed(videoQuery.data.value, requested)
)
}
/** 质量目标与当前候选操作权限共同控制提交。 */
const videoAllowed = computed(
() => props.target?.kind !== 'video' || canUseVideoAction(action.value === 'repair' ? 'repair' : 'validate')
)
/** 模型目录只读查询,随当前项目和弹窗状态取消过期请求。 */
const modelKey = computed(() =>
open.value && props.target?.kind === 'batch' && props.projectId ? props.projectId : ''
@@ -138,20 +178,25 @@ const maxValidations = computed(() =>
)
/** 质量面板的saved状态,随目标更新。 */
const saved = computed(() => (props.target?.kind === 'video' ? (session.value.videoValidation ?? null) : null))
/** 质量面板的repairAvailable状态,随目标更新。 */
const repairAvailable = computed(
() =>
!videoRepair.value ||
(session.value.receipt?.kind === 'video'
? session.value.receipt.result.passed === false
: saved.value?.passed === false)
/** 修复与校验均使用所选候选后端权限,持久化失败可直接修复。 */
const repairAvailable = computed(() => videoAllowed.value)
/** 外层候选版本或权限变化后撤销已确认费用。 */
watch([() => props.video, () => videoQuery.data.value], () => {
acknowledged.value = false
})
/** 优先选择后端允许的操作,两个权限均关闭时保持按钮禁用。 */
watch(
() => videoQuery.data.value,
video => {
if (video && !video.canValidate && video.canRepair) action.value = 'repair'
}
)
/** 目标和费用范围变化均撤销确认;关闭不取消已经发送到后端的长请求。 */
watch(
[key, open],
() => {
action.value = props.target?.kind === 'batch' ? 'batch' : 'validate'
action.value = props.target?.kind === 'batch' ? 'batch' : (props.initialAction ?? 'validate')
attempts.value = props.target?.kind === 'video' ? 2 : 1
concurrency.value = 1
limit.value = 1
@@ -215,6 +260,13 @@ const optionsExpanded = ref<string[]>(['options'])
description="查看质量结果,或按需发起新的视觉检查。"
wide
>
<ContextNotice
v-if="target?.kind === 'video' && (videoQuery.error.value || videoQuery.data.value?.staleReason)"
type="warning"
:show-icon="false"
>
{{ videoQuery.error.value || videoQuery.data.value?.staleReason }}
</ContextNotice>
<AppForm
ref="formRef"
:model="formModel"
@@ -232,8 +284,9 @@ const optionsExpanded = ref<string[]>(['options'])
class="mt-4"
aria-label="素材质量操作"
>
<NRadioButton value="validate">视觉校验</NRadioButton
><NRadioButton value="repair">{{
<NRadioButton value="validate" :disabled="target?.kind === 'video' && !canUseVideoAction('validate')"
>视觉校验</NRadioButton
><NRadioButton value="repair" :disabled="target?.kind === 'video' && !canUseVideoAction('repair')">{{
target?.kind === 'video' ? '生成修复候选' : '校验并修复'
}}</NRadioButton>
</NRadioGroup>
@@ -269,7 +322,7 @@ const optionsExpanded = ref<string[]>(['options'])
本次仅创建一个修复视频,不自动等待或复检。完成后请打开新候选的质量检查;修复约束沿用上次失败校验,不使用额外参数。
</p>
<ContextNotice v-if="!repairAvailable" type="warning" :show-icon="false" class="mt-3"
>请先执行视觉校验,只有未通过的视频可以创建修复候选。</ContextNotice
>当前候选不允许执行所选质量操作,请查看后端原因或刷新权限。</ContextNotice
>
<NCollapse
v-if="!videoRepair"