feat(short-drama-agent-front): 完善视觉资产审核流程
This commit is contained in:
1 parent
dc8bb17a23
commit
b88ad8770f
45 files changed
+2258
-352
No files matched your search
@@ -34,6 +34,7 @@ import { useSubjectIdentity } from './useSubjectIdentity'
|
||||
import { useProjectContext } from '../projects/context'
|
||||
import { useProjectStageAccess } from '../projects/useProjectStageAccess'
|
||||
import StableAnchorQualityDialog from './components/StableAnchorQualityDialog.vue'
|
||||
import VisualFactRevisionDrawer from './components/VisualFactRevisionDrawer.vue'
|
||||
import IdentityEditor from './components/IdentityEditor.vue'
|
||||
import SubjectIdentitySkeleton from './SubjectIdentitySkeleton.vue'
|
||||
import IdentityDetailSkeleton from './components/IdentityDetailSkeleton.vue'
|
||||
@@ -113,6 +114,21 @@ const identityBatchScopeLabel = computed(
|
||||
/** 单主体稳定母版质量生成弹窗开关。 */
|
||||
const qualityOpen = ref(false)
|
||||
const imageOpen = ref(false)
|
||||
/** 当前主体视觉事实修订抽屉。 */
|
||||
const revisionOpen = ref(false)
|
||||
watch(selectedId, () => {
|
||||
revisionOpen.value = false
|
||||
})
|
||||
|
||||
/** 保存后重读身份、全部形态与制作准入。 */
|
||||
async function refreshVisualFacts() {
|
||||
await Promise.all([
|
||||
detail.refresh(),
|
||||
catalog.refresh(),
|
||||
castingQuery.refresh(),
|
||||
projectContext.refreshStageReadiness()
|
||||
])
|
||||
}
|
||||
/** 从失败记录重试时保留原视角,普通生成仍使用弹窗默认视角。 */
|
||||
const retryImageView = ref<IdentityViewType>()
|
||||
const castingOpen = ref(false)
|
||||
@@ -921,6 +937,25 @@ function runNextAction() {
|
||||
<p v-if="dirty" class="mt-3 text-xs text-muted">
|
||||
请先保存身份修改,再使用 AI 或生成图片。
|
||||
</p>
|
||||
<!-- 以下是未生图主体的原文事实修订入口 -->
|
||||
<NButton
|
||||
class="mt-4 workspace-action-button"
|
||||
:disabled="detailBlocked || dirty"
|
||||
@click="revisionOpen = true"
|
||||
>核对与修订视觉事实</NButton
|
||||
>
|
||||
<VisualFactRevisionDrawer
|
||||
v-if="revisionOpen"
|
||||
:key="subject.id"
|
||||
v-model:open="revisionOpen"
|
||||
:project-id="projectId"
|
||||
:subject-id="subject.id"
|
||||
:subject-name="subject.name"
|
||||
:disabled="detailBlocked || dirty"
|
||||
@saved="refreshVisualFacts"
|
||||
/>
|
||||
|
||||
<!-- 以下是主体身份文本准备 -->
|
||||
<IdentityEditor
|
||||
:saving="isOperationRunning(operation, '保存主体身份')"
|
||||
:key="`${selectedId}:${editorRevision}`"
|
||||
|
||||
@@ -57,20 +57,31 @@ const generationInput = computed<GenerateCastingCandidateInput>(() => ({
|
||||
generationOptions: { ...generationOptions.value }
|
||||
}))
|
||||
/** 选角使用 primary 且不引用当前母版,与正式候选生成一致。 */
|
||||
const { preview, acknowledged, loading, submitting, error, staleNotice, canSubmit, loadPreview, submit } =
|
||||
useImageGenerationPreview({
|
||||
open,
|
||||
target: () => JSON.stringify([props.subjectId, props.profile]),
|
||||
input: () => generationInput.value,
|
||||
disabled: () => props.disabled || !valid.value,
|
||||
load: (input, signal) =>
|
||||
subjectIdentityApi.previewImage(
|
||||
props.subjectId,
|
||||
{ ...input, viewType: 'primary', useAnchorReference: false },
|
||||
signal
|
||||
),
|
||||
generate: input => props.submitGeneration(input)
|
||||
})
|
||||
const {
|
||||
preview,
|
||||
acknowledged,
|
||||
loading,
|
||||
submitting,
|
||||
error,
|
||||
staleNotice,
|
||||
recoveryNotice,
|
||||
canSubmit,
|
||||
loadPreview,
|
||||
submit
|
||||
} = useImageGenerationPreview({
|
||||
open,
|
||||
recoveryTarget: () => (props.subjectId ? 'identity:' + props.subjectId : ''),
|
||||
target: () => JSON.stringify([props.subjectId, props.profile]),
|
||||
input: () => generationInput.value,
|
||||
disabled: () => props.disabled || !valid.value,
|
||||
load: (input, signal) =>
|
||||
subjectIdentityApi.previewImage(
|
||||
props.subjectId,
|
||||
{ ...input, viewType: 'primary', useAnchorReference: false },
|
||||
signal
|
||||
),
|
||||
generate: input => props.submitGeneration(input)
|
||||
})
|
||||
/** 当前描述草稿对应的表单模型。 */
|
||||
const formModel = computed(() => ({ prompt: prompt.value }))
|
||||
</script>
|
||||
@@ -94,7 +105,7 @@ const formModel = computed(() => ({ prompt: prompt.value }))
|
||||
>
|
||||
<ContextNotice type="info" :show-icon="false" class="text-xs">
|
||||
AI
|
||||
会根据角色身份、项目视觉风格和选角要求生成一张新的候选图,不会复用当前身份母版。生成完成后,请在图库点击“确认选角并锁定”,将图片设为角色母版。
|
||||
会根据角色身份、项目视觉风格和选角要求生成一张新的候选图,不会复用当前身份母版。生成后请在图库审核候选,通过后再确认选角并锁定身份。
|
||||
</ContextNotice>
|
||||
<NFormItem
|
||||
class="block"
|
||||
@@ -130,7 +141,7 @@ const formModel = computed(() => ({ prompt: prompt.value }))
|
||||
:loading="loading"
|
||||
:disabled="disabled || submitting || !valid"
|
||||
:error="error"
|
||||
:stale-notice="staleNotice"
|
||||
:stale-notice="staleNotice || recoveryNotice"
|
||||
@load="loadPreview"
|
||||
/>
|
||||
<NCheckbox
|
||||
|
||||
@@ -129,6 +129,7 @@ defineExpose({ openCandidates, closeCandidates })
|
||||
:identity-locked="identityLocked"
|
||||
:disabled="disabled"
|
||||
:pending-operation="pendingOperation"
|
||||
:validation-result="validationResult"
|
||||
:retry-disabled-reason="retryDisabledReason"
|
||||
:active="true"
|
||||
:description="displayImage.isAnchor ? anchorDescription : undefined"
|
||||
@@ -142,6 +143,7 @@ defineExpose({ openCandidates, closeCandidates })
|
||||
v-if="validationResult && images.some(image => image.id === validationResult?.imageId) && !candidatesOpen"
|
||||
class="mt-5"
|
||||
:result="validationResult"
|
||||
:module="module"
|
||||
/>
|
||||
<!-- 以下是与镜头生产一致的底部图片操作模块 -->
|
||||
<div class="identity-gallery-actions">
|
||||
@@ -169,6 +171,7 @@ defineExpose({ openCandidates, closeCandidates })
|
||||
:identity-locked="identityLocked"
|
||||
:disabled="disabled"
|
||||
:pending-operation="pendingOperation"
|
||||
:validation-result="validationResult"
|
||||
:retry-disabled-reason="retryDisabledReason"
|
||||
:active="candidatesOpen"
|
||||
@anchor="emit('anchor', $event)"
|
||||
@@ -181,6 +184,7 @@ defineExpose({ openCandidates, closeCandidates })
|
||||
v-if="validationResult && managedCandidates.some(image => image.id === validationResult?.imageId)"
|
||||
class="mt-5"
|
||||
:result="validationResult"
|
||||
:module="module"
|
||||
/>
|
||||
</AppDialog>
|
||||
</section>
|
||||
|
||||
@@ -5,7 +5,8 @@ import { AppDialog, AssetImage, AssetOpenLink, StatusBadge } from '../../../comp
|
||||
import { formatDate } from '../../../lib/format'
|
||||
import ConfirmAction from '../../workflows/ConfirmAction.vue'
|
||||
import { canBeAnchor, identityViewLabels } from '../model'
|
||||
import type { IdentityImage, IdentityImageOperation } from '../types'
|
||||
import { imageValidationPassed } from '../../subject-images/validation'
|
||||
import type { IdentityImage, IdentityImageOperation, IdentityValidationResult } from '../types'
|
||||
|
||||
/** 母版与候选共用图片卡片,操作始终绑定卡片的正式图片编号。 */
|
||||
const props = defineProps<{
|
||||
@@ -27,6 +28,8 @@ const props = defineProps<{
|
||||
description?: string
|
||||
/** 候选管理是否可见,关闭管理弹窗时同步收起错误浮层。 */
|
||||
active?: boolean
|
||||
/** 只用于同一候选的已知审核证据。 */
|
||||
validationResult?: IdentityValidationResult | null
|
||||
}>()
|
||||
/** 卡片只请求父页面执行操作,不直接调用模型或修改母版。 */
|
||||
const emit = defineEmits<{
|
||||
@@ -51,12 +54,19 @@ const confirmLoading = computed(
|
||||
const validateLoading = computed(
|
||||
() => props.pendingOperation?.imageId === props.image.id && props.pendingOperation.kind === 'validate'
|
||||
)
|
||||
/** 当前图片需要具备刚刚读取的明确审核结果。 */
|
||||
const quality = computed(() =>
|
||||
props.validationResult?.imageId === props.image.id
|
||||
? imageValidationPassed(props.validationResult, props.module)
|
||||
: null
|
||||
)
|
||||
/** 只有完成的 primary 可以确认,已锁定的当前母版不提供重复确认。 */
|
||||
const canSelect = computed(
|
||||
() =>
|
||||
!props.disabled &&
|
||||
!props.pendingOperation &&
|
||||
canBeAnchor(props.image) &&
|
||||
quality.value === true &&
|
||||
(!props.image.isAnchor || (character.value && !props.identityLocked))
|
||||
)
|
||||
/** 卡片标识区分身份母版、母版候选和辅助视角,不重复强调当前状态。 */
|
||||
@@ -174,6 +184,13 @@ function regenerate() {
|
||||
</NScrollbar>
|
||||
</NPopover>
|
||||
<NTag size="small" :bordered="false">{{ imageLabel }}</NTag>
|
||||
<NTag
|
||||
v-if="image.status === 'completed' && !image.isAnchor && image.viewType === 'primary'"
|
||||
size="small"
|
||||
:bordered="false"
|
||||
>
|
||||
{{ quality === null ? '待审核' : quality ? '审核通过' : '审核未通过或待复核' }}
|
||||
</NTag>
|
||||
<!-- 以下是母版身份锁定状态模块,紧邻图片下方的身份母版标签。 -->
|
||||
<NTag
|
||||
v-if="image.isAnchor"
|
||||
@@ -221,8 +238,8 @@ function regenerate() {
|
||||
<ConfirmAction
|
||||
:key="image.id"
|
||||
label="校验此身份图片"
|
||||
:description="`将校验图片 ${image.id},会调用视觉模型并可能产生费用,不会切换母版。`"
|
||||
:disabled="disabled || !!pendingOperation"
|
||||
description="将核对当前候选,可能调用视觉模型并产生费用。审核后仍需人工确认母版。"
|
||||
:disabled="disabled || !!pendingOperation || image.viewType !== 'primary'"
|
||||
:loading="validateLoading"
|
||||
acknowledgement
|
||||
@confirm="emit('validate', image.id)"
|
||||
@@ -241,12 +258,16 @@ function regenerate() {
|
||||
>
|
||||
<!-- 以下是身份母版采纳的费用与门禁说明模块 -->
|
||||
<p class="text-sm leading-7 text-muted">
|
||||
确认时会核对当前来源和质量,可能调用视觉模型并产生审核费用。通过后才锁定并采纳;未通过时保留旧母版,不自动追加生图。
|
||||
{{
|
||||
character
|
||||
? '将复核已保存的质量证据,通过后锁定并采纳。'
|
||||
: '将复核已保存的质量证据。若审核记录失效,服务可能再次调用视觉模型并产生费用。'
|
||||
}}
|
||||
</p>
|
||||
<template #footer>
|
||||
<NButton @click="confirming = false">取消</NButton>
|
||||
<NButton :disabled="!canSelect" type="primary" @click="chooseAnchor">{{
|
||||
character ? '确认演员选择' : '确认切换身份母版'
|
||||
character ? '确认演员选择' : '确认费用并切换母版'
|
||||
}}</NButton>
|
||||
</template>
|
||||
</AppDialog>
|
||||
|
||||
@@ -110,11 +110,13 @@ const {
|
||||
submitting,
|
||||
error: previewError,
|
||||
staleNotice,
|
||||
recoveryNotice,
|
||||
canSubmit,
|
||||
loadPreview,
|
||||
submit
|
||||
} = useImageGenerationPreview({
|
||||
open,
|
||||
recoveryTarget: () => (props.subjectId ? 'identity:' + props.subjectId : ''),
|
||||
target: () =>
|
||||
JSON.stringify([props.subjectId, props.images.filter(image => image.status === 'completed'), props.profile]),
|
||||
input: () => generationInput.value,
|
||||
@@ -229,7 +231,7 @@ const rules = {
|
||||
:loading="previewLoading"
|
||||
:disabled="disabled || submitting || !valid"
|
||||
:error="previewError"
|
||||
:stale-notice="staleNotice"
|
||||
:stale-notice="staleNotice || recoveryNotice"
|
||||
@load="loadPreview"
|
||||
/>
|
||||
<NCheckbox
|
||||
|
||||
@@ -0,0 +1,334 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { NButton, NCheckbox, NCollapse, NCollapseItem, NInput, NSelect } from 'naive-ui'
|
||||
import { AppDrawer } from '../../../components/ui'
|
||||
import ContextNotice from '../../../components/ui/ContextNotice.vue'
|
||||
import RawDataDetails from '../../../components/ui/RawDataDetails.vue'
|
||||
import WorkspaceSectionHeading from '../../../components/ui/WorkspaceSectionHeading.vue'
|
||||
import { useQuery } from '../../../composables/useQuery'
|
||||
import { ApiError, errorMessage } from '../../../lib/http'
|
||||
import { projectsApi } from '../../projects/api'
|
||||
import { getOperation, runOperation } from '../../workflows/operations'
|
||||
import { visualFactsApi, type VisualFactFormEdit, type VisualFactRevision } from '../visual-facts'
|
||||
|
||||
/** 仅修订当前项目中尚未生图的正式主体。 */
|
||||
const props = defineProps<{
|
||||
/** 正式项目编号。 */
|
||||
projectId: string
|
||||
/** 正式主体编号。 */
|
||||
subjectId: string
|
||||
/** 主体名称。 */
|
||||
subjectName: string
|
||||
/** 项目当前禁止写入。 */
|
||||
disabled: boolean
|
||||
}>()
|
||||
/** 全屏修订界面可见状态。 */
|
||||
const open = defineModel<boolean>('open', { default: false })
|
||||
/** 保存后刷新身份、形态和制作状态。 */
|
||||
const emit = defineEmits<{ saved: [] }>()
|
||||
/** 请求只绑定当前打开的项目和主体。 */
|
||||
const key = computed(() => (open.value ? JSON.stringify([props.projectId, props.subjectId]) : ''))
|
||||
/** 同时读取正式来源正文及事实版本,来源选择器只显示双方能绑定的记录。 */
|
||||
const query = useQuery(key, async (value, signal) => {
|
||||
if (!value) return null
|
||||
const [projectId, subjectId] = JSON.parse(value) as [string, string]
|
||||
const [preview, project] = await Promise.all([
|
||||
visualFactsApi.preview(subjectId, signal),
|
||||
projectsApi.detail(projectId, signal)
|
||||
])
|
||||
if (preview.subjectId !== subjectId || project.id !== projectId) throw new Error('资料与当前主体不匹配。')
|
||||
return { preview, project }
|
||||
})
|
||||
/** 原始主题以空选择区分,避免与真实剧集编号混用。 */
|
||||
const sourceId = ref<string | null>(null)
|
||||
/** 逐字原文由操作者明确填写。 */
|
||||
const quote = ref('')
|
||||
/** 主体稳定外观和叙事描述分别保留。 */
|
||||
const appearance = ref('')
|
||||
/** 可选修改的主体叙事说明。 */
|
||||
const description = ref('')
|
||||
/** 所有现存形态的人工草稿。 */
|
||||
const forms = ref<VisualFactFormEdit[]>([])
|
||||
/** 人工审阅人。 */
|
||||
const operator = ref('')
|
||||
/** 可追溯的人工修订理由。 */
|
||||
const reason = ref('')
|
||||
/** 只对本轮草稿和所选原文生效的明确确认。 */
|
||||
const confirmed = ref(false)
|
||||
/** 保存期间禁止重复提交或关闭。 */
|
||||
const saving = ref(false)
|
||||
/** 首次提交后显示完整校验。 */
|
||||
const attempted = ref(false)
|
||||
/** 当前写入失败说明。 */
|
||||
const conflict = ref('')
|
||||
/** 上次发生冲突的输入供人工对照,不作为新版本自动提交。 */
|
||||
const previousDraft = ref<VisualFactRevision | null>(null)
|
||||
/** 正式来源文本和版本直接从两个只读结果匹配。 */
|
||||
const sources = computed(() => {
|
||||
const data = query.data.value
|
||||
if (!data) return []
|
||||
const episodes = data.preview.sources.episodes.flatMap(source => {
|
||||
const episode = data.project.episodes.find(item => item.id === source.id && item.episode === source.episode)
|
||||
return episode
|
||||
? [
|
||||
{
|
||||
value: source.id,
|
||||
label: `第 ${source.episode} 集 · ${episode.title}`,
|
||||
text: episode.content,
|
||||
fingerprint: source.fingerprint
|
||||
}
|
||||
]
|
||||
: []
|
||||
})
|
||||
return [
|
||||
{
|
||||
value: 'topic',
|
||||
label: '原始主题',
|
||||
text: data.project.topic,
|
||||
fingerprint: data.preview.sources.topicFingerprint
|
||||
},
|
||||
...episodes
|
||||
]
|
||||
})
|
||||
/** 当前原文展示与提交使用同一正式来源。 */
|
||||
const source = computed(() => sources.value.find(item => item.value === sourceId.value))
|
||||
watch(
|
||||
() => query.data.value,
|
||||
data => {
|
||||
const facts = data?.preview.facts
|
||||
appearance.value = facts?.appearancePrompt ?? ''
|
||||
description.value = facts?.description ?? ''
|
||||
forms.value =
|
||||
facts?.forms.map(form => ({
|
||||
formId: form.id,
|
||||
description: form.description ?? '',
|
||||
appearancePrompt: form.appearancePrompt ?? ''
|
||||
})) ?? []
|
||||
sourceId.value = null
|
||||
operator.value = ''
|
||||
reason.value = ''
|
||||
attempted.value = false
|
||||
confirmed.value = false
|
||||
}
|
||||
)
|
||||
watch(sourceId, () => {
|
||||
quote.value = ''
|
||||
})
|
||||
watch(
|
||||
[appearance, description, forms, sourceId, quote, operator, reason],
|
||||
() => {
|
||||
confirmed.value = false
|
||||
},
|
||||
{ deep: true, flush: 'sync' }
|
||||
)
|
||||
watch(key, () => {
|
||||
conflict.value = ''
|
||||
previousDraft.value = null
|
||||
})
|
||||
|
||||
/** 提交时校验全部形态和逐字证据,服务事务再次核对真实原文。 */
|
||||
const validationError = computed(() => {
|
||||
if (
|
||||
!appearance.value.trim() ||
|
||||
!forms.value.length ||
|
||||
forms.value.length > 30 ||
|
||||
forms.value.some(form => !form.description.trim() || !form.appearancePrompt.trim())
|
||||
)
|
||||
return '请填写主体外观和所有形态的说明与外观。'
|
||||
if (!source.value || !quote.value.trim() || !source.value.text.includes(quote.value.trim()))
|
||||
return '请选择原文来源,并粘贴其中逐字一致的引文。'
|
||||
if (!operator.value.trim() || !reason.value.trim()) return '请填写修订人及修订原因。'
|
||||
return ''
|
||||
})
|
||||
|
||||
/** 提交当前版本一次,409 只重新读取资料,要求人工重新核对。 */
|
||||
async function save() {
|
||||
if (
|
||||
saving.value ||
|
||||
props.disabled ||
|
||||
query.loading.value ||
|
||||
query.error.value ||
|
||||
!query.data.value?.preview.canRevise
|
||||
)
|
||||
return
|
||||
attempted.value = true
|
||||
const selected = source.value
|
||||
if (validationError.value || !selected || !confirmed.value) return
|
||||
const { projectId, subjectId } = props
|
||||
const target = key.value
|
||||
const preview = query.data.value.preview
|
||||
const evidence = { quote: quote.value.trim(), expectedFingerprint: selected.fingerprint }
|
||||
const input: VisualFactRevision = {
|
||||
expectedVersion: preview.version,
|
||||
appearancePrompt: appearance.value.trim(),
|
||||
description: description.value.trim() || undefined,
|
||||
forms: forms.value.map(form => ({
|
||||
formId: form.formId,
|
||||
description: form.description.trim(),
|
||||
appearancePrompt: form.appearancePrompt.trim()
|
||||
})),
|
||||
source:
|
||||
selected.value === 'topic'
|
||||
? { kind: 'topic', ...evidence }
|
||||
: { kind: 'episode', episodeId: selected.value, ...evidence },
|
||||
operator: operator.value.trim(),
|
||||
reason: reason.value.trim()
|
||||
}
|
||||
saving.value = true
|
||||
conflict.value = ''
|
||||
try {
|
||||
const ok = await runOperation(
|
||||
projectId,
|
||||
'修订主体视觉事实',
|
||||
async () => {
|
||||
const result = await visualFactsApi.revise(subjectId, input)
|
||||
if (result.subjectId !== subjectId || !result.revisionId)
|
||||
throw new Error('保存结果待核对,请刷新资料。')
|
||||
},
|
||||
{ type: 'success', content: '视觉事实已保存。需要时可重新准备身份和形态描述。' }
|
||||
)
|
||||
if (key.value !== target) return
|
||||
if (ok) {
|
||||
emit('saved')
|
||||
open.value = false
|
||||
} else {
|
||||
const cause = getOperation(projectId).cause
|
||||
confirmed.value = false
|
||||
if (cause instanceof ApiError && cause.status === 409) {
|
||||
previousDraft.value = input
|
||||
conflict.value = `${errorMessage(cause)} 将重新读取当前资料,请复核后再提交。`
|
||||
await query.refresh()
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AppDrawer
|
||||
v-model:open="open"
|
||||
:title="`修订视觉事实 · ${subjectName}`"
|
||||
description="依据原文纠正当前主体和全部形态。保存后需要重新准备受影响的身份和画面描述。"
|
||||
:busy="saving"
|
||||
>
|
||||
<!-- 以下是当前可修订性和版本冲突反馈 -->
|
||||
<div class="space-y-5">
|
||||
<ContextNotice v-if="conflict" type="warning" :show-icon="false">{{ conflict }}</ContextNotice>
|
||||
<RawDataDetails v-if="previousDraft" title="查看冲突前填写的修订与引文" :value="previousDraft" />
|
||||
<ContextNotice v-if="query.error.value" type="error" :show-icon="false">{{
|
||||
query.error.value
|
||||
}}</ContextNotice>
|
||||
<p v-else-if="query.loading.value" class="text-sm text-muted">正在读取事实与原文…</p>
|
||||
<p v-else-if="query.data.value && !query.data.value.preview.canRevise" class="text-sm text-muted">
|
||||
此主体当前无法修订。请检查是否已有身份或形态图片、身份已锁定,或项目还有任务进行中。
|
||||
</p>
|
||||
<template v-else-if="query.data.value">
|
||||
<!-- 以下是主体与全部正式形态的事实编辑 -->
|
||||
<section class="space-y-4">
|
||||
<WorkspaceSectionHeading
|
||||
title="主体与形态"
|
||||
description="保留每个形态,分别填写可从原文支持的事实。"
|
||||
/>
|
||||
<label class="block text-sm"
|
||||
>主体说明<NInput
|
||||
v-model:value="description"
|
||||
class="mt-2"
|
||||
type="textarea"
|
||||
:maxlength="12000"
|
||||
:disabled="saving"
|
||||
/></label>
|
||||
<label class="block text-sm"
|
||||
>主体稳定外观<NInput
|
||||
v-model:value="appearance"
|
||||
class="mt-2"
|
||||
type="textarea"
|
||||
:maxlength="12000"
|
||||
:disabled="saving"
|
||||
/></label>
|
||||
<article v-for="(form, index) in forms" :key="form.formId" class="space-y-3">
|
||||
<h3 class="text-sm font-medium">{{ query.data.value.preview.facts.forms[index]?.name }}</h3>
|
||||
<label class="block text-sm"
|
||||
>形态说明<NInput
|
||||
v-model:value="form.description"
|
||||
class="mt-2"
|
||||
type="textarea"
|
||||
:maxlength="12000"
|
||||
:disabled="saving"
|
||||
/></label>
|
||||
<label class="block text-sm"
|
||||
>形态外观<NInput
|
||||
v-model:value="form.appearancePrompt"
|
||||
class="mt-2"
|
||||
type="textarea"
|
||||
:maxlength="12000"
|
||||
:disabled="saving"
|
||||
/></label>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<!-- 以下是可追溯的原文、修订原因和人工确认 -->
|
||||
<section class="space-y-4">
|
||||
<WorkspaceSectionHeading
|
||||
title="原文证据"
|
||||
description="从原始主题或正式剧本中引用能直接支持本次修订的原句。"
|
||||
/>
|
||||
<NSelect
|
||||
v-model:value="sourceId"
|
||||
:options="sources"
|
||||
placeholder="选择原文来源"
|
||||
:disabled="saving"
|
||||
aria-label="原文来源"
|
||||
/>
|
||||
<NCollapse v-if="source" :key="source.value">
|
||||
<NCollapseItem name="original" title="查看完整原文">
|
||||
<p class="max-h-64 overflow-y-auto whitespace-pre-wrap wrap-anywhere text-sm leading-7">
|
||||
{{ source.text }}
|
||||
</p>
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
<label class="block text-sm"
|
||||
>逐字引文<NInput
|
||||
v-model:value="quote"
|
||||
class="mt-2"
|
||||
type="textarea"
|
||||
:maxlength="6000"
|
||||
:disabled="saving"
|
||||
/></label>
|
||||
<label class="block text-sm"
|
||||
>修订人<NInput v-model:value="operator" class="mt-2" :maxlength="120" :disabled="saving"
|
||||
/></label>
|
||||
<label class="block text-sm"
|
||||
>修订原因<NInput
|
||||
v-model:value="reason"
|
||||
class="mt-2"
|
||||
type="textarea"
|
||||
:maxlength="4000"
|
||||
:disabled="saving"
|
||||
/></label>
|
||||
<NCheckbox v-model:checked="confirmed" :disabled="saving"
|
||||
>我已核对原文和全部形态,并确认保存本次修订。</NCheckbox
|
||||
>
|
||||
<p v-if="attempted && validationError" role="alert" class="text-sm text-danger">
|
||||
{{ validationError }}
|
||||
</p>
|
||||
</section>
|
||||
</template>
|
||||
</div>
|
||||
<template #footer>
|
||||
<NButton :disabled="saving" @click="open = false">关闭</NButton>
|
||||
<NButton
|
||||
v-if="query.data.value?.preview.canRevise"
|
||||
type="primary"
|
||||
:loading="saving"
|
||||
:disabled="disabled || !confirmed || query.loading.value || !!query.error.value"
|
||||
@click="save"
|
||||
>保存修订</NButton
|
||||
>
|
||||
<NButton v-else-if="query.error.value" :loading="query.loading.value" @click="query.refresh"
|
||||
>重新读取</NButton
|
||||
>
|
||||
</template>
|
||||
</AppDrawer>
|
||||
</template>
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ApiError } from '../../lib/http'
|
||||
import { imageValidationPassed } from '../subject-images/validation'
|
||||
import type { ImageGenerationSubmission } from '../subject-images/generation-preview'
|
||||
import { computed, ref, shallowRef, watch } from 'vue'
|
||||
@@ -271,9 +272,18 @@ export function useSubjectIdentity() {
|
||||
*/
|
||||
async function validateImage(imageId: string) {
|
||||
const image = images.value.find(item => item.id === imageId)
|
||||
if (detailBlocked.value || !subject.value || image?.status !== 'completed' || !image.imageUrl) return
|
||||
if (
|
||||
detailBlocked.value ||
|
||||
!subject.value ||
|
||||
image?.viewType !== 'primary' ||
|
||||
image.status !== 'completed' ||
|
||||
!image.imageUrl
|
||||
)
|
||||
return
|
||||
const id = subject.value.id
|
||||
const name = subject.value.name
|
||||
const project = projectId.value
|
||||
const module = subject.value.module
|
||||
delete validationResults.value[id]
|
||||
const sourceKey = validationSourceKey.value
|
||||
await runImageOperation(
|
||||
@@ -284,12 +294,20 @@ export function useSubjectIdentity() {
|
||||
const result = await subjectIdentityApi.validateImage(id, imageId)
|
||||
if (result.subjectId !== id || result.imageId !== imageId)
|
||||
throw new Error('身份校验回执与提交目标不匹配')
|
||||
if (validationSourceKey.value === sourceKey) validationResults.value[id] = result
|
||||
if (validationSourceKey.value === sourceKey) {
|
||||
await refreshImageConfirmation(project, id)
|
||||
if (
|
||||
projectId.value === project &&
|
||||
selectedId.value === id &&
|
||||
images.value.some(item => item.id === imageId && item.imageUrl === image.imageUrl)
|
||||
)
|
||||
validationResults.value[id] = result
|
||||
}
|
||||
return result
|
||||
},
|
||||
result => ({
|
||||
type: imageValidationPassed(result) ? 'success' : 'warning',
|
||||
content: `${name} 的身份图片校验${imageValidationPassed(result) ? '通过' : '未通过或待复核'}:${result.summary}`
|
||||
type: imageValidationPassed(result, module) ? 'success' : 'warning',
|
||||
content: `${name} 的身份图片校验${imageValidationPassed(result, module) ? '通过' : '未通过或待复核'}:${result.summary}`
|
||||
})
|
||||
)
|
||||
}
|
||||
@@ -520,7 +538,7 @@ export function useSubjectIdentity() {
|
||||
image.identityId !== identityId ||
|
||||
!['pending', 'generating'].includes(image.status)
|
||||
) {
|
||||
throw new Error(image?.error || '身份参考图任务未成功创建,请刷新后重试。')
|
||||
throw new ApiError('身份参考图任务回执待核对,请刷新候选和任务。', 202)
|
||||
}
|
||||
if (projectId.value === project && selectedId.value === id) {
|
||||
// 先展示真实回执中的生成记录,后续读取失败也能保留状态并继续轮询。
|
||||
@@ -555,7 +573,7 @@ export function useSubjectIdentity() {
|
||||
async () => {
|
||||
const image = await subjectIdentityApi.generateCastingCandidate(id, input)
|
||||
if (!image || image.identityId !== identityId || !['pending', 'generating'].includes(image.status)) {
|
||||
throw new Error(image?.error || '选角候选任务未成功创建,请刷新后重试。')
|
||||
throw new ApiError('角色候选任务回执待核对,请刷新候选和任务。', 202)
|
||||
}
|
||||
if (projectId.value === project)
|
||||
await Promise.all([
|
||||
@@ -612,14 +630,16 @@ export function useSubjectIdentity() {
|
||||
(subject.value?.module !== 'scene' && subject.value?.module !== 'prop') ||
|
||||
!identity.value ||
|
||||
!image ||
|
||||
!canBeAnchor(image)
|
||||
!canBeAnchor(image) ||
|
||||
validationResult.value?.imageId !== imageId ||
|
||||
!imageValidationPassed(validationResult.value, subject.value.module)
|
||||
)
|
||||
return
|
||||
const subjectId = subject.value.id
|
||||
const identityId = identity.value.id
|
||||
const project = projectId.value
|
||||
const name = subject.value.name
|
||||
await runImageOperation(
|
||||
const confirmed = await runImageOperation(
|
||||
'confirm',
|
||||
imageId,
|
||||
`确认 ${name} 身份母版`,
|
||||
@@ -641,6 +661,10 @@ export function useSubjectIdentity() {
|
||||
},
|
||||
{ type: 'success', content: `${name} 的身份母版已确认并锁定。` }
|
||||
)
|
||||
if (!confirmed) {
|
||||
delete validationResults.value[subjectId]
|
||||
await refreshImageConfirmation(project, subjectId)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -656,14 +680,16 @@ export function useSubjectIdentity() {
|
||||
!!castingQuery.error.value ||
|
||||
!identity.value ||
|
||||
!image ||
|
||||
!canBeAnchor(image)
|
||||
!canBeAnchor(image) ||
|
||||
validationResult.value?.imageId !== imageId ||
|
||||
!imageValidationPassed(validationResult.value, subject.value.module)
|
||||
)
|
||||
return
|
||||
const subjectId = subject.value.id
|
||||
const identityId = identity.value.id
|
||||
const project = projectId.value
|
||||
const name = subject.value.name
|
||||
await runImageOperation(
|
||||
const confirmed = await runImageOperation(
|
||||
'confirm',
|
||||
imageId,
|
||||
`确认 ${name} 角色选角`,
|
||||
@@ -685,6 +711,10 @@ export function useSubjectIdentity() {
|
||||
},
|
||||
{ type: 'success', content: `${name} 的角色选角已确认,身份已锁定。` }
|
||||
)
|
||||
if (!confirmed) {
|
||||
delete validationResults.value[subjectId]
|
||||
await refreshImageConfirmation(project, subjectId)
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
import { request } from '../../lib/http'
|
||||
|
||||
/** 修订必须完整保留每个已存在形态的绑定。 */
|
||||
export interface VisualFactFormEdit {
|
||||
/** 正式形态编号。 */
|
||||
formId: string
|
||||
/** 纠正后的形态说明。 */
|
||||
description: string
|
||||
/** 纠正后的形态外观。 */
|
||||
appearancePrompt: string
|
||||
}
|
||||
|
||||
/** 只读修订预览。 */
|
||||
export interface VisualFactPreview {
|
||||
/** 正式主体编号。 */
|
||||
subjectId: string
|
||||
/** 当前事实的并发版本。 */
|
||||
version: string
|
||||
/** 当前允许人工修订。 */
|
||||
canRevise: boolean
|
||||
/** 当前正式主体和全部形态。 */
|
||||
facts: {
|
||||
/** 主体说明。 */
|
||||
description: string | null
|
||||
/** 主体稳定外观。 */
|
||||
appearancePrompt: string | null
|
||||
/** 已存在的正式形态。 */
|
||||
forms: Array<{
|
||||
/** 正式形态编号。 */
|
||||
id: string
|
||||
/** 形态显示名称。 */
|
||||
name: string
|
||||
/** 当前形态说明。 */
|
||||
description: string | null
|
||||
/** 当前形态外观。 */
|
||||
appearancePrompt: string | null
|
||||
}>
|
||||
}
|
||||
/** 允许用于举证的正式原文版本。 */
|
||||
sources: {
|
||||
/** 原始主题的版本。 */
|
||||
topicFingerprint: string
|
||||
/** 正式剧集的原文版本。 */
|
||||
episodes: Array<{
|
||||
/** 正式剧集编号。 */
|
||||
id: string
|
||||
/** 用户可见的集数。 */
|
||||
episode: number
|
||||
/** 正文版本。 */
|
||||
fingerprint: string
|
||||
}>
|
||||
}
|
||||
}
|
||||
|
||||
/** 原文引证含同一来源的版本,原文变化由服务事务复核。 */
|
||||
type VisualFactSource = {
|
||||
/** 最新预览中的原文版本。 */
|
||||
expectedFingerprint: string
|
||||
/** 用户核对并填写的逐字原文。 */
|
||||
quote: string
|
||||
} & ({ /** 原始主题。 */ kind: 'topic' } | { /** 正式剧集。 */ kind: 'episode'; /** 剧集编号。 */ episodeId: string })
|
||||
|
||||
/** 明确的人工修订请求,沿用正式接口的严格字段。 */
|
||||
export interface VisualFactRevision {
|
||||
/** 最新事实版本。 */
|
||||
expectedVersion: string
|
||||
/** 主体稳定外观。 */
|
||||
appearancePrompt: string
|
||||
/** 可选修订主体说明。 */
|
||||
description?: string
|
||||
/** 全部现有形态。 */
|
||||
forms: VisualFactFormEdit[]
|
||||
/** 用户核对的原文证据。 */
|
||||
source: VisualFactSource
|
||||
/** 实际修订人员。 */
|
||||
operator: string
|
||||
/** 本次修订原因。 */
|
||||
reason: string
|
||||
}
|
||||
|
||||
/** 正式修订 API,读取免费,保存人工输入后不会触发生成。 */
|
||||
export const visualFactsApi = {
|
||||
/**
|
||||
* 读取当前事实及可修订性。
|
||||
* @param subjectId 正式主体编号
|
||||
* @param signal 关闭抽屉时取消读取
|
||||
* @returns 当前修订预览
|
||||
*/
|
||||
preview: (subjectId: string, signal?: AbortSignal) =>
|
||||
request<VisualFactPreview>(`/subjects/${encodeURIComponent(subjectId)}/visual-facts/revision-preview`, {
|
||||
signal
|
||||
}),
|
||||
/**
|
||||
* 原子保存本次人工修订。
|
||||
* @param subjectId 正式主体编号
|
||||
* @param input 人工确认的事实、全部形态和来源
|
||||
* @returns 已保存的正式修订回执
|
||||
*/
|
||||
revise: (subjectId: string, input: VisualFactRevision) =>
|
||||
request<{ revisionId: string; subjectId: string; version: string; formIds: string[] }>(
|
||||
`/subjects/${encodeURIComponent(subjectId)}/visual-facts/revisions`,
|
||||
{ method: 'POST', body: input }
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user