feat(short-drama-agent-front): 完善主体身份骨架屏与交互反馈
This commit is contained in:
1 parent
5fa1c251a9
commit
dd0bd79a35
19 files changed
+1552
-419
No files matched your search
@@ -2,21 +2,25 @@
|
||||
import ConfirmAction from '../../workflows/ConfirmAction.vue'
|
||||
import { NScrollbar, NAlert, NButton, NTag } from 'naive-ui'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { AssetImage, StatusBadge } from '../../../components/ui'
|
||||
import { referenceImageUrl } from '../../../lib/assets'
|
||||
import { AppDialog, AssetImage, StatusBadge } from '../../../components/ui'
|
||||
import { formatDate } from '../../../lib/format'
|
||||
import { canBeAnchor, currentAnchor, identityViewLabels } from '../model'
|
||||
import type { IdentityImage, IdentityValidationResult } from '../types'
|
||||
import type { IdentityImage, IdentityImageOperation } from '../types'
|
||||
|
||||
/** 身份图库区分权威母版、primary 候选和辅助视图,保留后端原始状态。 */
|
||||
const props = defineProps<{
|
||||
/** 指定图片本次校验回执。 */
|
||||
validationResult?: IdentityValidationResult | null
|
||||
/** 正式身份图片列表。 */
|
||||
images: IdentityImage[]
|
||||
/** 当前主体名称。 */
|
||||
subjectName: string
|
||||
/** 主体类型。 */
|
||||
module: string
|
||||
/** 身份是否已经锁定。 */
|
||||
identityLocked: boolean
|
||||
/** 当前项目或主体是否禁止写入。 */
|
||||
disabled: boolean
|
||||
/** 当前确认或校验请求的固定图片目标。 */
|
||||
pendingOperation?: IdentityImageOperation | null
|
||||
}>()
|
||||
/** 用户确认的图片操作。 */
|
||||
const emit = defineEmits<{ anchor: [imageId: string]; validate: [imageId: string] }>()
|
||||
@@ -32,16 +36,23 @@ const selected = computed(
|
||||
)
|
||||
/** 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))
|
||||
)
|
||||
/** imageUrl 的当前界面状态与输入绑定。 */
|
||||
const imageUrl = computed(() => referenceImageUrl(selected.value?.imageUrl ?? ''))
|
||||
/** 监听界面目标变化并重置关联确认状态。 */
|
||||
watch(
|
||||
() => selected.value?.id,
|
||||
@@ -59,10 +70,14 @@ function chooseAnchor() {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="mt-5 pt-5" aria-label="身份参考图库">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<h3 class="text-sm font-medium">身份参考图 · {{ images.length }}</h3>
|
||||
<NTag size="small" :bordered="false">{{ anchor ? '已选母版' : '尚无母版' }}</NTag>
|
||||
<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>
|
||||
</div>
|
||||
<template v-if="selected">
|
||||
<AssetImage
|
||||
@@ -112,7 +127,8 @@ function chooseAnchor() {
|
||||
<span class="image-history-meta"><StatusBadge :status="image.status" /></span>
|
||||
</NButton>
|
||||
</NScrollbar>
|
||||
<div class="mt-3 flex flex-wrap items-center justify-between gap-3">
|
||||
<!-- 以下是当前图片的状态、尺寸与创建时间模块,模型信息不参与展示 -->
|
||||
<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
|
||||
@@ -121,68 +137,101 @@ function chooseAnchor() {
|
||||
? '母版候选'
|
||||
: identityViewLabels[selected.viewType]
|
||||
}}</NTag
|
||||
><span class="text-xs text-muted">{{ selected.width || '—' }} × {{ selected.height || '—' }}</span>
|
||||
><span v-if="selected.width && selected.height" class="text-xs text-muted"
|
||||
>{{ selected.width }} × {{ selected.height }}</span
|
||||
>
|
||||
</div>
|
||||
<a
|
||||
v-if="imageUrl && selected.status === 'completed'"
|
||||
:href="imageUrl"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="text-button"
|
||||
>打开原图</a
|
||||
<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="mt-3 flex flex-wrap items-center gap-3">
|
||||
<!-- 以下是当前图片的确认母版与质量校验模块,原图通过上方图片预览查看 -->
|
||||
<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
|
||||
><span class="text-[11px] text-muted"
|
||||
>{{ selected.provider }} · {{ selected.model }} · {{ formatDate(selected.createdAt) }}</span
|
||||
>
|
||||
<ConfirmAction
|
||||
:key="selected.id"
|
||||
label="校验此身份图片"
|
||||
:description="`将校验图片 ${selected.id},会调用视觉模型并可能产生费用,不会切换母版。`"
|
||||
:disabled="disabled || selected.status !== 'completed' || !selected.imageUrl"
|
||||
:loading="validateLoading"
|
||||
acknowledgement
|
||||
@confirm="emit('validate', selected.id)"
|
||||
/>
|
||||
</div>
|
||||
<!-- 以下是指定身份图片质量校验模块 -->
|
||||
<ConfirmAction
|
||||
:key="selected.id"
|
||||
label="校验此身份图片"
|
||||
:description="`将校验图片 ${selected.id},会调用视觉模型并可能产生费用,不会切换母版。`"
|
||||
:disabled="disabled || selected.status !== 'completed' || !selected.imageUrl"
|
||||
acknowledgement
|
||||
@confirm="emit('validate', selected.id)"
|
||||
/>
|
||||
<NAlert
|
||||
v-if="validationResult?.imageId === selected.id"
|
||||
:type="validationResult.passed ? 'success' : 'warning'"
|
||||
class="mt-3"
|
||||
>
|
||||
<p>{{ validationResult.passed ? '本次校验通过' : '本次校验未通过' }}:{{ validationResult.summary }}</p>
|
||||
<p v-for="(issue, index) in validationResult.issues" :key="index">
|
||||
{{ issue.severity }} · {{ issue.type }}:{{ issue.description }}
|
||||
</p>
|
||||
</NAlert>
|
||||
<p v-if="selected.viewType !== 'primary'" class="mt-2 text-xs text-muted">
|
||||
辅助视图不能直接设为母版;它会继承当前身份母版,不适合用来更换演员。
|
||||
</p>
|
||||
<NAlert v-if="confirming" type="info" :show-icon="false" class="mt-3"
|
||||
><p class="text-xs">
|
||||
{{
|
||||
character
|
||||
? '确认选择这张图片作为正式演员?后端会在同一事务中切换身份母版并锁定 Identity,完成后首帧才具备稳定人物身份。'
|
||||
: '确认切换身份母版?旧 primary 母版将停用并保留。身份锁定后,后续场景/道具形态生图会引用新母版。此操作不调用模型。'
|
||||
}}
|
||||
</p>
|
||||
<div class="mt-3 flex gap-3">
|
||||
<!-- 以下是确认母版弹窗模块,操作确认不会被图库滚动位置遮住 -->
|
||||
<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
|
||||
><NButton @click="confirming = false" text size="small">取消</NButton>
|
||||
</div></NAlert
|
||||
>
|
||||
}}</NButton>
|
||||
</div>
|
||||
</AppDialog>
|
||||
</template>
|
||||
<p v-else class="py-8 text-sm text-muted">尚无身份参考图。先保存身份提示词,再生成第一张母版。</p>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
@reference "../../../styles/styles.css";
|
||||
/* 保存留在编辑器,图片入口随图库标题排列;换行后继续沿用同一左右边界。 */
|
||||
.identity-gallery-toolbar {
|
||||
@apply flex flex-wrap items-center justify-between gap-x-4 gap-y-3;
|
||||
}
|
||||
.identity-gallery-title,
|
||||
.identity-gallery-actions {
|
||||
@apply flex flex-wrap min-w-0 items-center gap-2;
|
||||
}
|
||||
/* 身份历史缩略图等宽等高,保留顶部裁切;上方大图继续完整预览。 */
|
||||
.identity-gallery .image-history-item .asset-image {
|
||||
height: auto;
|
||||
aspect-ratio: 1;
|
||||
}
|
||||
/* 状态、时间与确认校验分别排列,信息栏与按钮之间保留统一间距。 */
|
||||
.identity-image-meta {
|
||||
@apply mt-4 flex flex-wrap items-center justify-between gap-x-4 gap-y-2;
|
||||
}
|
||||
.identity-image-created {
|
||||
@apply text-[11px] text-muted whitespace-nowrap;
|
||||
}
|
||||
.identity-image-actions {
|
||||
@apply mt-4 flex flex-wrap min-w-0 items-center gap-3;
|
||||
}
|
||||
@media (max-width: 760px) {
|
||||
.identity-gallery-actions {
|
||||
@apply w-full;
|
||||
}
|
||||
.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