From dd0bd79a35ce0999c02720b600e2fbedf9d50a35 Mon Sep 17 00:00:00 2001 From: GJ Date: Sun, 11 Oct 2026 17:23:14 +0800 Subject: [PATCH] =?UTF-8?q?feat(short-drama-agent-front):=20=E5=AE=8C?= =?UTF-8?q?=E5=96=84=E4=B8=BB=E4=BD=93=E8=BA=AB=E4=BB=BD=E9=AA=A8=E6=9E=B6?= =?UTF-8?q?=E5=B1=8F=E4=B8=8E=E4=BA=A4=E4=BA=92=E5=8F=8D=E9=A6=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ui/RevealImage.vue | 2 + .../production/components/KeyframeDialog.vue | 15 +- src/features/projects/ProjectLayout.vue | 62 +- .../subject-identity/SubjectIdentityPage.vue | 543 +++++++++++------- .../SubjectIdentitySkeleton.vue | 119 ++++ .../components/CastingCandidateDialog.vue | 13 +- .../components/IdentityDetailSkeleton.vue | 104 ++++ .../components/IdentityEditor.vue | 37 +- .../components/IdentityGallery.vue | 159 +++-- src/features/subject-identity/types.ts | 12 + .../subject-identity/useSubjectIdentity.ts | 317 ++++++---- src/features/workflows/ConfirmAction.vue | 30 +- src/features/workflows/operations.ts | 40 +- src/styles/admin.css | 5 + tests/features/projects/access.test.ts | 68 ++- .../features/subject-identity/editor.test.ts | 43 ++ .../subject-identity/identity.test.ts | 50 +- tests/features/workflows/operations.test.ts | 44 ++ tests/features/workflows/pages.test.ts | 308 +++++++++- 19 files changed, 1552 insertions(+), 419 deletions(-) create mode 100644 src/features/subject-identity/SubjectIdentitySkeleton.vue create mode 100644 src/features/subject-identity/components/IdentityDetailSkeleton.vue create mode 100644 tests/features/subject-identity/editor.test.ts diff --git a/src/components/ui/RevealImage.vue b/src/components/ui/RevealImage.vue index 88360c3..c6c213d 100644 --- a/src/components/ui/RevealImage.vue +++ b/src/components/ui/RevealImage.vue @@ -82,6 +82,8 @@ watch(() => props.src, reset) @apply w-full h-full min-w-0 min-h-0; } .reveal-image > .n-image img { + /* 所有图片从顶部展示,裁切缩略图时优先保留人物头部。 */ + object-position: center top; opacity: 0; transition: opacity 220ms cubic-bezier(0.25, 1, 0.5, 1); } diff --git a/src/features/production/components/KeyframeDialog.vue b/src/features/production/components/KeyframeDialog.vue index 2ae88b5..96e3e1c 100644 --- a/src/features/production/components/KeyframeDialog.vue +++ b/src/features/production/components/KeyframeDialog.vue @@ -36,17 +36,14 @@ const imageGenerationOptions = ref({}) const projectAspectRatio = ref('9:16') const canSubmit = computed(() => !props.disabled && confirmed.value) /** 预览仅对应当前镜头、模型和参数;请求过期后不得覆盖新配置。 */ -const previewRequestKey = computed(() => JSON.stringify([ - props.shotId, - imageProvider.value, - imageGenerationOptions.value -])) +const previewRequestKey = computed(() => + JSON.stringify([props.shotId, imageProvider.value, imageGenerationOptions.value]) +) watch(previewRequestKey, () => { preview.value = null previewError.value = '' }) - /** 切换镜头或重新打开时清空费用确认;新图一律先作为候选。 */ async function reset() { confirmed.value = false @@ -164,7 +161,11 @@ async function loadPreview() { -
+
生成规格检查 (() => { return { title: '操作未完成', description: error } }) -/** 镜头工作区的操作结果只在用户发起操作后显示,不在进入页面时重放旧提示。 */ +/** 操作结果只在当前项目收到新响应后通知,不在进入工作区时重放旧提示。 */ const actionMessage = useActionMessage() -/** 分镜和生产页保留必要进度,操作成功或失败改用临时消息。 */ -const quietFeedback = computed(() => currentSection.value === 'production' || currentSection.value === 'storyboard') +/** 分镜、生产和主体身份的操作结果使用临时消息。 */ +const quietFeedback = computed(() => + ['production', 'storyboard', 'subject-identity'].includes(currentSection.value ?? '') +) +/** 主体身份请求进度使用消息,其余工作区继续展示已有任务进度。 */ +const inlinePendingFeedback = computed(() => operation.value.pending && currentSection.value !== 'subject-identity') +/** 当前身份请求的加载消息,完成或离开工作区后立即销毁。 */ +let pendingMessage: MessageReactive | null = null +/** 请求开始即反馈,切换主体时保留请求目标名称,避免无反馈的禁用按钮。 */ +watch( + () => [id.value, currentSection.value, operation.value.pending, operation.value.label] as const, + ([, section, pending, label]) => { + pendingMessage?.destroy() + pendingMessage = null + if (section === 'subject-identity' && pending) + pendingMessage = actionMessage?.loading(`${label || '主体身份操作'},请稍候…`, { duration: 0 }) ?? null + } +) +/** 关闭页面时清理未完成请求的加载消息。 */ +onScopeDispose(() => pendingMessage?.destroy()) /** 只通知仍在当前项目的真实新结果,不把任务提交当作素材生成完成。 */ watch( () => [id.value, operation.value.error, operation.value.notice] as const, ([projectId, error, notice], [previousProject, previousError, previousNotice]) => { - if (!quietFeedback.value || projectId !== previousProject) return + if (projectId !== previousProject) return if (error && error !== previousError) { + if (!quietFeedback.value) return const guide = operationGuide.value - const content = productionMessage(error) + const content = + currentSection.value === 'subject-identity' + ? `${operation.value.label || '主体身份操作'}失败:${productionMessage(error)}` + : productionMessage(error) actionMessage?.error( () => h('div', { class: 'flex max-w-[min(600px,calc(100vw-48px))] flex-wrap items-center gap-3' }, [ @@ -181,9 +205,24 @@ watch( { duration: 8000, closable: true } ) } else if (notice && notice !== previousNotice) { - if (/生成|提交/.test(operation.value.label)) + if (!quietFeedback.value) return + if (operation.value.noticeType) + actionMessage?.[operation.value.noticeType](notice, { + duration: operation.value.noticeType === 'warning' ? 8000 : 4000, + closable: true + }) + else if (operation.value.label === 'AI 生成主体身份') + actionMessage?.success('身份文本已生成并保存。', { duration: 3000, closable: true }) + else if (operation.value.label === '保存主体身份') + actionMessage?.success('主体身份已保存。', { duration: 3000, closable: true }) + else if (/生成|提交/.test(operation.value.label)) actionMessage?.info('任务已提交,完成后会显示结果。', { duration: 4000 }) else actionMessage?.success('操作已完成。', { duration: 3000 }) + // 身份页已消费的反馈立即清除,切换主体或其它工作区都不会遗留旧横幅。 + if (currentSection.value === 'subject-identity') { + operation.value.notice = '' + operation.value.noticeType = null + } } }, { flush: 'post' } @@ -240,7 +279,12 @@ onScopeDispose(() => { @@ -250,7 +294,7 @@ onScopeDispose(() => { >重试读取 - {{ operation.label || '后台制作任务执行中' }}。可切换页面查看结果,请勿重复提交。 @@ -311,6 +355,8 @@ onScopeDispose(() => { + +
diff --git a/src/features/subject-identity/SubjectIdentityPage.vue b/src/features/subject-identity/SubjectIdentityPage.vue index 267a632..34a9585 100644 --- a/src/features/subject-identity/SubjectIdentityPage.vue +++ b/src/features/subject-identity/SubjectIdentityPage.vue @@ -26,8 +26,11 @@ import ConfirmAction from '../workflows/ConfirmAction.vue' import { castingStatusLabel, currentAnchor } from './model' import { useSubjectIdentity } from './useSubjectIdentity' import { useProjectContext } from '../projects/context' +import { useProjectStageAccess } from '../projects/useProjectStageAccess' import StableAnchorQualityDialog from './components/StableAnchorQualityDialog.vue' import IdentityEditor from './components/IdentityEditor.vue' +import SubjectIdentitySkeleton from './SubjectIdentitySkeleton.vue' +import IdentityDetailSkeleton from './components/IdentityDetailSkeleton.vue' import IdentityGallery from './components/IdentityGallery.vue' import IdentityImageDialog from './components/IdentityImageDialog.vue' import CastingCandidateDialog from './components/CastingCandidateDialog.vue' @@ -38,7 +41,6 @@ import type { IdentitySubject } from './types' const route = useRoute() const router = useRouter() const projectContext = useProjectContext() -const stageComplete = computed(() => projectContext.stageReadiness.value?.identity.ready === true) const { projectId, operation, @@ -82,9 +84,31 @@ const { confirmCasting, validateImage, generateStableAnchorQuality, - validationResult, - qualityResult + pendingImageOperation } = useSubjectIdentity() +/** 所有形态图片入口复用侧栏和路由的服务端阶段准入规则。 */ +const stageAccess = useProjectStageAccess(projectId, projectContext.stageReadiness) +/** 当前项目是否允许进入形态图片,以及尚未开放的具体原因。 */ +const subjectImagesAccess = computed(() => stageAccess.sections.value['subject-images']) +/** 当前主体的生成进度或失败原因统一放在两栏上方,切换主体时跟随正式详情更新。 */ +const generationFeedback = computed(() => { + if (!subject.value) return null + if (activeIdentityGeneration.value) + return { + type: 'info' as const, + message: `${subject.value.name} 的身份图片正在生成,刷新页面不会重复提交,请等待当前任务完成。` + } + if (latestIdentityFailure.value) + return { + type: 'error' as const, + message: `最近一次身份图片生成失败:${latestIdentityFailure.value.error || '未返回具体错误'}。可以调整模型参数后重新生成。` + } + return null +}) +/** 首次读取目录才替换整页,刷新已有主体时保留选择与阅读位置。 */ +const initialLoading = computed(() => catalog.loading.value && !catalog.data.value) +/** 切换主体时只替换尚未返回的详情,不遮挡已读取的主体目录。 */ +const detailInitialLoading = computed(() => detail.loading.value && !detail.data.value) const search = ref('') const module = ref('all') const identityBatchModule = ref<'all' | 'character' | 'scene' | 'prop'>('all') @@ -219,7 +243,7 @@ const identityFlow = computed(() => { const character = subject.value?.module === 'character' return [ { label: '身份文本', done: identityTextReady.value }, - { label: character ? '选角候选' : '身份参考图', done: candidateReady.value }, + { label: character ? '角色候选图' : '身份参考图', done: candidateReady.value }, { label: '确认并锁定', done: identityReady.value } ] }) @@ -227,6 +251,7 @@ const currentFlowIndex = computed(() => { const index = identityFlow.value.findIndex(step => !step.done) return index < 0 ? identityFlow.value.length : index }) +/** 按身份文本、角色候选图和母版确认状态说明下一步,明确 AI 生成的是文本还是图片。 */ const nextAction = computed<{ action: IdentityFlowAction; title: string; description: string; label: string }>(() => { if (!hasStyle.value) return { @@ -246,16 +271,16 @@ const nextAction = computed<{ action: IdentityFlowAction; title: string; descrip return { action: 'identity', title: '第 1 步:生成身份文本', - description: '生成稳定身份描述和核心提示词。', - label: '生成身份文本' + description: 'AI 填写下方身份描述和核心提示词,生成后会保存到项目。', + label: 'AI 生成主体身份' } if (!candidateReady.value) return subject.value?.module === 'character' ? { action: 'candidate', - title: '第 2 步:生成选角候选', - description: '生成候选后再确认正式演员。', - label: '生成选角候选' + title: '第 2 步:生成角色候选图', + description: 'AI 根据身份文本生成角色外观图片,选定一张作为角色母版,用于后续图片生成。', + label: 'AI 生成角色候选图' } : { action: 'candidate', @@ -280,7 +305,9 @@ const nextAction = computed<{ action: IdentityFlowAction; title: string; descrip return { action: 'forms', title: '主体身份已完成', - description: '可以继续生成此主体的形态图片。', + description: subjectImagesAccess.value.enabled + ? '可以继续生成此主体的形态图片。' + : `${subjectImagesAccess.value.reason},完成项目准备后可进入形态图片。`, label: '查看形态图片' } }) @@ -290,10 +317,10 @@ function openProfileSettings() { if (route.query.configure !== 'profile') void router.replace({ query: { ...route.query, configure: 'profile' } }) } +/** 根据当前主体的下一步引导执行操作,形态图片跳转仍遵守项目统一准入规则。 */ function runNextAction() { if (nextAction.value.action === 'style') void router.push(`/projects/${projectId.value}/visual-style`) else if (nextAction.value.action === 'profile') openProfileSettings() - else if (nextAction.value.action === 'identity') void generate() else if (nextAction.value.action === 'candidate') { if (subject.value?.module === 'character') castingOpen.value = true else imageOpen.value = true @@ -301,7 +328,7 @@ function runNextAction() { document.querySelector('#identity-reference-gallery')?.scrollIntoView({ behavior: 'smooth', block: 'start' }) } else if (nextAction.value.action === 'lock') { document.querySelector('#identity-lock')?.scrollIntoView({ behavior: 'smooth', block: 'center' }) - } else if (nextAction.value.action === 'forms') { + } else if (nextAction.value.action === 'forms' && subjectImagesAccess.value.enabled) { void router.push({ path: `/projects/${projectId.value}/subject-images`, query: { subjectRef: subject.value?.ref } @@ -311,9 +338,11 @@ function runNextAction() {