feat: 增加操作步骤引导与错误修复入口
This commit is contained in:
1 parent
be06caaa9f
commit
1c5b1e448a
8 files changed
+374
-122
No files matched your search
@@ -17,8 +17,8 @@ import {
|
||||
NTag
|
||||
} from 'naive-ui'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { RefreshCw, UserCheck } from '@lucide/vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { Check, Circle, RefreshCw, UserCheck } from '@lucide/vue'
|
||||
import { AssetImage, DirectoryItem, EmptyState, StatusBadge } from '../../components/ui'
|
||||
import { downloadText } from '../../lib/format'
|
||||
import ConfirmAction from '../workflows/ConfirmAction.vue'
|
||||
@@ -29,10 +29,12 @@ 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 CreativeProfileSettings from '../generation-config/components/CreativeProfileSettings.vue'
|
||||
import type { IdentitySubject } from './types'
|
||||
|
||||
/** 主体身份工作区按正式主体聚合,不把同一主体的多个 Form 当成不同身份。 */
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const {
|
||||
projectId,
|
||||
operation,
|
||||
@@ -42,10 +44,10 @@ const {
|
||||
catalog,
|
||||
castingQuery,
|
||||
styleQuery,
|
||||
profileQuery,
|
||||
detail,
|
||||
identity,
|
||||
images,
|
||||
castingItem,
|
||||
session,
|
||||
concurrency,
|
||||
candidateLimit,
|
||||
@@ -56,6 +58,7 @@ const {
|
||||
castingBlocked,
|
||||
detailBlocked,
|
||||
hasStyle,
|
||||
hasCreativeProfile,
|
||||
canGenerateText,
|
||||
canGenerateImage,
|
||||
canGenerateCandidate,
|
||||
@@ -162,6 +165,121 @@ watch(
|
||||
)
|
||||
const formModel = computed(() => ({ concurrency: concurrency.value, candidateLimit: candidateLimit.value }))
|
||||
const rules = { concurrency: integerRule('并发数'), candidateLimit: integerRule('本批上限') }
|
||||
|
||||
type IdentityFlowAction = 'style' | 'profile' | 'identity' | 'candidate' | 'confirm' | 'lock' | 'forms'
|
||||
const primaryCandidate = computed(() =>
|
||||
images.value.find(image => image.viewType === 'primary' && image.status === 'completed' && image.imageUrl)
|
||||
)
|
||||
const identityTextReady = computed(() => !!identity.value?.generationPrompt?.trim())
|
||||
const candidateReady = computed(() => !!anchor.value || !!primaryCandidate.value)
|
||||
const identityReady = computed(() => !!anchor.value && !!identity.value?.isLocked)
|
||||
const identityFlow = computed(() => {
|
||||
const character = subject.value?.module === 'character'
|
||||
return [
|
||||
{ label: '身份文本', done: identityTextReady.value },
|
||||
{ label: character ? '选角候选' : '身份参考图', done: candidateReady.value },
|
||||
{ label: '确认并锁定', done: identityReady.value }
|
||||
]
|
||||
})
|
||||
const currentFlowIndex = computed(() => {
|
||||
const index = identityFlow.value.findIndex(step => !step.done)
|
||||
return index < 0 ? identityFlow.value.length : index
|
||||
})
|
||||
const nextAction = computed<{ action: IdentityFlowAction; title: string; description: string; label: string }>(() => {
|
||||
if (!hasStyle.value)
|
||||
return {
|
||||
action: 'style',
|
||||
title: '先设置视觉风格',
|
||||
description: '身份生成需要项目视觉风格。',
|
||||
label: '设置视觉风格'
|
||||
}
|
||||
if (!hasCreativeProfile.value)
|
||||
return {
|
||||
action: 'profile',
|
||||
title: '先配置生成模型',
|
||||
description: '选择项目图片与视频模型后才能生图。',
|
||||
label: '配置生成模型'
|
||||
}
|
||||
if (!identityTextReady.value)
|
||||
return {
|
||||
action: 'identity',
|
||||
title: '第 1 步:生成身份文本',
|
||||
description: '生成稳定身份描述和核心提示词。',
|
||||
label: '生成身份文本'
|
||||
}
|
||||
if (!candidateReady.value)
|
||||
return subject.value?.module === 'character'
|
||||
? {
|
||||
action: 'candidate',
|
||||
title: '第 2 步:生成选角候选',
|
||||
description: '生成候选后再确认正式演员。',
|
||||
label: '生成选角候选'
|
||||
}
|
||||
: {
|
||||
action: 'candidate',
|
||||
title: '第 2 步:生成身份参考图',
|
||||
description: '生成一张可选为母版的参考图。',
|
||||
label: '生成身份参考图'
|
||||
}
|
||||
if (anchor.value && !identity.value?.isLocked)
|
||||
return {
|
||||
action: 'lock',
|
||||
title: '第 3 步:锁定身份',
|
||||
description: '勾选锁定并保存,后续生成才会稳定引用当前母版。',
|
||||
label: '前往锁定'
|
||||
}
|
||||
if (!identityReady.value)
|
||||
return {
|
||||
action: 'confirm',
|
||||
title: '第 3 步:确认并锁定',
|
||||
description: '在下方选择母版;人物会同时锁定,场景和道具还需保存锁定状态。',
|
||||
label: '前往确认母版'
|
||||
}
|
||||
return {
|
||||
action: 'forms',
|
||||
title: '主体身份已完成',
|
||||
description: '可以继续生成此主体的形态图片。',
|
||||
label: '查看形态图片'
|
||||
}
|
||||
})
|
||||
|
||||
function openProfileSettings() {
|
||||
toolsOpen.value = true
|
||||
overview.value = []
|
||||
if (route.query.configure !== 'profile') void router.replace({ query: { ...route.query, configure: 'profile' } })
|
||||
}
|
||||
|
||||
function runNextAction() {
|
||||
if (nextAction.value.action === 'style') void router.push(`/projects/${projectId.value}/visual-style`)
|
||||
else if (nextAction.value.action === 'profile') openProfileSettings()
|
||||
else if (nextAction.value.action === 'identity') void generate()
|
||||
else if (nextAction.value.action === 'candidate') {
|
||||
if (subject.value?.module === 'character') castingOpen.value = true
|
||||
else imageOpen.value = true
|
||||
} else if (nextAction.value.action === 'confirm') {
|
||||
document.querySelector('#identity-reference-gallery')?.scrollIntoView({ behavior: 'smooth', block: 'start' })
|
||||
} else if (nextAction.value.action === 'lock') {
|
||||
document.querySelector('#identity-lock')?.scrollIntoView({ behavior: 'smooth', block: 'center' })
|
||||
} else if (nextAction.value.action === 'forms') {
|
||||
void router.push({
|
||||
path: `/projects/${projectId.value}/subject-images`,
|
||||
query: { subjectRef: subject.value?.ref }
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
async function profileSaved() {
|
||||
operation.value.error = ''
|
||||
await profileQuery.refresh()
|
||||
}
|
||||
|
||||
watch(
|
||||
() => route.query.configure,
|
||||
value => {
|
||||
if (value === 'profile') openProfileSettings()
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -188,6 +306,7 @@ const rules = { concurrency: integerRule('并发数'), candidateLimit: integerRu
|
||||
title="角色选角总览与批量操作"
|
||||
:has-receipt="!!session.receipt"
|
||||
>
|
||||
<CreativeProfileSettings :project-id="projectId" @saved="profileSaved" />
|
||||
<div class="identity-tools-intro flex flex-wrap items-end justify-between gap-4">
|
||||
<div>
|
||||
<h2 class="text-lg font-semibold">主体身份</h2>
|
||||
@@ -503,6 +622,17 @@ const rules = { concurrency: integerRule('并发数'), candidateLimit: integerRu
|
||||
当前相关操作已暂停,请刷新核对后端。
|
||||
</NAlert></NScrollbar
|
||||
>
|
||||
<NAlert
|
||||
v-if="profileQuery.data.value && !hasCreativeProfile"
|
||||
type="warning"
|
||||
:show-icon="false"
|
||||
class="identity-prerequisite"
|
||||
>
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<span><strong>需要先配置项目生成模型</strong>,否则身份图和选角候选无法生成。</span>
|
||||
<NButton type="primary" @click="openProfileSettings">立即配置</NButton>
|
||||
</div>
|
||||
</NAlert>
|
||||
<div v-if="subjects.length" class="identity-workspace">
|
||||
<!-- 以下是主体目录 -->
|
||||
<aside class="panel directory-panel identity-directory">
|
||||
@@ -579,20 +709,6 @@ const rules = { concurrency: integerRule('并发数'), candidateLimit: integerRu
|
||||
<h3 class="font-semibold">
|
||||
{{ subject.name }} <code class="subject-ref ml-2">{{ subject.ref }}</code>
|
||||
</h3>
|
||||
<p class="mt-2 text-xs text-muted">
|
||||
<template v-if="subject.module === 'character' && castingItem">
|
||||
选角状态:{{ castingStatusLabel(castingItem.status) }}
|
||||
</template>
|
||||
<template v-else>
|
||||
{{
|
||||
identity
|
||||
? identity.isLocked
|
||||
? '身份文本已锁定'
|
||||
: '身份文本未锁定'
|
||||
: '尚未创建身份'
|
||||
}}
|
||||
</template>
|
||||
</p>
|
||||
</div>
|
||||
<NButton :disabled="detail.loading.value" @click="detail.refresh" text size="small">
|
||||
刷新身份
|
||||
@@ -605,25 +721,39 @@ const rules = { concurrency: integerRule('并发数'), candidateLimit: integerRu
|
||||
正在读取主体身份…
|
||||
</p>
|
||||
<template v-if="detail.data.value">
|
||||
<div class="mt-4 flex flex-wrap gap-3">
|
||||
<ConfirmAction
|
||||
:label="identity ? 'AI 重新生成身份' : 'AI 生成身份'"
|
||||
:disabled="!canGenerateText"
|
||||
acknowledgement
|
||||
description="调用文本模型生成稳定身份描述和提示词。旧图片不会自动重生成;已锁定身份需先解锁并保存。"
|
||||
@confirm="generate"
|
||||
/><NButton
|
||||
v-if="subject.module === 'character'"
|
||||
:disabled="!canGenerateCandidate"
|
||||
@click="castingOpen = true"
|
||||
>
|
||||
生成选角候选</NButton
|
||||
><NButton
|
||||
v-if="subject.module !== 'character' || !!anchor"
|
||||
:disabled="!canGenerateImage"
|
||||
@click="imageOpen = true"
|
||||
>{{ subject.module === 'character' ? '生成辅助身份图' : '生成身份参考图' }}</NButton
|
||||
>
|
||||
<div class="identity-flow mt-4" 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
|
||||
type="primary"
|
||||
:disabled="
|
||||
operation.pending ||
|
||||
(nextAction.action === 'identity' && !canGenerateText) ||
|
||||
(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
|
||||
@@ -657,6 +787,7 @@ const rules = { concurrency: integerRule('并发数'), candidateLimit: integerRu
|
||||
</div>
|
||||
</div>
|
||||
<IdentityGallery
|
||||
id="identity-reference-gallery"
|
||||
:key="selectedId"
|
||||
:images="images"
|
||||
:subject-name="subject.name"
|
||||
@@ -748,6 +879,38 @@ const rules = { concurrency: integerRule('并发数'), candidateLimit: integerRu
|
||||
.identity-workspace-page {
|
||||
container: identity-header / inline-size;
|
||||
}
|
||||
.identity-prerequisite {
|
||||
@apply shrink-0 mx-0 mb-3;
|
||||
}
|
||||
.identity-flow {
|
||||
@apply p-4 bg-(--app-subtle);
|
||||
}
|
||||
.identity-flow-steps {
|
||||
@apply flex flex-wrap items-center gap-x-6 gap-y-2;
|
||||
}
|
||||
.identity-flow-steps li {
|
||||
@apply flex items-center gap-2 text-xs text-muted;
|
||||
}
|
||||
.identity-flow-steps li.current {
|
||||
@apply text-accent font-semibold;
|
||||
}
|
||||
.identity-flow-steps li.done {
|
||||
@apply text-muted;
|
||||
}
|
||||
.identity-flow-marker {
|
||||
@apply grid place-items-center w-5 h-5 rounded-full border border-(--app-border);
|
||||
}
|
||||
.identity-flow-steps li.done .identity-flow-marker,
|
||||
.identity-flow-steps li.current .identity-flow-marker {
|
||||
@apply border-(--app-accent) text-accent;
|
||||
}
|
||||
.identity-next-action {
|
||||
@apply mt-4 pt-4 flex items-center justify-between gap-4;
|
||||
border-top: 1px solid var(--app-border);
|
||||
}
|
||||
.identity-next-action p {
|
||||
@apply mt-1 text-xs text-muted;
|
||||
}
|
||||
.toolbar-type-filter {
|
||||
@apply w-[152px] min-w-0;
|
||||
}
|
||||
@@ -843,6 +1006,9 @@ const rules = { concurrency: integerRule('并发数'), candidateLimit: integerRu
|
||||
@apply shrink-0;
|
||||
}
|
||||
@media (max-width: 760px) {
|
||||
.identity-next-action {
|
||||
@apply items-start flex-col;
|
||||
}
|
||||
.identity-workspace {
|
||||
@apply grid-cols-[minmax(0,_1fr)] grid-rows-[auto_minmax(0,_1fr)] gap-2.5;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user