feat(short-drama-agent-front): 优化身份管理与镜头素材布局
This commit is contained in:
1 parent
dd0bd79a35
commit
3d2c198e52
14 files changed
+1060
-629
No files matched your search
@@ -9,6 +9,7 @@ import { AssetImage } from '../../../components/ui'
|
||||
import { usePolling } from '../../../composables/usePolling'
|
||||
import { useQuery } from '../../../composables/useQuery'
|
||||
import { errorMessage } from '../../../lib/http'
|
||||
import { candidateDialogWidth } from '../../../lib/candidate-layout'
|
||||
import type { DesignedShot } from '../../storyboard/types'
|
||||
import { storyboardApi } from '../../storyboard/api'
|
||||
import ConfirmAction from '../../workflows/ConfirmAction.vue'
|
||||
@@ -308,15 +309,6 @@ async function refreshAfterReview() {
|
||||
await refreshAll()
|
||||
}
|
||||
const keyframeCandidates = computed(() => keyframes.value.filter(item => item.id !== currentKeyframe.value?.id))
|
||||
/**
|
||||
* 按候选数量计算弹窗宽度,每项 260px,每行最多五项,预留间距和左右内边距。
|
||||
* @param count 当前候选数量
|
||||
* @returns 弹窗的期望宽度,单位为像素
|
||||
*/
|
||||
function candidateDialogWidth(count: number): number {
|
||||
const columns = Math.max(1, Math.min(5, count))
|
||||
return columns * 260 + (columns - 1) * 12 + 48
|
||||
}
|
||||
/** 首帧弹窗按当前候选数适配一至五列,实际宽度由公共弹窗限制在视口内。 */
|
||||
const keyframeCandidatesWidth = computed(() => candidateDialogWidth(keyframeCandidates.value.length))
|
||||
/** 视频弹窗与首帧共用固定列宽,少量候选不留多余的整列空白。 */
|
||||
@@ -953,9 +945,10 @@ defineExpose({ inspectSpecs, inspecting })
|
||||
.keyframe-card .asset-image {
|
||||
@apply aspect-square rounded-none;
|
||||
}
|
||||
/* 素材按可用宽度等分列,自动收起空列,让首尾卡片与内容区左右边缘对齐。 */
|
||||
.video-input-grid {
|
||||
@apply grid gap-3;
|
||||
grid-template-columns: repeat(auto-fill, minmax(180px, 220px));
|
||||
@apply grid w-full gap-3;
|
||||
grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
|
||||
}
|
||||
.video-input-grid .asset-image {
|
||||
@apply aspect-square rounded-none;
|
||||
@@ -991,8 +984,9 @@ defineExpose({ inspectSpecs, inspecting })
|
||||
.asset-candidate-grid {
|
||||
@apply max-w-none grid-cols-[minmax(0,_1fr)];
|
||||
}
|
||||
/* 窄屏优先并排展示两列;素材较少时仍等分占满可用宽度。 */
|
||||
.video-input-grid {
|
||||
@apply grid-cols-[repeat(2,_minmax(0,_1fr))];
|
||||
grid-template-columns: repeat(auto-fit, minmax(min(120px, 100%), 1fr));
|
||||
}
|
||||
.generation-settings-panel {
|
||||
@apply p-4;
|
||||
|
||||
@@ -15,12 +15,13 @@ import {
|
||||
NInput,
|
||||
NInputNumber,
|
||||
NSelect,
|
||||
NTag
|
||||
NTag,
|
||||
type ScrollbarInst
|
||||
} from 'naive-ui'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useRoute, useRouter, type LocationQueryRaw } from 'vue-router'
|
||||
import { Check, Circle, UserCheck } from '@lucide/vue'
|
||||
import { AssetImage, DirectoryItem, EmptyState, StatusBadge } from '../../components/ui'
|
||||
import { DirectoryItem, EmptyState, StatusBadge } from '../../components/ui'
|
||||
import { downloadText } from '../../lib/format'
|
||||
import ConfirmAction from '../workflows/ConfirmAction.vue'
|
||||
import { castingStatusLabel, currentAnchor } from './model'
|
||||
@@ -35,7 +36,7 @@ import IdentityGallery from './components/IdentityGallery.vue'
|
||||
import IdentityImageDialog from './components/IdentityImageDialog.vue'
|
||||
import CastingCandidateDialog from './components/CastingCandidateDialog.vue'
|
||||
import IdentityThumbnail from './components/IdentityThumbnail.vue'
|
||||
import type { IdentitySubject } from './types'
|
||||
import type { IdentitySubject, IdentityViewType } from './types'
|
||||
|
||||
/** 主体身份工作区按正式主体聚合,不把同一主体的多个 Form 当成不同身份。 */
|
||||
const route = useRoute()
|
||||
@@ -70,7 +71,6 @@ const {
|
||||
canGenerateImage,
|
||||
canGenerateCandidate,
|
||||
activeIdentityGeneration,
|
||||
latestIdentityFailure,
|
||||
batchValid,
|
||||
candidateLimitValid,
|
||||
save,
|
||||
@@ -90,7 +90,7 @@ const {
|
||||
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)
|
||||
@@ -98,11 +98,6 @@ const generationFeedback = computed(() => {
|
||||
type: 'info' as const,
|
||||
message: `${subject.value.name} 的身份图片正在生成,刷新页面不会重复提交,请等待当前任务完成。`
|
||||
}
|
||||
if (latestIdentityFailure.value)
|
||||
return {
|
||||
type: 'error' as const,
|
||||
message: `最近一次身份图片生成失败:${latestIdentityFailure.value.error || '未返回具体错误'}。可以调整模型参数后重新生成。`
|
||||
}
|
||||
return null
|
||||
})
|
||||
/** 首次读取目录才替换整页,刷新已有主体时保留选择与阅读位置。 */
|
||||
@@ -115,6 +110,8 @@ const identityBatchModule = ref<'all' | 'character' | 'scene' | 'prop'>('all')
|
||||
/** 单主体稳定母版质量生成弹窗开关。 */
|
||||
const qualityOpen = ref(false)
|
||||
const imageOpen = ref(false)
|
||||
/** 从失败记录重试时保留原视角,普通生成仍使用弹窗默认视角。 */
|
||||
const retryImageView = ref<IdentityViewType>()
|
||||
const castingOpen = ref(false)
|
||||
const pendingSelection = ref('')
|
||||
const anchor = computed(() => currentAnchor(images.value))
|
||||
@@ -142,11 +139,34 @@ const filtered = computed(() =>
|
||||
)
|
||||
/** 主体目录根节点,复用分镜与生产目录的自动定位和平滑滚动。 */
|
||||
const subjectDirectoryRoot = ref<HTMLElement | null>(null)
|
||||
/** 桌面主体正文的独立滚动容器,切换主体时通过组件公开方法回到顶部。 */
|
||||
const identityDetailScrollbar = ref<ScrollbarInst | null>(null)
|
||||
/** 图片管理组件,步骤引导通过公开入口打开候选弹窗。 */
|
||||
const identityGallery = ref<InstanceType<typeof IdentityGallery> | null>(null)
|
||||
/** 手机正文起点,用于在页面共用滚动容器中定位新主体的内容顶部。 */
|
||||
const identityContentRoot = ref<HTMLElement | null>(null)
|
||||
useDirectorySelection(
|
||||
subjectDirectoryRoot,
|
||||
() => selectedId.value,
|
||||
() => filtered.value.map(item => item.id)
|
||||
)
|
||||
/** 只在主体实际改变后重置正文,刷新身份或取消切换时保留当前阅读位置。 */
|
||||
watch(
|
||||
selectedId,
|
||||
(id, previousId) => {
|
||||
if (!id || !previousId || id === previousId) return
|
||||
identityDetailScrollbar.value?.scrollTo({ top: 0, behavior: 'instant' })
|
||||
if (!window.matchMedia('(max-width: 760px)').matches) return
|
||||
const content = identityContentRoot.value
|
||||
const viewport = content?.closest<HTMLElement>('.project-view')
|
||||
if (!content || !viewport) return
|
||||
viewport.scrollTo({
|
||||
top: viewport.scrollTop + content.getBoundingClientRect().top - viewport.getBoundingClientRect().top,
|
||||
behavior: 'instant'
|
||||
})
|
||||
},
|
||||
{ flush: 'post' }
|
||||
)
|
||||
|
||||
/** 深链接仅在目标 ID 变化时选择,不因目录轮询把用户切回原主体。 */
|
||||
const linkedSubjectId = computed(
|
||||
@@ -165,6 +185,10 @@ watch(selectedId, () => {
|
||||
castingOpen.value = false
|
||||
pendingSelection.value = ''
|
||||
})
|
||||
/** 关闭生成弹窗后清除重试视角,避免影响下一次普通生成。 */
|
||||
watch(imageOpen, open => {
|
||||
if (!open) retryImageView.value = undefined
|
||||
})
|
||||
/** 当前主体写入地址,刷新和返回页面后恢复相同主体,再定位到对应目录项。 */
|
||||
watch(
|
||||
selectedId,
|
||||
@@ -212,6 +236,39 @@ function chooseAnchor(imageId: string) {
|
||||
if (subject.value?.module === 'character') void confirmCasting(imageId)
|
||||
else void confirmStableAnchor(imageId)
|
||||
}
|
||||
/** 当前主体生图暂不可用时,在失败记录旁说明具体恢复步骤。 */
|
||||
const imageRetryDisabledReason = computed(() => {
|
||||
if (operation.value.pending) return '当前操作尚未结束,请等待完成后再重新生成。'
|
||||
if (activeIdentityGeneration.value) return '此主体已有图片正在生成,请等待当前任务完成。'
|
||||
if (dirty.value) return '请先保存下方身份文本修改,再重新生成图片。'
|
||||
if (catalog.error.value || !catalog.data.value || detail.error.value || !detail.data.value)
|
||||
return '主体数据读取失败或尚未完成,请先点击“刷新身份”或重试读取目录。'
|
||||
if (styleQuery.error.value || !styleQuery.data.value) return '视觉风格尚未读取成功,请刷新页面后重试。'
|
||||
if (blocked.value) return '当前项目暂不允许生成图片,请检查剧本与拆解状态,或刷新页面后重试。'
|
||||
if (!hasStyle.value) return '请先在视觉风格页面保存项目风格。'
|
||||
if (generationModelsQuery.error.value || !generationModelsQuery.data.value)
|
||||
return '生成模型目录尚未读取成功,请刷新页面后重试。'
|
||||
if (profileQuery.error.value) return '项目生成配置读取失败,请刷新页面后重试。'
|
||||
if (!hasCreativeProfile.value) return '请先在“项目配置”中选择生成模型。'
|
||||
if (!identity.value?.generationPrompt?.trim()) return '请先填写并保存核心提示词,或使用 AI 生成主体身份。'
|
||||
if (subject.value?.module === 'character' && (castingQuery.error.value || !castingQuery.data.value))
|
||||
return '角色选角状态尚未读取成功,请刷新页面后重试。'
|
||||
return ''
|
||||
})
|
||||
/**
|
||||
* 重新生成只打开原图片类型对应的参数弹窗,费用确认前不发送请求。
|
||||
* @param imageId 当前主体中失败图片的正式编号
|
||||
*/
|
||||
function retryIdentityImage(imageId: string) {
|
||||
const image = images.value.find(item => item.id === imageId && item.status === 'failed')
|
||||
if (!image || imageRetryDisabledReason.value) return
|
||||
if (subject.value?.module === 'character' && image.viewType === 'primary') {
|
||||
if (canGenerateCandidate.value) castingOpen.value = true
|
||||
} else if (canGenerateImage.value) {
|
||||
retryImageView.value = image.viewType
|
||||
imageOpen.value = true
|
||||
}
|
||||
}
|
||||
/** 新回执自动展开,避免折叠区隐藏部分失败诊断。 */
|
||||
const toolsOpen = ref(false)
|
||||
watch(
|
||||
@@ -299,8 +356,8 @@ const nextAction = computed<{ action: IdentityFlowAction; title: string; descrip
|
||||
return {
|
||||
action: 'confirm',
|
||||
title: '第 3 步:确认并锁定',
|
||||
description: '在下方选择母版;人物会同时锁定,场景和道具还需保存锁定状态。',
|
||||
label: '前往确认母版'
|
||||
description: '在“管理候选”弹窗中确认母版;人物会同时锁定,场景和道具还需保存锁定状态。',
|
||||
label: '管理候选并确认'
|
||||
}
|
||||
return {
|
||||
action: 'forms',
|
||||
@@ -325,7 +382,7 @@ function runNextAction() {
|
||||
if (subject.value?.module === 'character') castingOpen.value = true
|
||||
else imageOpen.value = true
|
||||
} else if (nextAction.value.action === 'confirm') {
|
||||
document.querySelector('#identity-reference-gallery')?.scrollIntoView({ behavior: 'smooth', block: 'start' })
|
||||
identityGallery.value?.openCandidates()
|
||||
} else if (nextAction.value.action === 'lock') {
|
||||
document.querySelector('#identity-lock')?.scrollIntoView({ behavior: 'smooth', block: 'center' })
|
||||
} else if (nextAction.value.action === 'forms' && subjectImagesAccess.value.enabled) {
|
||||
@@ -676,9 +733,10 @@ function runNextAction() {
|
||||
</div>
|
||||
</div>
|
||||
</Transition>
|
||||
<div class="identity-workspace">
|
||||
<!-- 以下是主体目录 -->
|
||||
<aside class="panel directory-panel identity-directory">
|
||||
<!-- 以下是与分镜一致的融合工作区模块,目录与详情共用外层背景。 -->
|
||||
<div class="panel workspace-surface directory-workspace identity-workspace">
|
||||
<!-- 以下是主体目录模块,标题和搜索固定,条目通过独立滚动容器浏览。 -->
|
||||
<nav class="directory-panel identity-directory" aria-label="主体目录">
|
||||
<div class="directory-heading">
|
||||
<h3>
|
||||
主体目录 <span>{{ filtered.length }} / {{ subjects.length }}</span>
|
||||
@@ -730,166 +788,168 @@ function runNextAction() {
|
||||
<p v-if="!filtered.length" class="py-6 text-xs text-muted">没有匹配主体,请调整筛选。</p>
|
||||
</div>
|
||||
</NScrollbar>
|
||||
</aside>
|
||||
<NScrollbar class="identity-detail panel-scroll min-w-0">
|
||||
<NAlert v-if="pendingSelection" type="info" :show-icon="false" class="mb-4"
|
||||
><p class="text-xs">当前主体有未保存修改,切换会丢弃草稿。</p>
|
||||
<div class="mt-3 flex gap-3">
|
||||
<NButton @click="discardAndSelect">放弃草稿并切换</NButton
|
||||
><NButton @click="pendingSelection = ''" text size="small">继续编辑</NButton>
|
||||
</div></NAlert
|
||||
</nav>
|
||||
<!-- 以下是主体详情模块,滚动和内边距由公共工作区布局统一管理。 -->
|
||||
<article class="directory-workspace-detail identity-detail" aria-label="主体身份详情">
|
||||
<NScrollbar
|
||||
ref="identityDetailScrollbar"
|
||||
class="panel-scroll"
|
||||
content-class="directory-workspace-content identity-detail-content"
|
||||
>
|
||||
<section v-if="subject" class="panel workspace-panel">
|
||||
<div class="flex flex-wrap items-start justify-between gap-3">
|
||||
<div>
|
||||
<h3 class="font-semibold">
|
||||
{{ subject.name }} <code class="subject-ref ml-2">{{ subject.ref }}</code>
|
||||
</h3>
|
||||
</div>
|
||||
<NButton :disabled="detail.loading.value" @click="detail.refresh" text size="small">
|
||||
刷新身份
|
||||
</NButton>
|
||||
</div>
|
||||
<NAlert v-if="detail.error.value" role="alert" type="error" :show-icon="false" class="mt-4"
|
||||
>{{ detail.error.value }} 查询失败时不允许生成或覆盖。
|
||||
</NAlert>
|
||||
<!-- 以下是切换主体时的局部骨架模块,保留真实主体名称与目录 -->
|
||||
<IdentityDetailSkeleton v-if="detailInitialLoading" class="mt-5" />
|
||||
<template v-if="detail.data.value">
|
||||
<div class="identity-flow" aria-label="主体身份操作步骤">
|
||||
<ol class="identity-flow-steps">
|
||||
<li
|
||||
v-for="(step, index) in identityFlow"
|
||||
:key="step.label"
|
||||
:class="{ done: step.done, current: index === currentFlowIndex }"
|
||||
>
|
||||
<span class="identity-flow-marker">
|
||||
<Check v-if="step.done" :size="14" />
|
||||
<Circle v-else :size="12" />
|
||||
</span>
|
||||
<span>{{ index + 1 }}. {{ step.label }}</span>
|
||||
</li>
|
||||
</ol>
|
||||
<div class="identity-next-action">
|
||||
<div>
|
||||
<strong>{{ nextAction.title }}</strong>
|
||||
<p>{{ nextAction.description }}</p>
|
||||
</div>
|
||||
<NButton
|
||||
v-if="
|
||||
nextAction.action !== 'identity' &&
|
||||
(nextAction.action !== 'forms' || subjectImagesAccess.enabled)
|
||||
"
|
||||
type="primary"
|
||||
:disabled="
|
||||
operation.pending ||
|
||||
(nextAction.action === 'candidate' &&
|
||||
(subject.module === 'character'
|
||||
? !canGenerateCandidate
|
||||
: !canGenerateImage))
|
||||
"
|
||||
@click="runNextAction"
|
||||
>{{ nextAction.label }}</NButton
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="dirty" class="mt-3 text-xs text-muted">请先保存身份修改,再使用 AI 或生成图片。</p>
|
||||
<IdentityEditor
|
||||
:key="`${selectedId}:${editorRevision}`"
|
||||
:identity="identity"
|
||||
:module="subject.module"
|
||||
:disabled="detailBlocked"
|
||||
@save="save"
|
||||
@dirty="dirty = $event"
|
||||
>
|
||||
<!-- 以下是唯一的单主体 AI 文本生成入口,覆盖已有文本时沿用确认弹窗 -->
|
||||
<template #generate>
|
||||
<ConfirmAction
|
||||
v-if="identity?.description?.trim() || identity?.generationPrompt?.trim()"
|
||||
label="AI 生成主体身份"
|
||||
description="AI 将重新生成当前主体的身份描述和核心提示词,并覆盖已保存的文本;已有图片不会自动更新。"
|
||||
:disabled="!canGenerateText"
|
||||
primary
|
||||
@confirm="generate"
|
||||
/>
|
||||
<NButton v-else type="primary" :disabled="!canGenerateText" @click="generate">
|
||||
AI 生成主体身份
|
||||
</NButton>
|
||||
</template>
|
||||
</IdentityEditor>
|
||||
<div v-if="anchor" class="identity-anchor mt-5 flex items-center gap-4 pt-5">
|
||||
<AssetImage
|
||||
:src="anchor.imageUrl"
|
||||
:alt="`${subject.name}当前身份母版`"
|
||||
preview
|
||||
class="h-20 w-20 shrink-0"
|
||||
/>
|
||||
<NAlert v-if="pendingSelection" type="info" :show-icon="false" class="mb-4"
|
||||
><p class="text-xs">当前主体有未保存修改,切换会丢弃草稿。</p>
|
||||
<div class="mt-3 flex gap-3">
|
||||
<NButton @click="discardAndSelect">放弃草稿并切换</NButton
|
||||
><NButton @click="pendingSelection = ''" text size="small">继续编辑</NButton>
|
||||
</div></NAlert
|
||||
>
|
||||
<section v-if="subject" ref="identityContentRoot" class="identity-subject-content">
|
||||
<div class="flex flex-wrap items-start justify-between gap-3">
|
||||
<div>
|
||||
<p class="text-sm font-medium">当前身份母版</p>
|
||||
<p class="mt-2 text-xs text-muted">
|
||||
{{
|
||||
subject.module === 'character'
|
||||
? identity?.isLocked
|
||||
? '演员身份已确认并锁定,可用于形态图与镜头首帧。'
|
||||
: '已有演员母版但 Identity 尚未锁定,镜头首帧仍会被阻塞。'
|
||||
: subject.module === 'prop'
|
||||
? '锁定后,后续道具形态图会继承当前母版。'
|
||||
: '后续场景形态图会继承此图的空间结构。'
|
||||
}}
|
||||
</p>
|
||||
<h3 class="font-semibold">
|
||||
{{ subject.name }} <code class="subject-ref ml-2">{{ subject.ref }}</code>
|
||||
</h3>
|
||||
</div>
|
||||
<NButton :disabled="detail.loading.value" @click="detail.refresh" text size="small">
|
||||
刷新身份
|
||||
</NButton>
|
||||
</div>
|
||||
<IdentityGallery
|
||||
id="identity-reference-gallery"
|
||||
:key="selectedId"
|
||||
:images="images"
|
||||
:subject-name="subject.name"
|
||||
:module="subject.module"
|
||||
:identity-locked="!!identity?.isLocked"
|
||||
:disabled="
|
||||
detailBlocked || (subject.module === 'character' && !!castingQuery.error.value)
|
||||
"
|
||||
:pending-operation="pendingImageOperation"
|
||||
@validate="validateImage"
|
||||
@anchor="chooseAnchor"
|
||||
>
|
||||
<!-- 以下是图库标题栏的生成入口模块,与身份保存操作分组 -->
|
||||
<template #actions>
|
||||
<NButton
|
||||
v-if="subject.module === 'scene' || subject.module === 'prop'"
|
||||
:disabled="!canGenerateImage"
|
||||
@click="qualityOpen = true"
|
||||
>生成稳定母版并校验质量</NButton
|
||||
<NAlert v-if="detail.error.value" role="alert" type="error" :show-icon="false" class="mt-4"
|
||||
>{{ detail.error.value }} 查询失败时不允许生成或覆盖。
|
||||
</NAlert>
|
||||
<!-- 以下是切换主体时的局部骨架模块,保留真实主体名称与目录 -->
|
||||
<IdentityDetailSkeleton v-if="detailInitialLoading" class="mt-5" />
|
||||
<template v-if="detail.data.value">
|
||||
<div class="identity-flow" aria-label="主体身份操作步骤">
|
||||
<ol class="identity-flow-steps">
|
||||
<li
|
||||
v-for="(step, index) in identityFlow"
|
||||
:key="step.label"
|
||||
:class="{ done: step.done, current: index === currentFlowIndex }"
|
||||
>
|
||||
<span class="identity-flow-marker">
|
||||
<Check v-if="step.done" :size="14" />
|
||||
<Circle v-else :size="12" />
|
||||
</span>
|
||||
<span>{{ index + 1 }}. {{ step.label }}</span>
|
||||
</li>
|
||||
</ol>
|
||||
<div class="identity-next-action">
|
||||
<div>
|
||||
<strong>{{ nextAction.title }}</strong>
|
||||
<p>{{ nextAction.description }}</p>
|
||||
</div>
|
||||
<NButton
|
||||
v-if="
|
||||
nextAction.action !== 'identity' &&
|
||||
(nextAction.action !== 'forms' || subjectImagesAccess.enabled)
|
||||
"
|
||||
type="primary"
|
||||
:disabled="
|
||||
operation.pending ||
|
||||
(nextAction.action === 'candidate' &&
|
||||
(subject.module === 'character'
|
||||
? !canGenerateCandidate
|
||||
: !canGenerateImage))
|
||||
"
|
||||
@click="runNextAction"
|
||||
>{{ nextAction.label }}</NButton
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="dirty" class="mt-3 text-xs text-muted">
|
||||
请先保存身份修改,再使用 AI 或生成图片。
|
||||
</p>
|
||||
<IdentityEditor
|
||||
:key="`${selectedId}:${editorRevision}`"
|
||||
:identity="identity"
|
||||
:module="subject.module"
|
||||
:disabled="detailBlocked"
|
||||
@save="save"
|
||||
@dirty="dirty = $event"
|
||||
>
|
||||
<!-- 以下是唯一的单主体 AI 文本生成入口,覆盖已有文本时沿用确认弹窗 -->
|
||||
<template #generate>
|
||||
<ConfirmAction
|
||||
v-if="identity?.description?.trim() || identity?.generationPrompt?.trim()"
|
||||
label="AI 生成主体身份"
|
||||
description="AI 将重新生成当前主体的身份描述和核心提示词,并覆盖已保存的文本;已有图片不会自动更新。"
|
||||
:disabled="!canGenerateText"
|
||||
primary
|
||||
@confirm="generate"
|
||||
/>
|
||||
<NButton v-else type="primary" :disabled="!canGenerateText" @click="generate">
|
||||
AI 生成主体身份
|
||||
</NButton>
|
||||
</template>
|
||||
</IdentityEditor>
|
||||
<IdentityGallery
|
||||
id="identity-reference-gallery"
|
||||
ref="identityGallery"
|
||||
:key="selectedId"
|
||||
:images="images"
|
||||
:subject-name="subject.name"
|
||||
:module="subject.module"
|
||||
:identity-locked="!!identity?.isLocked"
|
||||
:disabled="
|
||||
detailBlocked || (subject.module === 'character' && !!castingQuery.error.value)
|
||||
"
|
||||
:pending-operation="pendingImageOperation"
|
||||
:retry-disabled-reason="imageRetryDisabledReason"
|
||||
@validate="validateImage"
|
||||
@anchor="chooseAnchor"
|
||||
@regenerate="retryIdentityImage"
|
||||
>
|
||||
<!-- 以下是母版卡片底部的生成入口模块,候选在独立弹窗中管理 -->
|
||||
<template #actions>
|
||||
<NButton
|
||||
v-if="subject.module === 'scene' || subject.module === 'prop'"
|
||||
:disabled="!canGenerateImage"
|
||||
@click="qualityOpen = true"
|
||||
>生成稳定母版并校验质量</NButton
|
||||
>
|
||||
<NButton
|
||||
v-if="subject.module === 'character'"
|
||||
:disabled="!canGenerateCandidate"
|
||||
@click="castingOpen = true"
|
||||
>{{ anchor ? '再生成一张候选' : 'AI 生成角色候选图' }}</NButton
|
||||
>
|
||||
<NButton :disabled="!canGenerateImage" @click="imageOpen = true">
|
||||
{{
|
||||
subject.module === 'character'
|
||||
? '生成辅助参考图'
|
||||
: anchor
|
||||
? '再生成一张候选'
|
||||
: '生成母版候选'
|
||||
}}
|
||||
</NButton>
|
||||
</template>
|
||||
</IdentityGallery>
|
||||
</template>
|
||||
<!-- 以下是当前主体形态与可用跳转入口,各行沿用统一上下间距 -->
|
||||
<div v-if="!detailInitialLoading" class="identity-subject-forms">
|
||||
<h4 class="text-xs font-medium">此主体的形态</h4>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<NTag v-for="form in subject.forms" :key="form.id" size="small" :bordered="false"
|
||||
>{{ form.name }}{{ form.isDefault ? ' · 默认' : '' }}</NTag
|
||||
>
|
||||
<NButton :disabled="!canGenerateImage" @click="imageOpen = true">
|
||||
{{ subject.module === 'character' ? '生成辅助参考图' : '生成母版候选' }}
|
||||
</NButton>
|
||||
</template>
|
||||
</IdentityGallery>
|
||||
</template>
|
||||
<!-- 以下是当前主体形态与可用跳转入口,各行沿用统一上下间距 -->
|
||||
<div v-if="!detailInitialLoading" class="identity-subject-forms">
|
||||
<h4 class="text-xs font-medium">此主体的形态</h4>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<NTag v-for="form in subject.forms" :key="form.id" size="small" :bordered="false"
|
||||
>{{ form.name }}{{ form.isDefault ? ' · 默认' : '' }}</NTag
|
||||
</div>
|
||||
<p v-if="!subject.forms.length" class="text-xs text-muted">
|
||||
此角色尚无正式形态,但可以先完成 Identity 与选角。
|
||||
</p>
|
||||
<RouterLink
|
||||
v-if="subjectImagesAccess.enabled"
|
||||
:to="{
|
||||
path: `/projects/${projectId}/subject-images`,
|
||||
query: { subjectRef: subject.ref }
|
||||
}"
|
||||
class="text-button justify-self-start"
|
||||
>查看此主体形态图片 →</RouterLink
|
||||
>
|
||||
</div>
|
||||
<p v-if="!subject.forms.length" class="text-xs text-muted">
|
||||
此角色尚无正式形态,但可以先完成 Identity 与选角。
|
||||
</p>
|
||||
<RouterLink
|
||||
v-if="subjectImagesAccess.enabled"
|
||||
:to="{
|
||||
path: `/projects/${projectId}/subject-images`,
|
||||
query: { subjectRef: subject.ref }
|
||||
}"
|
||||
class="text-button justify-self-start"
|
||||
>查看此主体形态图片 →</RouterLink
|
||||
>
|
||||
</div>
|
||||
</section>
|
||||
</NScrollbar>
|
||||
</section>
|
||||
</NScrollbar>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
<EmptyState
|
||||
@@ -920,6 +980,7 @@ function runNextAction() {
|
||||
:subject-id="subject.id"
|
||||
:subject-name="subject.name"
|
||||
:module="subject.module"
|
||||
:initial-view-type="retryImageView"
|
||||
:images="images"
|
||||
:catalog="generationModelsQuery.data.value"
|
||||
:profile="profileQuery.data.value.profile"
|
||||
@@ -942,15 +1003,13 @@ function runNextAction() {
|
||||
<style>
|
||||
/* 本组件专属布局与 Naive 内部结构覆盖。 */
|
||||
@reference "../../styles/styles.css";
|
||||
.identity-workspace {
|
||||
@apply grid grid-cols-[240px_minmax(0,_1fr)] items-start gap-3;
|
||||
}
|
||||
/* 主体目录根节点只用于定位,保留桌面纵向和手机横向的自然布局。 */
|
||||
.identity-directory-items {
|
||||
display: contents;
|
||||
}
|
||||
/* 目录由可用工作区高度约束,标题与搜索之外的空间供列表独立滚动。 */
|
||||
.identity-subject-list {
|
||||
@apply max-h-[560px] overflow-hidden;
|
||||
@apply min-h-0 flex-1 overflow-hidden;
|
||||
}
|
||||
.casting-stats {
|
||||
@apply grid grid-cols-[repeat(5,_minmax(0,_1fr))] gap-2.5;
|
||||
@@ -965,12 +1024,6 @@ function runNextAction() {
|
||||
@apply mt-[5px] font-mono text-[13px];
|
||||
}
|
||||
@media (max-width: 900px) {
|
||||
.identity-workspace {
|
||||
@apply grid-cols-[minmax(0,_1fr)];
|
||||
}
|
||||
.identity-subject-list {
|
||||
@apply max-h-[220px];
|
||||
}
|
||||
.casting-stats {
|
||||
@apply grid-cols-[repeat(2,_minmax(0,_1fr))];
|
||||
}
|
||||
@@ -1064,37 +1117,6 @@ function runNextAction() {
|
||||
.identity-tools-intro {
|
||||
@apply mb-6;
|
||||
}
|
||||
.identity-workspace {
|
||||
@apply flex-1 min-h-0 items-stretch overflow-hidden;
|
||||
}
|
||||
.identity-workspace {
|
||||
@apply grid-cols-[clamp(240px,_22%,_280px)_minmax(0,_1fr)];
|
||||
}
|
||||
.identity-workspace > div {
|
||||
@apply min-h-0 overflow-hidden overscroll-contain;
|
||||
}
|
||||
.identity-detail,
|
||||
.identity-detail > .n-scrollbar-container,
|
||||
.identity-detail .n-scrollbar-content,
|
||||
.identity-detail .panel {
|
||||
@apply w-full min-w-0 max-w-full;
|
||||
}
|
||||
.identity-detail .n-scrollbar-content {
|
||||
@apply wrap-anywhere;
|
||||
}
|
||||
.identity-detail .panel {
|
||||
@apply box-border;
|
||||
}
|
||||
/* AssetImage 的通用 width:100% 不得撑满母版摘要行,否则会把说明文字挤到最右侧。 */
|
||||
.identity-anchor > .asset-image {
|
||||
@apply h-20 w-20 shrink-0 aspect-square;
|
||||
}
|
||||
.identity-anchor > div {
|
||||
@apply min-w-0;
|
||||
}
|
||||
.identity-subject-list {
|
||||
@apply max-h-none min-h-0 flex-1;
|
||||
}
|
||||
.directory-filters {
|
||||
@apply grid gap-3 p-3 shrink-0;
|
||||
}
|
||||
@@ -1104,15 +1126,10 @@ function runNextAction() {
|
||||
.identity-subject-list-content {
|
||||
@apply gap-0.5 pt-0 px-0 pb-2;
|
||||
}
|
||||
/* 目录条目沿用分镜公共底色与选中反馈,仅调整缩略图所需间距。 */
|
||||
.n-button.identity-subject-item {
|
||||
@apply min-h-[86px] py-2.5 px-3.5;
|
||||
}
|
||||
.n-button.identity-subject-item:not(.selected) {
|
||||
@apply bg-(--app-surface);
|
||||
}
|
||||
.n-button.identity-subject-item:not(.selected):hover {
|
||||
@apply bg-(--app-subtle);
|
||||
}
|
||||
.identity-subject-item .directory-item-body {
|
||||
@apply gap-[3px];
|
||||
}
|
||||
@@ -1156,27 +1173,12 @@ function runNextAction() {
|
||||
flex: none;
|
||||
overflow: visible;
|
||||
}
|
||||
.identity-workspace-page .identity-workspace {
|
||||
height: auto;
|
||||
flex: none;
|
||||
overflow: visible;
|
||||
grid-template-rows: auto auto;
|
||||
}
|
||||
.identity-workspace-page .identity-workspace > .identity-detail,
|
||||
.identity-workspace-page .identity-detail > .n-scrollbar-container {
|
||||
height: auto;
|
||||
max-height: none;
|
||||
overflow: visible;
|
||||
}
|
||||
.identity-next-action {
|
||||
@apply items-start flex-col;
|
||||
}
|
||||
.identity-next-action > .n-button {
|
||||
@apply w-full;
|
||||
}
|
||||
.identity-workspace {
|
||||
@apply grid-cols-[minmax(0,_1fr)] grid-rows-[auto_minmax(0,_1fr)] gap-3;
|
||||
}
|
||||
.identity-directory {
|
||||
@apply h-auto;
|
||||
}
|
||||
|
||||
@@ -22,14 +22,14 @@ import IdentityDetailSkeleton from './components/IdentityDetailSkeleton.vue'
|
||||
<NSkeleton class="identity-skeleton-tools" :width="120" :height="34" />
|
||||
</div>
|
||||
</template>
|
||||
<div class="identity-skeleton-workspace">
|
||||
<div class="panel workspace-surface directory-workspace identity-skeleton-workspace">
|
||||
<!-- 以下是主体目录、搜索与缩略图条目占位模块 -->
|
||||
<aside class="panel directory-panel identity-skeleton-directory">
|
||||
<aside class="directory-panel identity-skeleton-directory">
|
||||
<div class="directory-heading"><NSkeleton :width="70" :height="14" /></div>
|
||||
<div class="identity-skeleton-search"><NSkeleton :height="34" /></div>
|
||||
<NScrollbar
|
||||
x-scrollable
|
||||
class="identity-skeleton-list panel-scroll"
|
||||
class="identity-skeleton-list panel-scroll directory-scroll"
|
||||
content-class="identity-skeleton-list-content"
|
||||
>
|
||||
<div v-for="row in 6" :key="row" class="identity-skeleton-subject">
|
||||
@@ -43,18 +43,17 @@ import IdentityDetailSkeleton from './components/IdentityDetailSkeleton.vue'
|
||||
</NScrollbar>
|
||||
</aside>
|
||||
<!-- 以下是与真实身份详情共用的步骤、文本与参考图库占位模块 -->
|
||||
<NScrollbar class="identity-skeleton-detail panel-scroll">
|
||||
<section class="panel workspace-panel"><IdentityDetailSkeleton heading /></section>
|
||||
</NScrollbar>
|
||||
<article class="directory-workspace-detail identity-skeleton-detail">
|
||||
<NScrollbar class="panel-scroll" content-class="directory-workspace-content">
|
||||
<IdentityDetailSkeleton heading />
|
||||
</NScrollbar>
|
||||
</article>
|
||||
</div>
|
||||
</WorkspacePage>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
@reference "../../styles/styles.css";
|
||||
.identity-skeleton-workspace {
|
||||
@apply grid grid-cols-[clamp(240px,_22%,_280px)_minmax(0,_1fr)] gap-3 flex-1 min-h-0 overflow-hidden;
|
||||
}
|
||||
.identity-skeleton-toolbar {
|
||||
@apply flex-nowrap;
|
||||
}
|
||||
@@ -85,25 +84,16 @@ import IdentityDetailSkeleton from './components/IdentityDetailSkeleton.vue'
|
||||
--n-color-end: var(--app-field-hover) !important;
|
||||
}
|
||||
@media (max-width: 760px) {
|
||||
.identity-skeleton-workspace {
|
||||
@apply grid-cols-[minmax(0,_1fr)] grid-rows-[auto_auto] flex-none overflow-visible;
|
||||
}
|
||||
.identity-skeleton-count {
|
||||
@apply hidden;
|
||||
}
|
||||
.identity-skeleton-tools {
|
||||
width: 34px !important;
|
||||
}
|
||||
.identity-skeleton-list.panel-scroll,
|
||||
.identity-skeleton-detail.panel-scroll,
|
||||
.identity-skeleton-detail > .n-scrollbar-container {
|
||||
.identity-skeleton-list.panel-scroll {
|
||||
height: auto;
|
||||
max-height: none;
|
||||
}
|
||||
.identity-skeleton-detail.panel-scroll,
|
||||
.identity-skeleton-detail > .n-scrollbar-container {
|
||||
overflow: visible;
|
||||
}
|
||||
.identity-skeleton-list-content {
|
||||
@apply flex-row w-max;
|
||||
}
|
||||
|
||||
@@ -45,9 +45,19 @@ const fieldHeights = [80, 96]
|
||||
</div>
|
||||
<div class="identity-skeleton-row identity-skeleton-gallery-heading">
|
||||
<NSkeleton :width="100" :height="14" />
|
||||
<NSkeleton :width="76" :height="24" />
|
||||
</div>
|
||||
<!-- 以下是母版卡片与底部候选操作占位模块,主页面不再显示候选缩略图列表 -->
|
||||
<div class="identity-skeleton-anchor">
|
||||
<NSkeleton class="identity-skeleton-picture" />
|
||||
<NSkeleton :width="'80%'" :height="18" />
|
||||
<NSkeleton :width="'60%'" :height="12" />
|
||||
<NSkeleton :height="34" />
|
||||
</div>
|
||||
<div class="identity-skeleton-row identity-skeleton-save">
|
||||
<NSkeleton :width="110" :height="34" />
|
||||
<NSkeleton :width="126" :height="34" />
|
||||
</div>
|
||||
<NSkeleton :height="150" />
|
||||
<div class="identity-skeleton-field">
|
||||
<NSkeleton :width="85" :height="12" />
|
||||
<div class="identity-skeleton-row">
|
||||
@@ -81,6 +91,14 @@ const fieldHeights = [80, 96]
|
||||
.identity-skeleton-field {
|
||||
@apply flex flex-col min-w-0 gap-3;
|
||||
}
|
||||
/* 骨架母版尺寸与正式卡片一致,手机仍按内容宽度显示正方形。 */
|
||||
.identity-skeleton-anchor {
|
||||
@apply grid w-full max-w-[260px] gap-3;
|
||||
}
|
||||
.identity-skeleton-anchor .identity-skeleton-picture {
|
||||
@apply aspect-square;
|
||||
height: auto;
|
||||
}
|
||||
.identity-skeleton-save {
|
||||
@apply flex-wrap;
|
||||
}
|
||||
@@ -89,6 +107,9 @@ const fieldHeights = [80, 96]
|
||||
--n-color-end: var(--app-field-hover) !important;
|
||||
}
|
||||
@media (max-width: 760px) {
|
||||
.identity-skeleton-anchor {
|
||||
@apply max-w-none;
|
||||
}
|
||||
.identity-skeleton-next {
|
||||
@apply items-start flex-col;
|
||||
}
|
||||
|
||||
@@ -1,237 +1,180 @@
|
||||
<script setup lang="ts">
|
||||
import ConfirmAction from '../../workflows/ConfirmAction.vue'
|
||||
import { NScrollbar, NAlert, NButton, NTag } from 'naive-ui'
|
||||
import { NButton, NTag } from 'naive-ui'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { AppDialog, AssetImage, StatusBadge } from '../../../components/ui'
|
||||
import { formatDate } from '../../../lib/format'
|
||||
import { canBeAnchor, currentAnchor, identityViewLabels } from '../model'
|
||||
import { AppDialog } from '../../../components/ui'
|
||||
import { candidateDialogWidth } from '../../../lib/candidate-layout'
|
||||
import { canBeAnchor, currentAnchor } from '../model'
|
||||
import type { IdentityImage, IdentityImageOperation } from '../types'
|
||||
import IdentityImageCard from './IdentityImageCard.vue'
|
||||
|
||||
/** 身份图库区分权威母版、primary 候选和辅助视图,保留后端原始状态。 */
|
||||
/** 身份图片主区域只展示正式母版,候选与辅助图在弹窗中管理。 */
|
||||
const props = defineProps<{
|
||||
/** 正式身份图片列表。 */
|
||||
/** 后端正式身份图片列表。 */
|
||||
images: IdentityImage[]
|
||||
/** 当前主体名称。 */
|
||||
subjectName: string
|
||||
/** 主体类型。 */
|
||||
/** 当前主体类型。 */
|
||||
module: string
|
||||
/** 身份是否已经锁定。 */
|
||||
/** 当前主体身份是否已经锁定。 */
|
||||
identityLocked: boolean
|
||||
/** 当前项目或主体是否禁止写入。 */
|
||||
disabled: boolean
|
||||
/** 当前确认或校验请求的固定图片目标。 */
|
||||
/** 当前固定图片目标的确认或校验操作。 */
|
||||
pendingOperation?: IdentityImageOperation | null
|
||||
/** 重新生成暂不可用的具体恢复步骤。 */
|
||||
retryDisabledReason?: string
|
||||
}>()
|
||||
/** 用户确认的图片操作。 */
|
||||
const emit = defineEmits<{ anchor: [imageId: string]; validate: [imageId: string] }>()
|
||||
/** selectedId 的当前界面状态与输入绑定。 */
|
||||
const selectedId = ref('')
|
||||
/** confirming 的当前界面状态与输入绑定。 */
|
||||
const confirming = ref(false)
|
||||
/** anchor 的当前界面状态与输入绑定。 */
|
||||
/** 图片操作交给父页面核验并执行,浏览候选不会修改母版。 */
|
||||
const emit = defineEmits<{
|
||||
/** 确认指定图片作为母版。 */
|
||||
anchor: [imageId: string]
|
||||
/** 校验指定图片。 */
|
||||
validate: [imageId: string]
|
||||
/** 打开失败图片对应类型的生成参数弹窗。 */
|
||||
regenerate: [imageId: string]
|
||||
}>()
|
||||
/** 母版仅认后端正式标记,不用首张候选填补空状态。 */
|
||||
const anchor = computed(() => currentAnchor(props.images))
|
||||
/** selected 的当前界面状态与输入绑定。 */
|
||||
const selected = computed(
|
||||
() => props.images.find(image => image.id === selectedId.value) ?? anchor.value ?? props.images[0]
|
||||
/** 其余 primary、辅助视图与未完成记录集中在管理弹窗。 */
|
||||
const candidates = computed(() => props.images.filter(image => image.id !== anchor.value?.id))
|
||||
/** 只有已完成的 primary 候选才可引导用户确认母版。 */
|
||||
const hasPrimaryCandidate = computed(() => candidates.value.some(canBeAnchor))
|
||||
/** 候选管理弹窗开关。 */
|
||||
const candidatesOpen = ref(false)
|
||||
/** 候选弹窗按固定卡片宽度适配列数,并由公共弹窗限制视口宽度。 */
|
||||
const candidatesWidth = computed(() => candidateDialogWidth(candidates.value.length))
|
||||
/** 母版卡片说明与身份锁定状态一致。 */
|
||||
const anchorDescription = computed(() =>
|
||||
props.identityLocked ? '后续形态图片会使用此母版。' : '请先锁定身份,后续形态图片才会稳定引用此母版。'
|
||||
)
|
||||
/** character 的当前界面状态与输入绑定。 */
|
||||
const character = computed(() => props.module === 'character')
|
||||
/** 仅为正在确认的图片显示加载状态。 */
|
||||
const confirmLoading = computed(
|
||||
() => props.pendingOperation?.imageId === selected.value?.id && props.pendingOperation?.kind === 'confirm'
|
||||
)
|
||||
/** 仅为正在校验的图片显示加载状态。 */
|
||||
const validateLoading = computed(
|
||||
() => props.pendingOperation?.imageId === selected.value?.id && props.pendingOperation?.kind === 'validate'
|
||||
)
|
||||
/** canSelect 的当前界面状态与输入绑定。 */
|
||||
const canSelect = computed(
|
||||
() =>
|
||||
!props.disabled &&
|
||||
!props.pendingOperation &&
|
||||
!!selected.value &&
|
||||
canBeAnchor(selected.value) &&
|
||||
(!selected.value.isAnchor || (character.value && !props.identityLocked))
|
||||
)
|
||||
/** 监听界面目标变化并重置关联确认状态。 */
|
||||
/** 后端确认新母版后收起候选,直接展示更新后的母版;请求失败则保留弹窗。 */
|
||||
watch(
|
||||
() => selected.value?.id,
|
||||
() => anchor.value?.id,
|
||||
() => {
|
||||
confirming.value = false
|
||||
candidatesOpen.value = false
|
||||
}
|
||||
)
|
||||
|
||||
/** 只发出用户确认过的目标 ID,父页面再核验图片归属。 */
|
||||
function chooseAnchor() {
|
||||
if (!canSelect.value || !confirming.value || !selected.value) return
|
||||
emit('anchor', selected.value.id)
|
||||
confirming.value = false
|
||||
/** 为步骤引导提供候选入口,打开弹窗只读取已有图片。 */
|
||||
function openCandidates() {
|
||||
if (candidates.value.length) candidatesOpen.value = true
|
||||
}
|
||||
/**
|
||||
* 关闭候选弹窗后打开原图片类型的参数设置,避免多个生成弹窗重叠。
|
||||
* @param imageId 用户选择重新生成的失败图片编号
|
||||
*/
|
||||
function regenerate(imageId: string) {
|
||||
candidatesOpen.value = false
|
||||
emit('regenerate', imageId)
|
||||
}
|
||||
/** 暴露只读管理入口供主体身份步骤引导复用。 */
|
||||
defineExpose({ openCandidates })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="identity-gallery mt-5 pt-5" aria-label="身份参考图库">
|
||||
<!-- 以下是图库标题、母版状态与图片生成操作模块 -->
|
||||
<!-- 以下是正式身份母版模块,主页面不展示候选与重复预览 -->
|
||||
<div class="identity-gallery-toolbar">
|
||||
<div class="identity-gallery-title">
|
||||
<h3 class="text-sm font-medium">身份参考图 · {{ images.length }}</h3>
|
||||
<NTag size="small" :bordered="false">{{ anchor ? '已选母版' : '尚无母版' }}</NTag>
|
||||
</div>
|
||||
<div v-if="$slots.actions" class="identity-gallery-actions"><slot name="actions" /></div>
|
||||
<h3 class="text-sm font-medium">身份母版</h3>
|
||||
<NTag v-if="!anchor" size="small" :bordered="false">尚无母版</NTag>
|
||||
</div>
|
||||
<template v-if="selected">
|
||||
<AssetImage
|
||||
:key="selected.id"
|
||||
:src="selected.status === 'completed' ? selected.imageUrl : null"
|
||||
:alt="`${subjectName} · ${identityViewLabels[selected.viewType]}`"
|
||||
class="asset-image-preview mt-4"
|
||||
object-fit="contain"
|
||||
preview
|
||||
:empty-text="selected.status === 'failed' ? '本次生成失败' : '等待后端图片结果'"
|
||||
<div v-if="anchor" class="identity-anchor-grid mt-4">
|
||||
<IdentityImageCard
|
||||
:image="anchor"
|
||||
:subject-name="subjectName"
|
||||
:module="module"
|
||||
:identity-locked="identityLocked"
|
||||
:disabled="disabled"
|
||||
:pending-operation="pendingOperation"
|
||||
:description="anchorDescription"
|
||||
@anchor="emit('anchor', $event)"
|
||||
@validate="emit('validate', $event)"
|
||||
/>
|
||||
<div class="image-history-heading">
|
||||
<h4 class="font-medium">历史记录 · {{ images.length }} 条</h4>
|
||||
</div>
|
||||
<NScrollbar
|
||||
x-scrollable
|
||||
trigger="none"
|
||||
content-class="image-history-content"
|
||||
:content-style="{ width: 'max-content' }"
|
||||
class="image-history"
|
||||
aria-label="身份图片历史"
|
||||
>
|
||||
<NButton
|
||||
v-for="image in images"
|
||||
</div>
|
||||
<p v-else class="mt-4 text-xs leading-6 text-muted">
|
||||
{{
|
||||
hasPrimaryCandidate
|
||||
? '尚未确认身份母版。请在“管理候选”中选择已完成的母版候选并确认。'
|
||||
: candidates.length
|
||||
? '尚无可确认的母版候选。请生成母版候选,已有图片可在“管理候选”中查看。'
|
||||
: '尚无身份母版。先保存身份文本,再生成母版候选。'
|
||||
}}
|
||||
</p>
|
||||
<!-- 以下是与镜头生产一致的底部图片操作模块 -->
|
||||
<div class="identity-gallery-actions">
|
||||
<NButton v-if="candidates.length" @click="openCandidates">管理候选({{ candidates.length }})</NButton>
|
||||
<slot name="actions" />
|
||||
</div>
|
||||
<!-- 以下是候选与辅助图片管理弹窗模块,确认和校验始终针对具体图片 -->
|
||||
<AppDialog
|
||||
v-model:open="candidatesOpen"
|
||||
title="身份候选管理"
|
||||
:description="`${subjectName} 的候选与辅助参考图;确认母版后,主页面会展示新母版。辅助参考图不能设为母版。`"
|
||||
:width="candidatesWidth"
|
||||
>
|
||||
<div class="identity-candidate-grid">
|
||||
<IdentityImageCard
|
||||
v-for="image in candidates"
|
||||
:key="image.id"
|
||||
:aria-label="`查看身份图片 ${image.id}`"
|
||||
:aria-pressed="image.id === selected.id"
|
||||
@click="selectedId = image.id"
|
||||
class="image-history-item"
|
||||
:class="{ selected: image.id === selected.id }"
|
||||
><AssetImage
|
||||
:src="image.status === 'completed' ? image.imageUrl : null"
|
||||
:alt="identityViewLabels[image.viewType]"
|
||||
:retryable="false"
|
||||
:empty-text="
|
||||
{ pending: '排队中', generating: '生成中', failed: '生成失败', completed: '图片缺失' }[
|
||||
image.status
|
||||
]
|
||||
"
|
||||
/><span class="image-history-label">{{
|
||||
image.isAnchor
|
||||
? '当前母版'
|
||||
: image.viewType === 'primary'
|
||||
? '母版候选'
|
||||
: identityViewLabels[image.viewType]
|
||||
}}</span>
|
||||
<span class="image-history-meta"><StatusBadge :status="image.status" /></span>
|
||||
</NButton>
|
||||
</NScrollbar>
|
||||
<!-- 以下是当前图片的状态、尺寸与创建时间模块,模型信息不参与展示 -->
|
||||
<div class="identity-image-meta">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<StatusBadge :status="selected.status" /><NTag size="small" :bordered="false">{{
|
||||
selected.isAnchor
|
||||
? '当前身份母版'
|
||||
: selected.viewType === 'primary'
|
||||
? '母版候选'
|
||||
: identityViewLabels[selected.viewType]
|
||||
}}</NTag
|
||||
><span v-if="selected.width && selected.height" class="text-xs text-muted"
|
||||
>{{ selected.width }} × {{ selected.height }}</span
|
||||
>
|
||||
</div>
|
||||
<time :datetime="selected.createdAt" class="identity-image-created"
|
||||
>创建于 {{ formatDate(selected.createdAt) }}</time
|
||||
>
|
||||
</div>
|
||||
<NAlert v-if="selected.error" role="alert" type="error" :show-icon="false" class="mt-3">{{
|
||||
selected.error
|
||||
}}</NAlert>
|
||||
<!-- 以下是当前图片的确认母版与质量校验模块,原图通过上方图片预览查看 -->
|
||||
<div class="identity-image-actions" role="group" aria-label="当前身份图片操作">
|
||||
<NButton
|
||||
v-if="!selected.isAnchor || (character && !identityLocked)"
|
||||
:disabled="!canSelect"
|
||||
:loading="confirmLoading"
|
||||
:aria-label="character ? '确认选角并锁定' : '设为身份母版'"
|
||||
:aria-busy="confirmLoading"
|
||||
type="primary"
|
||||
@click="confirming = true"
|
||||
>{{ character ? '确认选角并锁定' : '设为身份母版' }}</NButton
|
||||
>
|
||||
<ConfirmAction
|
||||
:key="selected.id"
|
||||
label="校验此身份图片"
|
||||
:description="`将校验图片 ${selected.id},会调用视觉模型并可能产生费用,不会切换母版。`"
|
||||
:disabled="disabled || selected.status !== 'completed' || !selected.imageUrl"
|
||||
:loading="validateLoading"
|
||||
acknowledgement
|
||||
@confirm="emit('validate', selected.id)"
|
||||
:image="image"
|
||||
:subject-name="subjectName"
|
||||
:module="module"
|
||||
:identity-locked="identityLocked"
|
||||
:disabled="disabled"
|
||||
:pending-operation="pendingOperation"
|
||||
:retry-disabled-reason="retryDisabledReason"
|
||||
:active="candidatesOpen"
|
||||
@anchor="emit('anchor', $event)"
|
||||
@validate="emit('validate', $event)"
|
||||
@regenerate="regenerate"
|
||||
/>
|
||||
</div>
|
||||
<p v-if="selected.viewType !== 'primary'" class="mt-2 text-xs text-muted">
|
||||
辅助视图不能直接设为母版;它会继承当前身份母版,不适合用来更换演员。
|
||||
</p>
|
||||
<!-- 以下是确认母版弹窗模块,操作确认不会被图库滚动位置遮住 -->
|
||||
<AppDialog
|
||||
v-model:open="confirming"
|
||||
:title="character ? '确认选角并锁定' : '确认切换身份母版'"
|
||||
:description="
|
||||
character
|
||||
? `确认将这张图片作为 ${subjectName} 的角色母版并锁定身份?后续图片生成会使用这张母版。`
|
||||
: `确认切换 ${subjectName} 的身份母版?旧母版会保留在图库中,后续形态图片生成会使用新母版。`
|
||||
"
|
||||
>
|
||||
<div class="dialog-footer mt-6">
|
||||
<NButton @click="confirming = false">取消</NButton>
|
||||
<NButton :disabled="!canSelect" @click="chooseAnchor" type="primary">{{
|
||||
character ? '确认演员选择' : '确认切换身份母版'
|
||||
}}</NButton>
|
||||
</div>
|
||||
</AppDialog>
|
||||
</template>
|
||||
<p v-else class="py-8 text-sm text-muted">尚无身份参考图。先保存身份提示词,再生成第一张母版。</p>
|
||||
</AppDialog>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
@reference "../../../styles/styles.css";
|
||||
/* 保存留在编辑器,图片入口随图库标题排列;换行后继续沿用同一左右边界。 */
|
||||
.identity-gallery-toolbar {
|
||||
@apply flex flex-wrap items-center justify-between gap-x-4 gap-y-3;
|
||||
@apply flex min-w-0 flex-wrap items-center justify-between gap-3;
|
||||
}
|
||||
/* 桌面母版与镜头首帧沿用 260px 卡片,画面宽高一致。 */
|
||||
.identity-anchor-grid {
|
||||
@apply grid w-full max-w-[260px] grid-cols-1;
|
||||
}
|
||||
/* 母版卡片采用 subtle 底色,与融合工作区的 surface 底色区分。 */
|
||||
.identity-anchor-grid .identity-image-card {
|
||||
@apply bg-(--app-subtle);
|
||||
}
|
||||
.identity-gallery-title,
|
||||
.identity-gallery-actions {
|
||||
@apply flex flex-wrap min-w-0 items-center gap-2;
|
||||
@apply mt-4 flex min-w-0 flex-wrap items-center gap-3;
|
||||
}
|
||||
/* 身份历史缩略图等宽等高,保留顶部裁切;上方大图继续完整预览。 */
|
||||
.identity-gallery .image-history-item .asset-image {
|
||||
height: auto;
|
||||
aspect-ratio: 1;
|
||||
/* 候选固定列宽并统一各行高度,弹窗正文负责纵向滚动。 */
|
||||
.identity-candidate-grid {
|
||||
@apply grid w-full max-w-[1348px] items-stretch gap-3;
|
||||
grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 260px));
|
||||
grid-auto-rows: 1fr;
|
||||
justify-content: space-between;
|
||||
}
|
||||
/* 状态、时间与确认校验分别排列,信息栏与按钮之间保留统一间距。 */
|
||||
.identity-image-meta {
|
||||
@apply mt-4 flex flex-wrap items-center justify-between gap-x-4 gap-y-2;
|
||||
/* 图片保持正方形,信息区填满剩余高度,操作固定在卡片底部。 */
|
||||
.identity-candidate-grid > .identity-image-card {
|
||||
@apply flex flex-col;
|
||||
}
|
||||
.identity-image-created {
|
||||
@apply text-[11px] text-muted whitespace-nowrap;
|
||||
.identity-candidate-grid .identity-image-card-body {
|
||||
@apply flex flex-1 flex-col;
|
||||
}
|
||||
.identity-image-actions {
|
||||
@apply mt-4 flex flex-wrap min-w-0 items-center gap-3;
|
||||
.identity-candidate-grid .identity-image-actions {
|
||||
margin-top: auto;
|
||||
padding-top: 8px;
|
||||
}
|
||||
@media (max-width: 760px) {
|
||||
.identity-gallery-actions {
|
||||
@apply w-full;
|
||||
.identity-anchor-grid {
|
||||
@apply max-w-none;
|
||||
}
|
||||
.identity-candidate-grid {
|
||||
@apply max-w-none grid-cols-[minmax(0,_1fr)];
|
||||
}
|
||||
.identity-gallery-actions > .n-button {
|
||||
@apply w-full;
|
||||
}
|
||||
/* 手机操作逐行铺满正文宽度,避免长按钮挤在一起或贴住下一行。 */
|
||||
.identity-image-actions > .n-button,
|
||||
.identity-image-actions > .confirm-action,
|
||||
.identity-image-actions > .confirm-action > .n-button {
|
||||
@apply w-full;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,308 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { NButton, NPopover, NScrollbar, NTag } from 'naive-ui'
|
||||
import { AppDialog, AssetImage, AssetOpenLink, StatusBadge } from '../../../components/ui'
|
||||
import { formatDate } from '../../../lib/format'
|
||||
import ConfirmAction from '../../workflows/ConfirmAction.vue'
|
||||
import { canBeAnchor, identityViewLabels } from '../model'
|
||||
import type { IdentityImage, IdentityImageOperation } from '../types'
|
||||
|
||||
/** 母版与候选共用图片卡片,操作始终绑定卡片的正式图片编号。 */
|
||||
const props = defineProps<{
|
||||
/** 此卡片对应的正式图片。 */
|
||||
image: IdentityImage
|
||||
/** 当前主体名称。 */
|
||||
subjectName: string
|
||||
/** 主体类型,决定确认选角或切换普通母版。 */
|
||||
module: string
|
||||
/** 身份是否已经锁定。 */
|
||||
identityLocked: boolean
|
||||
/** 当前项目或主体是否禁止写入。 */
|
||||
disabled: boolean
|
||||
/** 当前固定目标的图片操作。 */
|
||||
pendingOperation?: IdentityImageOperation | null
|
||||
/** 重新生成暂不可用的具体恢复步骤。 */
|
||||
retryDisabledReason?: string
|
||||
/** 当前母版的使用说明,候选卡片不展示。 */
|
||||
description?: string
|
||||
/** 候选管理是否可见,关闭管理弹窗时同步收起错误浮层。 */
|
||||
active?: boolean
|
||||
}>()
|
||||
/** 卡片只请求父页面执行操作,不直接调用模型或修改母版。 */
|
||||
const emit = defineEmits<{
|
||||
/** 确认指定图片作为母版。 */
|
||||
anchor: [imageId: string]
|
||||
/** 校验指定图片。 */
|
||||
validate: [imageId: string]
|
||||
/** 打开失败图片对应的生成参数弹窗。 */
|
||||
regenerate: [imageId: string]
|
||||
}>()
|
||||
/** 当前卡片的母版确认弹窗开关。 */
|
||||
const confirming = ref(false)
|
||||
/** 失败详情按需展示在浮层中,避免长错误文本撑高候选卡片。 */
|
||||
const failureDetailsOpen = ref(false)
|
||||
/** 角色使用选角确认事务,场景和道具使用稳定母版事务。 */
|
||||
const character = computed(() => props.module === 'character')
|
||||
/** 只为当前图片的确认请求显示加载。 */
|
||||
const confirmLoading = computed(
|
||||
() => props.pendingOperation?.imageId === props.image.id && props.pendingOperation.kind === 'confirm'
|
||||
)
|
||||
/** 只为当前图片的校验请求显示加载。 */
|
||||
const validateLoading = computed(
|
||||
() => props.pendingOperation?.imageId === props.image.id && props.pendingOperation.kind === 'validate'
|
||||
)
|
||||
/** 只有完成的 primary 可以确认,已锁定的当前母版不提供重复确认。 */
|
||||
const canSelect = computed(
|
||||
() =>
|
||||
!props.disabled &&
|
||||
!props.pendingOperation &&
|
||||
canBeAnchor(props.image) &&
|
||||
(!props.image.isAnchor || (character.value && !props.identityLocked))
|
||||
)
|
||||
/** 卡片标识区分身份母版、母版候选和辅助视角,不重复强调当前状态。 */
|
||||
const imageLabel = computed(() =>
|
||||
props.image.isAnchor
|
||||
? '身份母版'
|
||||
: props.image.viewType === 'primary'
|
||||
? '母版候选'
|
||||
: identityViewLabels[props.image.viewType]
|
||||
)
|
||||
/** 后台重启表示原请求结果未知,不能误导用户直接调整模型参数。 */
|
||||
const failureNotice = computed(() => {
|
||||
if (props.image.status !== 'failed') return null
|
||||
const error = props.image.error?.trim() ?? ''
|
||||
if (error.includes('服务重启时图片 Provider 请求状态不可恢复'))
|
||||
return {
|
||||
title: '图片生成中断,结果未确认',
|
||||
description:
|
||||
'后台服务重启,无法确认图片服务是否已完成原请求。系统未自动重试,以免重复生成和计费。请先到图片服务平台核对原任务结果,再决定是否重新生成。'
|
||||
}
|
||||
return { title: '本次图片生成失败', description: error || '图片服务未返回具体原因,请核对服务状态与生成参数。' }
|
||||
})
|
||||
/** 失败记录按原图片类型提供明确的重新生成入口。 */
|
||||
const regenerateLabel = computed(() =>
|
||||
props.image.viewType !== 'primary'
|
||||
? '重新生成辅助参考图'
|
||||
: character.value
|
||||
? '重新生成角色候选图'
|
||||
: '重新生成母版候选'
|
||||
)
|
||||
/** 已有请求、草稿或缺少前置配置时禁止重复生成。 */
|
||||
const regenerateDisabled = computed(() => props.disabled || !!props.pendingOperation || !!props.retryDisabledReason)
|
||||
/** 卡片被复用为其它图片或已确认为母版时,关闭旧目标的确认弹窗。 */
|
||||
watch([() => props.image.id, () => props.image.isAnchor, () => props.identityLocked], () => {
|
||||
confirming.value = false
|
||||
})
|
||||
/** 切换图片、任务状态变化或关闭候选弹窗时清理旧记录的错误浮层。 */
|
||||
watch([() => props.image.id, () => props.image.status, () => props.active], () => {
|
||||
failureDetailsOpen.value = false
|
||||
})
|
||||
/** 母版影响已由用户明确确认后,提交此卡片固定的图片编号。 */
|
||||
function chooseAnchor() {
|
||||
if (!canSelect.value || !confirming.value) return
|
||||
emit('anchor', props.image.id)
|
||||
confirming.value = false
|
||||
}
|
||||
/** 重新生成仅打开参数设置,失败记录自身不会被覆盖。 */
|
||||
function regenerate() {
|
||||
if (regenerateDisabled.value || props.image.status !== 'failed') return
|
||||
failureDetailsOpen.value = false
|
||||
emit('regenerate', props.image.id)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<article class="identity-image-card" :aria-label="`身份图片 ${image.id}`">
|
||||
<!-- 以下是方形身份图片与原图预览入口模块 -->
|
||||
<div class="relative">
|
||||
<AssetImage
|
||||
:src="image.status === 'completed' ? image.imageUrl : null"
|
||||
:alt="`${subjectName} · ${imageLabel}`"
|
||||
object-fit="cover"
|
||||
preview
|
||||
:empty-text="
|
||||
{ pending: '排队中', generating: '生成中', failed: '生成失败', completed: '图片缺失' }[image.status]
|
||||
"
|
||||
/>
|
||||
<AssetOpenLink :src="image.status === 'completed' ? image.imageUrl : null" label="打开身份图片" />
|
||||
</div>
|
||||
<!-- 以下是图片标识、尺寸和时间模块,母版锁定状态与身份标识同一行显示 -->
|
||||
<div class="identity-image-card-body">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<!-- 母版已是完成图,仅保留身份标识;候选继续显示生成状态。 -->
|
||||
<StatusBadge
|
||||
v-if="!image.isAnchor && !failureNotice"
|
||||
:status="image.status"
|
||||
:label="image.status === 'pending' ? '排队中' : undefined"
|
||||
/>
|
||||
<!-- 以下是失败标签的详情浮层模块,点击或键盘激活标签即可查看原因。 -->
|
||||
<NPopover
|
||||
v-if="failureNotice"
|
||||
v-model:show="failureDetailsOpen"
|
||||
trigger="click"
|
||||
placement="top-start"
|
||||
:to="true"
|
||||
:flip="true"
|
||||
:disabled="active === false"
|
||||
class="identity-failure-popover"
|
||||
@keydown.esc.stop="failureDetailsOpen = false"
|
||||
>
|
||||
<template #trigger>
|
||||
<button
|
||||
type="button"
|
||||
class="identity-failure-trigger"
|
||||
aria-label="生成失败,查看失败原因"
|
||||
:aria-expanded="failureDetailsOpen"
|
||||
:disabled="active === false"
|
||||
@keydown.esc.stop="failureDetailsOpen = false"
|
||||
>
|
||||
<StatusBadge :status="image.status" />
|
||||
</button>
|
||||
</template>
|
||||
<!-- 浮层挂到视口层避免裁剪,详情超出可用高度时由 NScrollbar 滚动。 -->
|
||||
<NScrollbar class="identity-failure-scroll">
|
||||
<div class="identity-image-failure text-xs leading-6">
|
||||
<p class="font-semibold text-danger">{{ failureNotice.title }}</p>
|
||||
<p class="mt-2">{{ failureNotice.description }}</p>
|
||||
<p v-if="retryDisabledReason" class="mt-2 text-muted">{{ retryDisabledReason }}</p>
|
||||
</div>
|
||||
</NScrollbar>
|
||||
</NPopover>
|
||||
<NTag size="small" :bordered="false">{{ imageLabel }}</NTag>
|
||||
<!-- 以下是母版身份锁定状态模块,紧邻图片下方的身份母版标签。 -->
|
||||
<NTag
|
||||
v-if="image.isAnchor"
|
||||
size="small"
|
||||
:bordered="false"
|
||||
:type="identityLocked ? 'success' : 'default'"
|
||||
>
|
||||
{{ identityLocked ? '已确认并锁定' : '待锁定' }}
|
||||
</NTag>
|
||||
</div>
|
||||
<!-- 以下是同一行的尺寸与时间模块,尺寸缺失时仍保持时间靠右对齐。 -->
|
||||
<div class="identity-image-meta">
|
||||
<span v-if="image.width && image.height">{{ image.width }} × {{ image.height }}</span>
|
||||
<time :datetime="image.createdAt">{{ formatDate(image.createdAt) }}</time>
|
||||
</div>
|
||||
<p v-if="description" class="text-xs leading-6 text-muted">{{ description }}</p>
|
||||
<p v-if="image.viewType !== 'primary'" class="text-xs leading-6 text-muted">
|
||||
辅助参考图继承当前母版,不能直接设为身份母版。
|
||||
</p>
|
||||
<!-- 以下是失败记录的重试模块,具体原因通过上方失败标签查看。 -->
|
||||
<div v-if="failureNotice" class="identity-image-actions" role="group" aria-label="失败图片恢复操作">
|
||||
<NButton size="small" :disabled="regenerateDisabled" type="primary" @click="regenerate">{{
|
||||
regenerateLabel
|
||||
}}</NButton>
|
||||
</div>
|
||||
<!-- 以下是固定图片目标的母版确认与校验模块,结果沿用 NMessage -->
|
||||
<div
|
||||
v-if="image.status === 'completed' && image.imageUrl"
|
||||
class="identity-image-actions"
|
||||
role="group"
|
||||
aria-label="当前身份图片操作"
|
||||
>
|
||||
<NButton
|
||||
v-if="image.viewType === 'primary' && (!image.isAnchor || (character && !identityLocked))"
|
||||
:disabled="!canSelect"
|
||||
:loading="confirmLoading"
|
||||
:aria-label="character ? '确认选角并锁定' : '设为身份母版'"
|
||||
:aria-busy="confirmLoading"
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="confirming = true"
|
||||
>
|
||||
{{ character ? '确认选角并锁定' : '设为身份母版' }}
|
||||
</NButton>
|
||||
<ConfirmAction
|
||||
:key="image.id"
|
||||
label="校验此身份图片"
|
||||
:description="`将校验图片 ${image.id},会调用视觉模型并可能产生费用,不会切换母版。`"
|
||||
:disabled="disabled || !!pendingOperation"
|
||||
:loading="validateLoading"
|
||||
acknowledgement
|
||||
@confirm="emit('validate', image.id)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 以下是明确母版影响的人工确认弹窗模块 -->
|
||||
<AppDialog
|
||||
v-model:open="confirming"
|
||||
:title="character ? '确认选角并锁定' : '确认切换身份母版'"
|
||||
:description="
|
||||
character
|
||||
? `确认将这张图片作为 ${subjectName} 的角色母版并锁定身份?后续图片生成会使用这张母版。`
|
||||
: `确认切换 ${subjectName} 的身份母版?旧母版会保留在候选记录中,后续形态图片生成会使用新母版。`
|
||||
"
|
||||
>
|
||||
<template #footer>
|
||||
<NButton @click="confirming = false">取消</NButton>
|
||||
<NButton :disabled="!canSelect" type="primary" @click="chooseAnchor">{{
|
||||
character ? '确认演员选择' : '确认切换身份母版'
|
||||
}}</NButton>
|
||||
</template>
|
||||
</AppDialog>
|
||||
</article>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
@reference "../../../styles/styles.css";
|
||||
/* 候选卡片与弹窗底色区分,方形画面保留顶部裁切与完整原图预览。 */
|
||||
.identity-image-card {
|
||||
@apply min-w-0 max-w-full overflow-hidden bg-(--app-subtle);
|
||||
}
|
||||
.identity-image-card .asset-image {
|
||||
@apply aspect-square;
|
||||
}
|
||||
.identity-image-card-body {
|
||||
@apply p-3 grid min-w-0 gap-2 wrap-anywhere;
|
||||
}
|
||||
.identity-image-meta {
|
||||
@apply flex min-h-4 min-w-0 items-center justify-between gap-2 text-[10px] text-muted;
|
||||
}
|
||||
.identity-image-meta > time {
|
||||
@apply ml-auto shrink-0 whitespace-nowrap;
|
||||
}
|
||||
.identity-failure-trigger {
|
||||
@apply inline-flex items-center border-0 bg-transparent p-0;
|
||||
}
|
||||
.identity-image-actions {
|
||||
@apply mt-2 grid min-w-0 grid-flow-col auto-cols-fr items-stretch gap-2;
|
||||
}
|
||||
.identity-image-actions > .confirm-action {
|
||||
@apply min-w-0 max-w-full;
|
||||
}
|
||||
.identity-image-card .identity-image-actions > .n-button,
|
||||
.identity-image-card .identity-image-actions > .confirm-action {
|
||||
@apply w-full;
|
||||
}
|
||||
.identity-image-card .identity-image-actions > .confirm-action > .n-button {
|
||||
@apply w-full;
|
||||
height: 100%;
|
||||
}
|
||||
/* 操作最多两项并等分一行,窄屏长文案自然换行,单项占满整行。 */
|
||||
.identity-image-card .identity-image-actions .n-button {
|
||||
height: auto;
|
||||
min-height: 28px;
|
||||
font-size: 12px;
|
||||
padding-inline: 8px;
|
||||
padding-block: 4px;
|
||||
}
|
||||
.identity-image-card .identity-image-actions .n-button__content {
|
||||
@apply whitespace-normal text-center leading-5;
|
||||
}
|
||||
/* 错误浮层独立于卡片布局,保留浮层箭头,滚动交由 NScrollbar。 */
|
||||
.identity-failure-popover.n-popover {
|
||||
box-sizing: border-box;
|
||||
width: min(360px, calc(100vw - 48px));
|
||||
}
|
||||
/* 为浮层内边距预留空间,短内容保持自然高度,长内容不撑出视口。 */
|
||||
.identity-failure-scroll.n-scrollbar {
|
||||
max-height: min(388px, calc(100dvh - 80px));
|
||||
}
|
||||
.identity-failure-scroll > .n-scrollbar-container {
|
||||
overscroll-behavior: contain;
|
||||
}
|
||||
.identity-image-failure {
|
||||
@apply whitespace-pre-wrap wrap-anywhere;
|
||||
}
|
||||
</style>
|
||||
@@ -16,12 +16,21 @@ import type { GenerateIdentityImageInput, IdentityImage, IdentityViewType } from
|
||||
|
||||
/** 身份图生成配置;默认自动引用母版,不提供后端不存在的“忽略母版”开关。 */
|
||||
const props = defineProps<{
|
||||
/** 正式主体编号。 */
|
||||
subjectId: string
|
||||
/** 当前主体名称。 */
|
||||
subjectName: string
|
||||
/** 主体类型,决定允许生成的视角。 */
|
||||
module?: string
|
||||
/** 从失败记录重新生成时使用的原视角。 */
|
||||
initialViewType?: IdentityViewType
|
||||
/** 当前主体的身份图片,供选择母版参考。 */
|
||||
images: IdentityImage[]
|
||||
/** 当前操作是否禁止提交。 */
|
||||
disabled: boolean
|
||||
/** 可用模型及动态参数目录。 */
|
||||
catalog: GenerationModelCatalog
|
||||
/** 已保存的项目默认生成配置。 */
|
||||
profile: CreativeProfile
|
||||
}>()
|
||||
/** open 的当前界面状态与输入绑定。 */
|
||||
@@ -55,11 +64,16 @@ const valid = computed(
|
||||
Boolean(provider.value) &&
|
||||
(!referenceImageId.value || references.value.some(image => image.id === referenceImageId.value))
|
||||
)
|
||||
/** 监听界面目标变化并重置关联确认状态。 */
|
||||
/** 打开或切换重试目标时恢复原视角,并重新读取项目默认参数与费用确认。 */
|
||||
watch(
|
||||
() => [open.value, props.subjectId],
|
||||
() => [open.value, props.subjectId, props.initialViewType],
|
||||
() => {
|
||||
viewType.value = props.module === 'character' ? 'front' : 'primary'
|
||||
viewType.value =
|
||||
props.module === 'character'
|
||||
? props.initialViewType && props.initialViewType !== 'primary'
|
||||
? props.initialViewType
|
||||
: 'front'
|
||||
: 'primary'
|
||||
referenceImageId.value = ''
|
||||
prompt.value = ''
|
||||
const selected =
|
||||
|
||||
@@ -155,7 +155,6 @@ export function useSubjectIdentity() {
|
||||
const activeIdentityGeneration = computed(() =>
|
||||
images.value.find(image => image.status === 'pending' || image.status === 'generating')
|
||||
)
|
||||
const latestIdentityFailure = computed(() => images.value.find(image => image.status === 'failed'))
|
||||
const canGenerateCandidate = computed(
|
||||
() =>
|
||||
canGenerateImage.value &&
|
||||
@@ -635,7 +634,6 @@ export function useSubjectIdentity() {
|
||||
canGenerateImage,
|
||||
canGenerateCandidate,
|
||||
activeIdentityGeneration,
|
||||
latestIdentityFailure,
|
||||
batchValid,
|
||||
candidateLimitValid,
|
||||
save,
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* 按 260px 候选卡片计算弹窗宽度,每行最多五项,并预留列间距和内边距。
|
||||
* @param count 当前候选数量
|
||||
* @returns 弹窗期望宽度,单位为像素,实际宽度由公共弹窗适配视口
|
||||
*/
|
||||
export function candidateDialogWidth(count: number): number {
|
||||
const columns = Math.max(1, Math.min(5, count))
|
||||
return columns * 260 + (columns - 1) * 12 + 48
|
||||
}
|
||||
@@ -409,6 +409,46 @@ body {
|
||||
:root:not([data-theme='dark']) .workspace-surface > .directory-panel {
|
||||
background: color-mix(in srgb, var(--app-subtle) 60%, var(--app-body));
|
||||
}
|
||||
/* 融合目录工作区沿用分镜的列宽和间距,真实页面与骨架共享同一背景和尺寸约束。 */
|
||||
.directory-workspace {
|
||||
display: grid;
|
||||
grid-template-columns: clamp(240px, 22%, 280px) minmax(0, 1fr);
|
||||
align-items: stretch;
|
||||
gap: 12px;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
.directory-workspace > .directory-panel {
|
||||
--app-field: var(--app-control);
|
||||
--app-field-hover: var(--app-control-hover);
|
||||
background: transparent;
|
||||
}
|
||||
/* 详情面板只负责约束高度,正文与图片滚动统一交给内部 NScrollbar。 */
|
||||
.directory-workspace-detail,
|
||||
.directory-workspace-detail > .panel-scroll,
|
||||
.directory-workspace-detail > .panel-scroll > .n-scrollbar-container,
|
||||
.directory-workspace-content {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
}
|
||||
.directory-workspace-detail {
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
.directory-workspace-content {
|
||||
box-sizing: border-box;
|
||||
padding: 20px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
@media (min-width: 1024px) {
|
||||
.directory-workspace-content {
|
||||
padding: 28px;
|
||||
}
|
||||
}
|
||||
.image-history.n-scrollbar,
|
||||
.table-scroll.n-scrollbar {
|
||||
height: auto;
|
||||
@@ -558,6 +598,32 @@ body {
|
||||
align-items: stretch;
|
||||
padding-bottom: 12px;
|
||||
}
|
||||
/* 手机目录横向浏览,详情自然撑高;两部分继续共用融合背景和页面滚动。 */
|
||||
.directory-workspace {
|
||||
height: auto;
|
||||
flex: none;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
grid-template-rows: auto auto;
|
||||
gap: 8px;
|
||||
overflow: visible;
|
||||
}
|
||||
.directory-workspace > .directory-panel {
|
||||
height: auto;
|
||||
}
|
||||
.directory-workspace > .directory-panel > .panel-scroll {
|
||||
height: auto;
|
||||
flex: none;
|
||||
}
|
||||
.directory-workspace-detail,
|
||||
.directory-workspace-detail > .panel-scroll,
|
||||
.directory-workspace-detail > .panel-scroll > .n-scrollbar-container {
|
||||
height: auto;
|
||||
max-height: none;
|
||||
overflow: visible;
|
||||
}
|
||||
.directory-workspace-content {
|
||||
padding: 12px;
|
||||
}
|
||||
/* 分镜和生产共用紧凑手机工具栏,剧集选择与两个操作入口保持同行。 */
|
||||
.compact-shot-workspace .workspace-toolbar {
|
||||
display: grid;
|
||||
|
||||
@@ -63,7 +63,8 @@ describe('统一目录条目', () => {
|
||||
expect(css).toMatch(/\.n-button\.identity-subject-item\s*\{[^}]*min-height:\s*86px;[^}]*padding:\s*10px 14px/)
|
||||
expect(css).not.toMatch(/\.n-button\.identity-subject-item\s*\{[^}]*border-bottom:/)
|
||||
expect(css).toMatch(/\.identity-thumbnail\s*\{[^}]*width:\s*48px;[^}]*height:\s*64px/)
|
||||
expect(css).toMatch(/\.n-button\.identity-subject-item:not\(\.selected\)\s*\{[^}]*var\(--app-surface\)/)
|
||||
// 融合工作区由外层承载背景,目录不再重复铺设独立底色。
|
||||
expect(css).toMatch(/\.directory-workspace > \.directory-panel\s*\{[^}]*background:\s*transparent/)
|
||||
})
|
||||
|
||||
it('侧栏与主体、镜头、剧集目录统一直角满行,保留文字内边距和移动端滚动', () => {
|
||||
|
||||
@@ -51,7 +51,7 @@ describe('镜头生产数据契约', () => {
|
||||
expect(source).toContain('v-if="currentVideo" class="video-grid mt-4"')
|
||||
expect(source).toMatch(/\.keyframe-grid,\s*\.video-grid\s*\{[^}]*max-w-\[260px\][^}]*grid-cols-1/)
|
||||
expect(source).toMatch(
|
||||
/\.video-input-grid\s*\{[^}]*grid-template-columns:\s*repeat\(auto-fill, minmax\(180px, 220px\)\)/
|
||||
/\.video-input-grid\s*\{[^}]*grid-template-columns:\s*repeat\(auto-fit, minmax\(min\(180px, 100%\), 1fr\)\)/
|
||||
)
|
||||
expect(source).toMatch(/\.keyframe-card \.asset-image\s*\{[^}]*aspect-square/)
|
||||
const videoCard = readFileSync('src/features/production/components/VideoCard.vue', 'utf8')
|
||||
@@ -62,7 +62,7 @@ describe('镜头生产数据契约', () => {
|
||||
expect(source).not.toContain('class="video-input-ref"')
|
||||
expect(source).not.toContain('{{ reference.subjectFormName }} · {{ reference.subjectRef }}')
|
||||
expect(source).toMatch(
|
||||
/@media \(max-width: 760px\)[\s\S]*?\.video-input-grid\s*\{[^}]*grid-cols-\[repeat\(2,_minmax\(0,_1fr\)\)\]/
|
||||
/@media \(max-width: 760px\)[\s\S]*?\.video-input-grid\s*\{[^}]*grid-template-columns:\s*repeat\(auto-fit, minmax\(min\(120px, 100%\), 1fr\)\)/
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { imageCatalog, generationProfile } from '../../fixtures/generation'
|
||||
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { NButton, NImage, NScrollbar } from 'naive-ui'
|
||||
import { AppDialog, AssetImage } from '@/components/ui'
|
||||
import { NButton, NImage } from 'naive-ui'
|
||||
import { AppDialog } from '@/components/ui'
|
||||
import IdentityImageDialog from '@/features/subject-identity/components/IdentityImageDialog.vue'
|
||||
import IdentityGallery from '@/features/subject-identity/components/IdentityGallery.vue'
|
||||
import IdentityImageCard from '@/features/subject-identity/components/IdentityImageCard.vue'
|
||||
import CastingCandidateDialog from '@/features/subject-identity/components/CastingCandidateDialog.vue'
|
||||
import { subjectIdentityApi } from '@/features/subject-identity/api'
|
||||
import {
|
||||
@@ -16,7 +17,7 @@ import {
|
||||
} from '@/features/subject-identity/model'
|
||||
import { identityImageFixture } from '@/features/subject-identity/testing/fixtures'
|
||||
import { formFixture } from '@/features/subject-images/testing/fixtures'
|
||||
import { expandSections, selectControl } from '@/testing/naive'
|
||||
import { selectControl } from '@/testing/naive'
|
||||
|
||||
let wrapper: VueWrapper | undefined
|
||||
afterEach(() => {
|
||||
@@ -26,13 +27,29 @@ afterEach(() => {
|
||||
vi.unstubAllGlobals()
|
||||
})
|
||||
|
||||
/** 从真实 Naive 弹窗内获取确认按钮。 */
|
||||
/**
|
||||
* 按可见文本或无障碍名称查找真实弹窗与标签操作按钮。
|
||||
* @param label 按钮文本或无障碍名称
|
||||
* @returns 对应的原生按钮
|
||||
*/
|
||||
function button(label: string) {
|
||||
const item = [...document.querySelectorAll('button')].find(element => element.textContent?.trim() === label)
|
||||
const item = [...document.querySelectorAll('button')].find(
|
||||
element => element.textContent?.trim() === label || element.getAttribute('aria-label') === label
|
||||
)
|
||||
if (!item) throw new Error(`缺少按钮 ${label}`)
|
||||
return item
|
||||
}
|
||||
|
||||
/**
|
||||
* 在指定图片卡片中获取操作按钮,避免不同候选的同名按钮混用。
|
||||
* @param card 当前图片卡片
|
||||
* @param label 目标操作文本
|
||||
* @returns 当前卡片的按钮包装器
|
||||
*/
|
||||
function cardButton(card: VueWrapper, label: string) {
|
||||
return card.findAllComponents(NButton).find(item => item.text() === label)!
|
||||
}
|
||||
|
||||
/** 修改 Portal 表单控件并触发 Vue 绑定。 */
|
||||
function input(selector: string, value: string) {
|
||||
if (selector === '#identity-view' || selector === '#identity-reference') {
|
||||
@@ -48,7 +65,78 @@ function input(selector: string, value: string) {
|
||||
const creativeProfile = generationProfile('project-1')
|
||||
|
||||
describe('身份图与母版契约', () => {
|
||||
it('详情大图 contain 完整显示,历史仍为 cover,缩略图只切换记录', async () => {
|
||||
it('主页面只显示权威母版,所有候选与辅助、失败和进行中记录在管理弹窗中浏览', async () => {
|
||||
const images = [
|
||||
identityImageFixture({ id: 'candidate', isAnchor: false }),
|
||||
identityImageFixture({
|
||||
id: 'failed',
|
||||
status: 'failed',
|
||||
imageUrl: null,
|
||||
isAnchor: false,
|
||||
error: '模型超时'
|
||||
}),
|
||||
identityImageFixture({
|
||||
id: 'anchor',
|
||||
imageUrl: '/storage/anchor.png',
|
||||
provider: 'qwen-image',
|
||||
model: 'qwen-image-3.0-pro'
|
||||
}),
|
||||
identityImageFixture({ id: 'front', viewType: 'front', isAnchor: false }),
|
||||
identityImageFixture({ id: 'pending', status: 'pending', imageUrl: null, isAnchor: false }),
|
||||
identityImageFixture({ id: 'generating', status: 'generating', imageUrl: null, isAnchor: false })
|
||||
]
|
||||
wrapper = mount(IdentityGallery, {
|
||||
attachTo: document.body,
|
||||
props: { subjectName: '林夏', module: 'character', identityLocked: true, disabled: false, images }
|
||||
})
|
||||
expect(wrapper.findAll('.identity-anchor-grid .identity-image-card')).toHaveLength(1)
|
||||
expect(wrapper.getComponent(NImage).props()).toMatchObject({
|
||||
objectFit: 'cover',
|
||||
previewDisabled: false
|
||||
})
|
||||
expect(wrapper.getComponent(NImage).props('src')).toContain('/storage/anchor.png')
|
||||
expect(wrapper.text()).not.toContain('qwen-image')
|
||||
expect(wrapper.find('.image-history').exists()).toBe(false)
|
||||
expect(document.querySelector('.identity-candidate-grid')).toBeNull()
|
||||
button('管理候选(5)').click()
|
||||
await flushPromises()
|
||||
const dialog = document.querySelector('[role="dialog"][aria-label="身份候选管理"]')!
|
||||
expect(dialog.querySelectorAll('.identity-image-card')).toHaveLength(5)
|
||||
expect(dialog.querySelector('[aria-label="身份图片 anchor"]')).toBeNull()
|
||||
for (const id of ['candidate', 'failed', 'front', 'pending', 'generating']) {
|
||||
expect(dialog.querySelector(`[aria-label="身份图片 ${id}"]`)).not.toBeNull()
|
||||
}
|
||||
expect(dialog.textContent).toContain('排队中')
|
||||
expect(dialog.textContent).toContain('生成中')
|
||||
expect(wrapper.emitted('anchor')).toBeUndefined()
|
||||
expect(wrapper.emitted('validate')).toBeUndefined()
|
||||
expect(wrapper.emitted('regenerate')).toBeUndefined()
|
||||
})
|
||||
|
||||
it('候选未确认时不填补母版空状态,无图片时不提供管理入口', async () => {
|
||||
wrapper = mount(IdentityGallery, {
|
||||
attachTo: document.body,
|
||||
props: {
|
||||
subjectName: '林夏',
|
||||
module: 'character',
|
||||
identityLocked: false,
|
||||
disabled: false,
|
||||
images: [identityImageFixture({ id: 'candidate', isAnchor: false })]
|
||||
}
|
||||
})
|
||||
expect(wrapper.text()).toContain('尚未确认身份母版')
|
||||
expect(wrapper.find('.identity-anchor-grid').exists()).toBe(false)
|
||||
button('管理候选(1)').click()
|
||||
await flushPromises()
|
||||
expect(document.querySelector('[aria-label="身份图片 candidate"]')).not.toBeNull()
|
||||
expect(wrapper.emitted('anchor')).toBeUndefined()
|
||||
await wrapper.setProps({ images: [] })
|
||||
expect(wrapper.text()).toContain('尚无身份母版')
|
||||
expect(wrapper.find('.identity-anchor-grid').exists()).toBe(false)
|
||||
expect(wrapper.findAll('button').some(item => item.text().includes('管理候选'))).toBe(false)
|
||||
})
|
||||
|
||||
it('失败详情按需在浮层显示,关闭管理同步收起详情,重试仅发出原记录 ID', async () => {
|
||||
wrapper = mount(IdentityGallery, {
|
||||
attachTo: document.body,
|
||||
props: {
|
||||
@@ -57,141 +145,66 @@ describe('身份图与母版契约', () => {
|
||||
identityLocked: true,
|
||||
disabled: false,
|
||||
images: [
|
||||
identityImageFixture({ id: 'anchor', imageUrl: '/storage/anchor.png' }),
|
||||
identityImageFixture({ id: 'anchor' }),
|
||||
identityImageFixture({
|
||||
id: 'front',
|
||||
viewType: 'front',
|
||||
id: 'interrupted',
|
||||
status: 'failed',
|
||||
imageUrl: null,
|
||||
isAnchor: false,
|
||||
imageUrl: '/storage/front.png'
|
||||
error: '服务重启时图片 Provider 请求状态不可恢复,请人工确认后重新生成'
|
||||
})
|
||||
]
|
||||
}
|
||||
})
|
||||
const images = wrapper.findAllComponents(NImage)
|
||||
expect(images).toHaveLength(3)
|
||||
expect(images.map(image => image.props('objectFit'))).toEqual(['contain', 'cover', 'cover'])
|
||||
expect(images.map(image => image.props('previewDisabled'))).toEqual([false, true, true])
|
||||
expect(wrapper.find('a[target="_blank"]').exists()).toBe(false)
|
||||
expect(wrapper.text()).not.toContain('打开原图')
|
||||
await wrapper.get('[aria-label="查看身份图片 front"] img').trigger('click')
|
||||
expect(wrapper.find('.identity-image-failure').exists()).toBe(false)
|
||||
button('管理候选(1)').click()
|
||||
await flushPromises()
|
||||
expect(wrapper.get('[aria-label="查看身份图片 front"]').attributes('aria-pressed')).toBe('true')
|
||||
expect(document.querySelector('.n-image-preview-container')).toBeNull()
|
||||
const main = wrapper.get('.asset-image-preview img')
|
||||
expect((main.element as HTMLImageElement).style.objectFit).toBe('contain')
|
||||
expect(main.attributes('src')).toContain('/storage/front.png')
|
||||
await main.trigger('click')
|
||||
const card = document.querySelector('[aria-label="身份图片 interrupted"]')!
|
||||
expect(card.textContent).not.toContain('核对原任务结果')
|
||||
expect(document.querySelector('.identity-image-failure')).toBeNull()
|
||||
expect(button('生成失败,查看失败原因').getAttribute('aria-expanded')).toBe('false')
|
||||
button('生成失败,查看失败原因').click()
|
||||
await flushPromises()
|
||||
const original = document.querySelector<HTMLImageElement>('.n-image-preview')!
|
||||
expect(original.getAttribute('src')).toBe(main.attributes('src'))
|
||||
expect(original.style.objectFit).not.toBe('cover')
|
||||
const failure = document.querySelector('.identity-image-failure')!
|
||||
expect(failure.closest('.identity-failure-scroll.n-scrollbar')).not.toBeNull()
|
||||
expect(failure.closest('.identity-image-card')).toBeNull()
|
||||
expect(failure.closest('.app-dialog')).toBeNull()
|
||||
expect(button('生成失败,查看失败原因').getAttribute('aria-expanded')).toBe('true')
|
||||
expect(failure.textContent).toContain('图片生成中断,结果未确认')
|
||||
expect(failure.textContent).toContain('核对原任务结果')
|
||||
expect(failure.textContent).toContain('重复生成和计费')
|
||||
expect(failure.textContent).not.toContain('Provider')
|
||||
expect(failure.querySelector('button')).toBeNull()
|
||||
expect(failure.textContent).not.toContain('查看当前母版')
|
||||
document.querySelector<HTMLButtonElement>('[aria-label="身份候选管理"] .n-card-header__close')!.click()
|
||||
await flushPromises()
|
||||
expect(
|
||||
wrapper
|
||||
.findAllComponents(AppDialog)
|
||||
.find(item => item.props('title') === '身份候选管理')!
|
||||
.props('open')
|
||||
).toBe(false)
|
||||
button('管理候选(1)').click()
|
||||
await flushPromises()
|
||||
expect(button('生成失败,查看失败原因').getAttribute('aria-expanded')).toBe('false')
|
||||
button('生成失败,查看失败原因').click()
|
||||
await flushPromises()
|
||||
button('生成失败,查看失败原因').dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }))
|
||||
await flushPromises()
|
||||
expect(button('生成失败,查看失败原因').getAttribute('aria-expanded')).toBe('false')
|
||||
button('重新生成角色候选图').click()
|
||||
await flushPromises()
|
||||
expect(wrapper.emitted('regenerate')).toEqual([['interrupted']])
|
||||
expect(wrapper.emitted('anchor')).toBeUndefined()
|
||||
expect(
|
||||
wrapper
|
||||
.findAllComponents(AppDialog)
|
||||
.find(item => item.props('title') === '身份候选管理')!
|
||||
.props('open')
|
||||
).toBe(false)
|
||||
})
|
||||
|
||||
it('身份图库使用精简资产,不展示已移除的提示词、模型信息和启停状态', () => {
|
||||
wrapper = mount(IdentityGallery, {
|
||||
props: {
|
||||
subjectName: '林夏',
|
||||
module: 'character',
|
||||
identityLocked: true,
|
||||
disabled: false,
|
||||
images: [identityImageFixture({ provider: 'qwen-image', model: 'qwen-image-3.0-pro' })]
|
||||
}
|
||||
})
|
||||
expect(wrapper.text()).toContain('当前身份母版')
|
||||
expect(wrapper.text()).not.toContain('本次实际提示词')
|
||||
expect(wrapper.text()).not.toContain('停用')
|
||||
expect(wrapper.text()).not.toContain('qwen-image')
|
||||
expect(wrapper.text()).toContain('创建于')
|
||||
})
|
||||
|
||||
it('全部历史记录显示在预览下方,候选、辅助、失败和进行中图片均可切换查看', async () => {
|
||||
const images = [
|
||||
identityImageFixture({
|
||||
id: 'candidate',
|
||||
imageUrl: '/storage/candidate.png',
|
||||
isAnchor: false
|
||||
}),
|
||||
identityImageFixture({
|
||||
id: 'failed',
|
||||
status: 'failed',
|
||||
imageUrl: null,
|
||||
isAnchor: false,
|
||||
|
||||
error: '图片模型超时'
|
||||
}),
|
||||
identityImageFixture({ id: 'anchor', imageUrl: '/storage/anchor.png', width: 4096, height: 4096 }),
|
||||
identityImageFixture({ id: 'front', imageUrl: '/storage/front.png', viewType: 'front', isAnchor: false }),
|
||||
identityImageFixture({ id: 'pending', status: 'pending', imageUrl: null, isAnchor: false }),
|
||||
identityImageFixture({
|
||||
id: 'generating',
|
||||
status: 'generating',
|
||||
imageUrl: null,
|
||||
isAnchor: false
|
||||
})
|
||||
]
|
||||
wrapper = mount(IdentityGallery, {
|
||||
attachTo: document.body,
|
||||
props: { subjectName: '林夏', module: 'character', identityLocked: true, disabled: false, images }
|
||||
})
|
||||
const history = wrapper.get('[aria-label="身份图片历史"]')
|
||||
expect(history.findAll('.image-history-item')).toHaveLength(6)
|
||||
expect(wrapper.getComponent(NScrollbar).props()).toMatchObject({
|
||||
xScrollable: true,
|
||||
trigger: 'none',
|
||||
contentStyle: { width: 'max-content' }
|
||||
})
|
||||
expect(wrapper.get('.asset-image-preview').element.nextElementSibling?.textContent).toContain('历史记录 · 6 条')
|
||||
expect(wrapper.get('.image-history-heading').element.nextElementSibling).toBe(history.element)
|
||||
expect(history.text()).toContain('当前母版')
|
||||
expect(history.text()).toContain('母版候选')
|
||||
expect(history.text()).toContain('正面')
|
||||
expect(history.text()).toContain('生成失败')
|
||||
expect(history.text()).toContain('排队中')
|
||||
expect(history.text()).toContain('生成中')
|
||||
expect(history.get('[aria-label="查看身份图片 anchor"]').attributes('aria-pressed')).toBe('true')
|
||||
for (const image of images) {
|
||||
await history.get(`[aria-label="查看身份图片 ${image.id}"]`).trigger('click')
|
||||
expect(history.findAll('[aria-pressed="true"]')).toHaveLength(1)
|
||||
expect(history.get(`[aria-label="查看身份图片 ${image.id}"]`).attributes('aria-pressed')).toBe('true')
|
||||
const preview = wrapper
|
||||
.findAllComponents(AssetImage)
|
||||
.find(item => item.classes().includes('asset-image-preview'))!
|
||||
expect(preview.props('src')).toBe(image.status === 'completed' ? image.imageUrl : null)
|
||||
expect(preview.props('alt')).toBe(`林夏 · ${image.viewType === 'primary' ? '身份母版' : '正面'}`)
|
||||
}
|
||||
await history.get('[aria-label="查看身份图片 failed"]').trigger('click')
|
||||
expect(wrapper.get('.asset-image-preview').text()).toContain('本次生成失败')
|
||||
expect(wrapper.findAll('[role="alert"]').map(item => item.text())).toContain('图片模型超时')
|
||||
expect(button('确认选角并锁定').disabled).toBe(true)
|
||||
expect(wrapper.emitted('anchor')).toBeUndefined()
|
||||
})
|
||||
|
||||
it('刷新新增历史不会切回母版或重置横向位置,当前记录移除后才回退', async () => {
|
||||
const anchor = identityImageFixture({ id: 'anchor' })
|
||||
const front = identityImageFixture({ id: 'front', viewType: 'front', isAnchor: false })
|
||||
wrapper = mount(IdentityGallery, {
|
||||
props: {
|
||||
subjectName: '林夏',
|
||||
module: 'character',
|
||||
identityLocked: true,
|
||||
disabled: false,
|
||||
images: [anchor, front]
|
||||
}
|
||||
})
|
||||
await wrapper.get('[aria-label="查看身份图片 front"]').trigger('click')
|
||||
const viewport = wrapper.get<HTMLElement>('.image-history .n-scrollbar-container').element
|
||||
viewport.scrollLeft = 120
|
||||
await wrapper.setProps({ images: [identityImageFixture({ id: 'new', isAnchor: false }), anchor, front] })
|
||||
expect(wrapper.get('[aria-label="查看身份图片 front"]').attributes('aria-pressed')).toBe('true')
|
||||
expect(wrapper.get('.image-history .n-scrollbar-container').element).toBe(viewport)
|
||||
expect(viewport.scrollLeft).toBe(120)
|
||||
await wrapper.setProps({ images: [anchor] })
|
||||
expect(wrapper.get('[aria-label="查看身份图片 anchor"]').attributes('aria-pressed')).toBe('true')
|
||||
expect(wrapper.get('.image-history-heading').text()).toContain('历史记录 · 1 条')
|
||||
})
|
||||
|
||||
it('切换历史取消上一张的确认,只有再次确认才能发出当前候选 ID', async () => {
|
||||
it('辅助图失败保留真实原因,草稿阻塞时说明恢复方向并禁止重试', async () => {
|
||||
wrapper = mount(IdentityGallery, {
|
||||
attachTo: document.body,
|
||||
props: {
|
||||
@@ -199,30 +212,85 @@ describe('身份图与母版契约', () => {
|
||||
module: 'character',
|
||||
identityLocked: false,
|
||||
disabled: false,
|
||||
images: ['candidate-a', 'candidate-b'].map(id => identityImageFixture({ id, isAnchor: false }))
|
||||
retryDisabledReason: '请先保存身份文本修改,再重新生成图片。',
|
||||
images: [
|
||||
identityImageFixture({
|
||||
id: 'failed-front',
|
||||
viewType: 'front',
|
||||
status: 'failed',
|
||||
imageUrl: null,
|
||||
isAnchor: false,
|
||||
error: '图片模型超时'
|
||||
})
|
||||
]
|
||||
}
|
||||
})
|
||||
button('管理候选(1)').click()
|
||||
await flushPromises()
|
||||
expect(document.querySelector('[aria-label="身份图片 failed-front"]')!.textContent).not.toContain(
|
||||
'图片模型超时'
|
||||
)
|
||||
button('生成失败,查看失败原因').click()
|
||||
await flushPromises()
|
||||
const notice = document.querySelector('.identity-image-failure')!
|
||||
expect(notice.textContent).toContain('图片模型超时')
|
||||
expect(notice.textContent).not.toContain('后台服务重启')
|
||||
expect(notice.textContent).toContain('请先保存身份文本修改')
|
||||
expect(button('重新生成辅助参考图').disabled).toBe(true)
|
||||
button('重新生成辅助参考图').click()
|
||||
await flushPromises()
|
||||
expect(wrapper.emitted('regenerate')).toBeUndefined()
|
||||
await wrapper.setProps({ retryDisabledReason: '' })
|
||||
button('重新生成辅助参考图').click()
|
||||
await flushPromises()
|
||||
expect(wrapper.emitted('regenerate')).toEqual([['failed-front']])
|
||||
})
|
||||
|
||||
it('明确确认目标后才提交指定候选,刷新同一母版保持管理弹窗,新母版返回后关闭弹窗', async () => {
|
||||
const anchor = identityImageFixture({ id: 'anchor' })
|
||||
const candidate = identityImageFixture({ id: 'candidate', isAnchor: false })
|
||||
wrapper = mount(IdentityGallery, {
|
||||
attachTo: document.body,
|
||||
props: {
|
||||
subjectName: '林夏',
|
||||
module: 'character',
|
||||
identityLocked: true,
|
||||
disabled: false,
|
||||
images: [anchor, candidate]
|
||||
}
|
||||
})
|
||||
button('管理候选(1)').click()
|
||||
await flushPromises()
|
||||
const management = wrapper.findAllComponents(AppDialog).find(item => item.props('title') === '身份候选管理')!
|
||||
button('确认选角并锁定').click()
|
||||
await flushPromises()
|
||||
expect(document.querySelector('[role="dialog"][aria-label="确认选角并锁定"]')).not.toBeNull()
|
||||
expect(button('确认演员选择').disabled).toBe(false)
|
||||
await wrapper.get('[aria-label="查看身份图片 candidate-b"]').trigger('click')
|
||||
expect(wrapper.findComponent(AppDialog).props('open')).toBe(false)
|
||||
expect(wrapper.emitted('anchor')).toBeUndefined()
|
||||
button('取消').click()
|
||||
await flushPromises()
|
||||
expect(wrapper.emitted('anchor')).toBeUndefined()
|
||||
button('确认选角并锁定').click()
|
||||
await flushPromises()
|
||||
button('确认演员选择').click()
|
||||
expect(wrapper.emitted('anchor')).toEqual([['candidate-b']])
|
||||
})
|
||||
|
||||
it('无历史图片时只展示空状态,不伪造缩略图或母版', () => {
|
||||
wrapper = mount(IdentityGallery, {
|
||||
props: { subjectName: '林夏', module: 'character', identityLocked: false, disabled: false, images: [] }
|
||||
await flushPromises()
|
||||
expect(wrapper.emitted('anchor')).toEqual([['candidate']])
|
||||
expect(management.props('open')).toBe(true)
|
||||
await wrapper.setProps({
|
||||
images: [anchor, { ...candidate }, identityImageFixture({ id: 'new', isAnchor: false })]
|
||||
})
|
||||
expect(wrapper.text()).toContain('身份参考图 · 0')
|
||||
expect(wrapper.text()).toContain('尚无身份参考图')
|
||||
expect(wrapper.find('.image-history').exists()).toBe(false)
|
||||
expect(wrapper.find('.asset-image-preview').exists()).toBe(false)
|
||||
expect(management.props('open')).toBe(true)
|
||||
expect(wrapper.get('.identity-anchor-grid .identity-image-card').attributes('aria-label')).toBe(
|
||||
'身份图片 anchor'
|
||||
)
|
||||
await wrapper.setProps({
|
||||
images: [
|
||||
{ ...anchor, isAnchor: false },
|
||||
{ ...candidate, isAnchor: true }
|
||||
]
|
||||
})
|
||||
expect(management.props('open')).toBe(false)
|
||||
expect(wrapper.get('.identity-anchor-grid .identity-image-card').attributes('aria-label')).toBe(
|
||||
'身份图片 candidate'
|
||||
)
|
||||
})
|
||||
|
||||
it('启用的辅助视角不是母版,primary 候选停用时仍可选为母版', () => {
|
||||
@@ -347,7 +415,7 @@ describe('身份图与母版契约', () => {
|
||||
expect(select.props('value')).toBe('front')
|
||||
})
|
||||
|
||||
it('辅助图不能切换母版,精简资产不展示内部提示词', async () => {
|
||||
it('辅助图只有校验入口,不能通过候选弹窗切换母版', async () => {
|
||||
wrapper = mount(IdentityGallery, {
|
||||
attachTo: document.body,
|
||||
props: {
|
||||
@@ -358,10 +426,12 @@ describe('身份图与母版契约', () => {
|
||||
images: [identityImageFixture({ viewType: 'front', isAnchor: false })]
|
||||
}
|
||||
})
|
||||
expect(button('确认选角并锁定').disabled).toBe(true)
|
||||
await expandSections()
|
||||
expect(wrapper.text()).not.toContain('本次实际提示词')
|
||||
expect(wrapper.find('script').exists()).toBe(false)
|
||||
button('管理候选(1)').click()
|
||||
await flushPromises()
|
||||
const card = wrapper.findAllComponents(IdentityImageCard)[0]!
|
||||
expect(card.findAllComponents(NButton).some(item => item.text() === '确认选角并锁定')).toBe(false)
|
||||
expect(card.text()).toContain('不能直接设为身份母版')
|
||||
expect(card.text()).not.toContain('本次实际提示词')
|
||||
expect(wrapper.emitted('anchor')).toBeUndefined()
|
||||
})
|
||||
|
||||
@@ -383,7 +453,7 @@ describe('身份图与母版契约', () => {
|
||||
expect(wrapper.emitted('anchor')).toEqual([['identity-image-1']])
|
||||
})
|
||||
|
||||
it('图片操作加载只对应提交目标,不能重复确认,切换图片不会错误显示加载', async () => {
|
||||
it('多张候选同时可见时加载只绑定提交目标,操作期间所有重复提交均禁用', async () => {
|
||||
wrapper = mount(IdentityGallery, {
|
||||
attachTo: document.body,
|
||||
props: {
|
||||
@@ -394,24 +464,28 @@ describe('身份图与母版契约', () => {
|
||||
images: ['first', 'second'].map(id => identityImageFixture({ id, isAnchor: false }))
|
||||
}
|
||||
})
|
||||
button('管理候选(2)').click()
|
||||
await flushPromises()
|
||||
const cards = wrapper.findAllComponents(IdentityImageCard)
|
||||
const first = cards.find(item => item.props('image').id === 'first')!
|
||||
const second = cards.find(item => item.props('image').id === 'second')!
|
||||
await wrapper.setProps({
|
||||
pendingOperation: { projectId: 'project-1', subjectId: 'subject-1', imageId: 'first', kind: 'confirm' }
|
||||
})
|
||||
const confirm = wrapper.findAllComponents(NButton).find(item => item.text() === '确认选角并锁定')!
|
||||
expect(confirm.props('loading')).toBe(true)
|
||||
expect(button('确认选角并锁定').disabled).toBe(true)
|
||||
button('确认选角并锁定').click()
|
||||
expect(cardButton(first, '确认选角并锁定').props('loading')).toBe(true)
|
||||
expect(cardButton(second, '确认选角并锁定').props('loading')).toBe(false)
|
||||
expect(cardButton(first, '确认选角并锁定').props('disabled')).toBe(true)
|
||||
expect(cardButton(second, '确认选角并锁定').props('disabled')).toBe(true)
|
||||
await cardButton(second, '确认选角并锁定').trigger('click')
|
||||
expect(wrapper.emitted('anchor')).toBeUndefined()
|
||||
await wrapper.get('[aria-label="查看身份图片 second"]').trigger('click')
|
||||
expect(confirm.props('loading')).toBe(false)
|
||||
await wrapper.setProps({
|
||||
pendingOperation: { projectId: 'project-1', subjectId: 'subject-1', imageId: 'second', kind: 'validate' }
|
||||
})
|
||||
const validate = wrapper.findAllComponents(NButton).find(item => item.text() === '校验此身份图片')!
|
||||
expect(validate.props('loading')).toBe(true)
|
||||
expect(button('校验此身份图片').disabled).toBe(true)
|
||||
expect(cardButton(first, '校验此身份图片').props('loading')).toBe(false)
|
||||
expect(cardButton(second, '校验此身份图片').props('loading')).toBe(true)
|
||||
expect(cardButton(second, '校验此身份图片').props('disabled')).toBe(true)
|
||||
await wrapper.setProps({ pendingOperation: null })
|
||||
expect(validate.props('loading')).toBe(false)
|
||||
expect(cardButton(second, '校验此身份图片').props('loading')).toBe(false)
|
||||
})
|
||||
|
||||
it('选角候选发送当前图片 Provider 与动态参数,不携带旧宽高字段', async () => {
|
||||
|
||||
@@ -350,7 +350,7 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('生成进度与失败提示位于两栏上方,切换主体后不会保留其它主体的状态,完成后隐藏', async () => {
|
||||
it('生成进度保留全栏提示,失败详情按需在浮层显示,切换后不串主体状态', async () => {
|
||||
/** 两个主体分别处于生成中与失败状态,所有查询均使用隔离的测试响应。 */
|
||||
const first = formFixture()
|
||||
const second = { ...formFixture(), id: 'second-form', subjectId: 'second-subject', images: [] }
|
||||
@@ -398,9 +398,16 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
.find(item => item.text().includes('第二个主体'))!
|
||||
.trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper!.get('.identity-generation-feedback').text()).toContain('模型暂时不可用')
|
||||
expect(wrapper!.get('.identity-generation-feedback').text()).not.toContain('林知夏 的身份图片正在生成')
|
||||
expect(wrapper!.findAll('.identity-generation-feedback')).toHaveLength(1)
|
||||
expect(wrapper!.find('.identity-generation-feedback').exists()).toBe(false)
|
||||
expect(wrapper!.find('.identity-image-failure').exists()).toBe(false)
|
||||
button('管理候选(1)').click()
|
||||
await flushPromises()
|
||||
expect(document.querySelector('.identity-candidate-grid')?.textContent).not.toContain('模型暂时不可用')
|
||||
expect(document.querySelector('.identity-image-failure')).toBeNull()
|
||||
button('生成失败,查看失败原因').click()
|
||||
await flushPromises()
|
||||
expect(document.querySelector('.identity-image-failure')?.textContent).toContain('模型暂时不可用')
|
||||
expect(document.querySelectorAll('.identity-image-failure')).toHaveLength(1)
|
||||
vi.mocked(subjectIdentityApi.listImages).mockResolvedValue([
|
||||
identityImageFixture({ identityId: `identity-${second.subjectId}`, status: 'completed' })
|
||||
])
|
||||
@@ -411,6 +418,7 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
.trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper!.find('.identity-generation-feedback').exists()).toBe(false)
|
||||
expect(document.querySelector('.identity-image-failure')).toBeNull()
|
||||
})
|
||||
|
||||
it('主体目录与详情分别显示骨架,查询失败结束占位并可重试恢复', async () => {
|
||||
@@ -448,7 +456,7 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
expect(wrapper!.get('.subject-identity-skeleton').attributes('aria-busy')).toBe('true')
|
||||
expect(wrapper!.get('.subject-identity-skeleton').text()).toBe('')
|
||||
expect(wrapper!.find('#identity-description').exists()).toBe(false)
|
||||
expect(wrapper!.text()).not.toContain('尚无身份参考图')
|
||||
expect(wrapper!.text()).not.toContain('尚无身份母版')
|
||||
rejectCatalog(new Error('主体目录读取失败'))
|
||||
await flushPromises()
|
||||
expect(wrapper!.find('.subject-identity-skeleton').exists()).toBe(false)
|
||||
@@ -467,7 +475,7 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
button('刷新身份').click()
|
||||
await flushPromises()
|
||||
expect(wrapper!.get<HTMLInputElement>('#identity-description').element.value).toBe('')
|
||||
expect(wrapper!.text()).toContain('尚无身份参考图')
|
||||
expect(wrapper!.text()).toContain('尚无身份母版')
|
||||
})
|
||||
|
||||
it('已有身份刷新保留草稿与图库,图片操作归属图库并遵守未保存限制', async () => {
|
||||
@@ -1071,6 +1079,8 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
})
|
||||
stubFetch(fetcher)
|
||||
await mountAssets('identity')
|
||||
button('管理候选(1)').click()
|
||||
await flushPromises()
|
||||
button('设为身份母版').click()
|
||||
await flushPromises()
|
||||
expect(fetcher.mock.calls.some(([, init]) => init?.method === 'PUT')).toBe(false)
|
||||
@@ -1079,14 +1089,13 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
expect(fetcher.mock.calls.find(([, init]) => init?.method === 'PUT')?.[0]).toBe(
|
||||
'/api/subjects/subject-db-1/identity/images/candidate/stable-anchor'
|
||||
)
|
||||
expect(wrapper!.text()).toContain('当前身份母版')
|
||||
expect(wrapper!.text()).toContain('身份母版')
|
||||
expect(getOperation(fixture.id)).toMatchObject({
|
||||
noticeType: 'success',
|
||||
notice: '林知夏 的身份母版已确认并锁定。'
|
||||
})
|
||||
const anchorImage = wrapper!
|
||||
.findAllComponents(NImage)
|
||||
.find(image => image.props('alt')?.endsWith('当前身份母版'))!
|
||||
// 仅检查正文母版预览,目录缩略图使用相同身份标识但不提供原图预览。
|
||||
const anchorImage = wrapper!.get('.identity-anchor-grid').getComponent(NImage)
|
||||
expect(anchorImage.props()).toMatchObject({ objectFit: 'cover', previewDisabled: false })
|
||||
})
|
||||
|
||||
@@ -1202,6 +1211,8 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
stubFetch(fetcher)
|
||||
await mountAssets('identity')
|
||||
expect(wrapper!.text()).toContain('等待确认演员')
|
||||
button('管理候选并确认').click()
|
||||
await flushPromises()
|
||||
button('确认选角并锁定').click()
|
||||
await flushPromises()
|
||||
button('确认演员选择').click()
|
||||
@@ -1210,7 +1221,7 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
expect(put[0]).toBe('/api/subjects/subject-db-1/identity/images/casting-1/casting')
|
||||
expect(fetcher.mock.calls.some(([url]) => String(url).endsWith('/anchor'))).toBe(false)
|
||||
expect(wrapper!.text()).toContain('主体身份已完成')
|
||||
expect(wrapper!.text()).toContain('演员身份已确认并锁定')
|
||||
expect(wrapper!.get('.identity-gallery').text()).toContain('已确认并锁定')
|
||||
})
|
||||
|
||||
it('切换主体会取消旧查询,迟到的身份结果不覆盖当前主体', async () => {
|
||||
|
||||
Reference in new issue
Block a user