feat: 同步质量校验修复并精简工作台操作
This commit is contained in:
1 parent
771b66cafc
commit
13bb6dc83b
47 files changed
+2244
-260
No files matched your search
@@ -0,0 +1,261 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import {
|
||||
NAlert,
|
||||
NButton,
|
||||
NCheckbox,
|
||||
NCollapse,
|
||||
NCollapseItem,
|
||||
NInput,
|
||||
NInputNumber,
|
||||
NRadioButton,
|
||||
NRadioGroup
|
||||
} from 'naive-ui'
|
||||
import { AppDialog } from '../../../components/ui'
|
||||
import { allowedTextLines, savedVideoValidation, validQualityInput } from '../quality'
|
||||
import type { QualityAction, QualityInput, QualityTarget } from '../quality.types'
|
||||
import { useQuality } from '../useQuality'
|
||||
import QualityResult from './QualityResult.vue'
|
||||
import ModelCapabilities from './ModelCapabilities.vue'
|
||||
|
||||
/** 单素材与当前集质量生成共用一个按需打开的面板,默认小批量且不自动调用模型。 */
|
||||
const props = defineProps<{
|
||||
projectId: string
|
||||
target: QualityTarget | null
|
||||
disabled: boolean
|
||||
savedRawJson?: string | null
|
||||
}>()
|
||||
const open = defineModel<boolean>('open', { default: false })
|
||||
const emit = defineEmits<{ changed: []; locate: [shotId: string] }>()
|
||||
const { key, session, operation, blocked, run } = useQuality(
|
||||
props,
|
||||
() => open.value,
|
||||
() => emit('changed')
|
||||
)
|
||||
const action = ref<QualityAction>('validate')
|
||||
const attempts = ref<number | null>(1)
|
||||
const concurrency = ref<number | null>(1)
|
||||
const limit = ref<number | null>(1)
|
||||
const force = ref(false)
|
||||
const width = ref<number | null>(null)
|
||||
const height = ref<number | null>(null)
|
||||
const texts = ref('')
|
||||
const acknowledged = ref(false)
|
||||
const videoRepair = computed(() => props.target?.kind === 'video' && action.value === 'repair')
|
||||
const input = computed<QualityInput>(() => ({
|
||||
concurrency: action.value === 'batch' ? (concurrency.value ?? 0) : 1,
|
||||
limit: action.value === 'batch' ? (limit.value ?? 0) : 1,
|
||||
maxRepairAttempts: action.value === 'validate' ? 0 : (attempts.value ?? -1),
|
||||
force: force.value,
|
||||
episodeNo: props.target?.kind === 'batch' ? props.target.episodeNo : 1,
|
||||
allowedTexts: allowedTextLines(texts.value),
|
||||
...(action.value === 'validate' || width.value === null ? {} : { width: width.value }),
|
||||
...(action.value === 'validate' || height.value === null ? {} : { height: height.value })
|
||||
}))
|
||||
const valid = computed(
|
||||
() => validQualityInput(input.value) && (!videoRepair.value || input.value.maxRepairAttempts > 0)
|
||||
)
|
||||
const generating = computed(() => action.value !== 'validate')
|
||||
const label = computed(() =>
|
||||
action.value === 'batch'
|
||||
? '开始质量生成'
|
||||
: action.value === 'repair'
|
||||
? videoRepair.value
|
||||
? '创建视频修复候选'
|
||||
: '校验并修复'
|
||||
: '开始视觉校验'
|
||||
)
|
||||
const maxImages = computed(() =>
|
||||
action.value === 'batch'
|
||||
? input.value.limit * (1 + input.value.maxRepairAttempts)
|
||||
: action.value === 'repair'
|
||||
? input.value.maxRepairAttempts
|
||||
: 0
|
||||
)
|
||||
const maxValidations = computed(() =>
|
||||
action.value === 'batch' ? maxImages.value : action.value === 'repair' ? input.value.maxRepairAttempts + 1 : 1
|
||||
)
|
||||
const saved = computed(() => (props.target?.kind === 'video' ? savedVideoValidation(props.savedRawJson) : null))
|
||||
const repairAvailable = computed(
|
||||
() =>
|
||||
!videoRepair.value ||
|
||||
(session.value.receipt?.kind === 'video'
|
||||
? session.value.receipt.result.passed === false
|
||||
: saved.value?.passed === false)
|
||||
)
|
||||
|
||||
/** 目标和费用范围变化均撤销确认;关闭不取消已经发送到后端的长请求。 */
|
||||
watch(
|
||||
[key, open],
|
||||
() => {
|
||||
action.value = props.target?.kind === 'batch' ? 'batch' : 'validate'
|
||||
attempts.value = props.target?.kind === 'video' ? 2 : 1
|
||||
concurrency.value = 1
|
||||
limit.value = 1
|
||||
force.value = false
|
||||
width.value = null
|
||||
height.value = null
|
||||
texts.value = ''
|
||||
acknowledged.value = false
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
watch([input, action], () => {
|
||||
acknowledged.value = false
|
||||
})
|
||||
/** 付费入口保留明确确认,不因菜单选择或查看历史自动提交。 */
|
||||
async function submit() {
|
||||
if (!acknowledged.value || !valid.value || blocked.value || !repairAvailable.value) return
|
||||
acknowledged.value = false
|
||||
await run(action.value, input.value)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AppDialog
|
||||
v-model:open="open"
|
||||
:title="`质量检查 · ${target?.title ?? ''}`"
|
||||
description="查看质量结果,或按需发起新的视觉检查。"
|
||||
wide
|
||||
>
|
||||
<NRadioGroup
|
||||
v-if="target && target.kind !== 'batch'"
|
||||
v-model:value="action"
|
||||
:disabled="operation.pending"
|
||||
class="mt-4"
|
||||
aria-label="素材质量操作"
|
||||
>
|
||||
<NRadioButton value="validate">视觉校验</NRadioButton
|
||||
><NRadioButton value="repair">{{ target?.kind === 'video' ? '生成修复候选' : '校验并修复' }}</NRadioButton>
|
||||
</NRadioGroup>
|
||||
<NAlert v-if="target?.kind === 'video'" type="info" :show-icon="false" class="mt-4"
|
||||
>视频校验只检查三个抽样帧,不含音频、口型和完整运动。普通候选只校验;修复候选复检通过后会自动设为主视频。</NAlert
|
||||
>
|
||||
<div v-if="generating" class="quality-fields mt-4">
|
||||
<label
|
||||
><span class="field-label">{{ videoRepair ? '修复链次数上限' : '每镜最多修复' }}</span
|
||||
><NInputNumber
|
||||
v-model:value="attempts"
|
||||
:disabled="operation.pending"
|
||||
:min="videoRepair ? 1 : 0"
|
||||
:step="1"
|
||||
:input-props="{ 'aria-label': '每镜最多修复次数' }"
|
||||
/></label>
|
||||
<label v-if="target?.kind === 'batch'"
|
||||
><span class="field-label">本批镜头上限</span
|
||||
><NInputNumber
|
||||
v-model:value="limit"
|
||||
:disabled="operation.pending"
|
||||
:min="1"
|
||||
:step="1"
|
||||
:input-props="{ 'aria-label': '质量生成镜头上限' }"
|
||||
/></label>
|
||||
</div>
|
||||
<NCheckbox v-if="target?.kind === 'batch'" v-model:checked="force" :disabled="operation.pending" class="mt-4"
|
||||
>重做本集已有有效首帧(通过后替换主图)</NCheckbox
|
||||
>
|
||||
<p v-if="target?.kind === 'batch'" class="mt-3 text-xs text-muted">
|
||||
仅第 {{ target.episodeNo }} 集,最多
|
||||
{{ limit ?? '—' }} 镜;非重做模式优先处理过期项,若全项目无过期项则补缺失首帧。
|
||||
</p>
|
||||
<p v-if="videoRepair" class="mt-3 text-xs text-muted">
|
||||
本次仅创建一个修复视频,不自动等待或复检。完成后请打开新候选的质量检查;修复约束沿用上次失败校验,不使用额外参数。
|
||||
</p>
|
||||
<NAlert v-if="!repairAvailable" type="warning" :show-icon="false" class="mt-3"
|
||||
>请先执行视觉校验,只有未通过的视频可以创建修复候选。</NAlert
|
||||
>
|
||||
<NCollapse v-if="!videoRepair" class="mt-4">
|
||||
<NCollapseItem name="options" title="更多参数与模型限制">
|
||||
<div class="quality-fields">
|
||||
<label v-if="target?.kind === 'batch'"
|
||||
><span class="field-label">批量并发</span
|
||||
><NInputNumber
|
||||
v-model:value="concurrency"
|
||||
:disabled="operation.pending"
|
||||
:min="1"
|
||||
:step="1"
|
||||
:input-props="{ 'aria-label': '质量生成并发' }"
|
||||
/></label>
|
||||
<label v-if="generating"
|
||||
><span class="field-label">宽度(可选)</span
|
||||
><NInputNumber
|
||||
v-model:value="width"
|
||||
:disabled="operation.pending"
|
||||
:min="1"
|
||||
:input-props="{ 'aria-label': '质量生成宽度' }"
|
||||
/></label>
|
||||
<label v-if="generating"
|
||||
><span class="field-label">高度(可选)</span
|
||||
><NInputNumber
|
||||
v-model:value="height"
|
||||
:disabled="operation.pending"
|
||||
:min="1"
|
||||
:input-props="{ 'aria-label': '质量生成高度' }"
|
||||
/></label>
|
||||
</div>
|
||||
<label class="mt-4 block"
|
||||
><span class="field-label">额外允许的画面文字(一行一项,可留空)</span
|
||||
><NInput
|
||||
v-model:value="texts"
|
||||
:disabled="operation.pending"
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 2, maxRows: 5 }"
|
||||
:input-props="{ 'aria-label': '额外允许的画面文字' }"
|
||||
/></label>
|
||||
<ModelCapabilities :shot-id="target && target.kind !== 'batch' ? target.shotId : undefined" />
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
<NAlert v-if="!valid" type="error" :show-icon="false" class="mt-4">{{
|
||||
videoRepair
|
||||
? '修复链次数上限需为正整数。'
|
||||
: '并发、数量和集数需为正整数,修复次数需为非负整数;宽高同时留空或同时填写正整数。'
|
||||
}}</NAlert>
|
||||
<NAlert type="warning" :show-icon="false" class="mt-4">
|
||||
<template v-if="videoRepair"
|
||||
>本次最多提交 1
|
||||
个视频生成任务,可能产生费用;生成完成不会切换主视频,需再次付费复检通过后才会晋升。</template
|
||||
>
|
||||
<template v-else-if="valid"
|
||||
>本次最多调用 {{ maxImages }} 次生图、{{ maxValidations }} 次视觉校验,均可能产生费用。</template
|
||||
>
|
||||
<template v-if="generating && !videoRepair"
|
||||
>修复/质量生成通过后可能替换主首帧;失败候选仍会保留,已有视频不会自动更新。</template
|
||||
>
|
||||
<template v-else-if="!generating">{{
|
||||
target?.kind === 'video' ? '如果当前是修复候选,校验通过将替换当前主视频。' : '仅校验,不修改主资产。'
|
||||
}}</template>
|
||||
</NAlert>
|
||||
<NCheckbox v-model:checked="acknowledged" :disabled="operation.pending" class="mt-4"
|
||||
>我已确认费用、处理范围,且同项目没有其他生成任务。</NCheckbox
|
||||
>
|
||||
<div class="dialog-footer mt-4">
|
||||
<NButton @click="open = false">关闭</NButton>
|
||||
<NButton
|
||||
type="primary"
|
||||
:loading="operation.pending"
|
||||
:disabled="blocked || !valid || !acknowledged || !repairAvailable"
|
||||
@click="submit"
|
||||
>{{ label }}</NButton
|
||||
>
|
||||
</div>
|
||||
<p v-if="operation.pending" role="status" class="mt-3 text-xs text-muted">
|
||||
{{ operation.label }}进行中。关闭面板不会取消后端任务;请勿重复提交。
|
||||
</p>
|
||||
<NAlert v-if="session.error" role="alert" type="error" :show-icon="false" class="mt-4">{{
|
||||
session.error
|
||||
}}</NAlert>
|
||||
<QualityResult v-if="session.receipt" :receipt="session.receipt" @locate="emit('locate', $event)" />
|
||||
<NCollapse v-else-if="saved" class="mt-4"
|
||||
><NCollapseItem name="saved" :title="`最近已保存校验 · ${saved.passed ? '通过' : '未通过'}`"
|
||||
><p>{{ saved.summary }}</p>
|
||||
<p v-for="(issue, index) in saved.issues" :key="index" class="mt-2 text-danger">
|
||||
{{ issue.description }}
|
||||
</p>
|
||||
<p class="mt-3 text-xs text-muted">此为历史抽样结论,不保证当前上游素材仍然一致。</p></NCollapseItem
|
||||
></NCollapse
|
||||
>
|
||||
<p v-if="session.receipt && target?.kind !== 'video'" class="mt-3 text-xs text-muted">
|
||||
回执保留在当前会话,可导出;后端暂未提供首帧校验历史读取接口。
|
||||
</p>
|
||||
</AppDialog>
|
||||
</template>
|
||||
Reference in new issue
Block a user