feat: 同步精简接口并统一表单校验

This commit is contained in:
GJ committed 2026-09-10 22:34:47 +08:00
1 parent 82d7bde631
commit 2eea0ea72e
66 files changed
+1611 -1100

No files matched your search

@@ -1,4 +1,7 @@
<script setup lang="ts">
import AppForm from '../../../components/ui/AppForm.vue'
import { NFormItem } from 'naive-ui'
import { integerRule, sizeRules } from '../../../lib/form-rules'
import { computed, ref, watch } from 'vue'
import {
NAlert,
@@ -12,7 +15,7 @@ import {
NRadioGroup
} from 'naive-ui'
import { AppDialog } from '../../../components/ui'
import { allowedTextLines, savedVideoValidation, validQualityInput } from '../quality'
import { allowedTextLines, validQualityInput } from '../quality'
import type { QualityAction, QualityInput, QualityTarget } from '../quality.types'
import { useQuality } from '../useQuality'
import QualityResult from './QualityResult.vue'
@@ -23,7 +26,6 @@ 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] }>()
@@ -75,7 +77,7 @@ const maxImages = computed(() =>
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 saved = computed(() => (props.target?.kind === 'video' ? (session.value.videoValidation ?? null) : null))
const repairAvailable = computed(
() =>
!videoRepair.value ||
@@ -109,6 +111,21 @@ async function submit() {
acknowledged.value = false
await run(action.value, input.value)
}
const formModel = computed(() => ({
attempts: attempts.value,
concurrency: concurrency.value,
limit: limit.value,
width: width.value,
height: height.value,
texts: texts.value
}))
const rules = computed(() => ({
attempts: integerRule('修复次数', videoRepair.value ? 1 : 0),
concurrency: integerRule('批量并发'),
limit: integerRule('本批镜头上限'),
...sizeRules(() => formModel.value)
}))
const optionsExpanded = ref<string[]>([])
</script>
<template>
@@ -118,126 +135,141 @@ async function submit() {
description="查看质量结果,或按需发起新的视觉检查。"
wide
>
<NRadioGroup
v-if="target && target.kind !== 'batch'"
v-model:value="action"
<AppForm
:model="formModel"
:rules="rules"
:disabled="operation.pending"
class="mt-4"
aria-label="素材质量操作"
:reset-key="`${open}:${key}:${action}`"
validate-on-change
@invalid="optionsExpanded = ['options']"
@submit="submit"
>
<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"
<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">
<NFormItem path="attempts" :label="videoRepair ? '修复链次数上限' : '每镜最多修复'"
><NInputNumber
v-model:value="attempts"
: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
:min="videoRepair ? 1 : 0"
:step="1"
:input-props="{ 'aria-label': '每镜最多修复次数' }"
/></NFormItem>
<NFormItem v-if="target?.kind === 'batch'" path="limit" label="本批镜头上限"
><NInputNumber
v-model:value="limit"
:disabled="operation.pending"
:min="1"
:step="1"
:input-props="{ 'aria-label': '质量生成镜头上限' }"
/></NFormItem>
</div>
<NCheckbox
v-if="target?.kind === 'batch'"
v-model:checked="force"
:disabled="operation.pending"
class="mt-4"
>重做本集已有有效首帧(通过后替换主图)</NCheckbox
>
<template v-else-if="valid"
>本次最多调用 {{ maxImages }} 次生图、{{ maxValidations }} 次视觉校验,均可能产生费用。</template
<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
>
<template v-if="generating && !videoRepair"
>修复/质量生成通过后可能替换主首帧;失败候选仍会保留,已有视频不会自动更新。</template
<NCollapse
v-if="!videoRepair"
v-model:expanded-names="optionsExpanded"
display-directive="show"
class="mt-4"
>
<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
<NCollapseItem name="options" title="更多参数与模型限制">
<div class="quality-fields">
<NFormItem v-if="target?.kind === 'batch'" path="concurrency" label="批量并发"
><NInputNumber
v-model:value="concurrency"
:disabled="operation.pending"
:min="1"
:step="1"
:input-props="{ 'aria-label': '质量生成并发' }"
/></NFormItem>
<NFormItem v-if="generating" path="width" label="宽度(可选)"
><NInputNumber
v-model:value="width"
:disabled="operation.pending"
:min="1"
:input-props="{ 'aria-label': '质量生成宽度' }"
/></NFormItem>
<NFormItem v-if="generating" path="height" label="高度(可选)"
><NInputNumber
v-model:value="height"
:disabled="operation.pending"
:min="1"
:input-props="{ 'aria-label': '质量生成高度' }"
/></NFormItem>
</div>
<NFormItem class="mt-4 block" path="texts" label="额外允许的画面文字(一行一项,可留空)"
><NInput
v-model:value="texts"
:disabled="operation.pending"
type="textarea"
:autosize="{ minRows: 2, maxRows: 5 }"
:input-props="{ 'aria-label': '额外允许的画面文字' }"
/></NFormItem>
<ModelCapabilities :shot-id="target && target.kind !== 'batch' ? target.shotId : undefined" />
</NCollapseItem>
</NCollapse>
<NAlert type="warning" :show-icon="false" class="mt-4">
<template v-if="videoRepair"
>本次最多提交 1
个视频生成任务,可能产生费用;生成完成不会切换主视频,需再次付费复检通过后才会晋升。</template
>
<template v-else-if="target?.kind === 'video'"
>本次提交一次视频校验请求,后端可能调用多个视觉模型并产生费用。</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>
<div class="dialog-footer mt-4">
<NButton @click="open = false">关闭</NButton>
<NButton
type="primary"
:loading="operation.pending"
:disabled="blocked || !acknowledged || !repairAvailable"
attr-type="submit"
>{{ label }}</NButton
>
</div>
</AppForm>
<p v-if="operation.pending" role="status" class="mt-3 text-xs text-muted">
{{ operation.label }}进行中,请勿重复提交。
</p>
@@ -246,7 +278,7 @@ async function submit() {
}}</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 ? '通过' : '未通过'}`"
><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 }}
@@ -254,8 +286,8 @@ async function submit() {
<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 v-if="target?.kind !== 'batch'" class="mt-3 text-xs text-muted">
校验回执保留在当前会话,可导出;素材列表不提供历史质量结果,刷新浏览器后需重新校验。
</p>
</AppDialog>
</template>