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
@@ -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>
|
||||
Reference in new issue
Block a user