feat(short-drama-agent-front): 接入关系修复并优化配置与弹窗

This commit is contained in:
GJ committed 2026-10-31 22:37:22 +08:00
1 parent 2db8549818
commit 41d1cfe3ed
15 files changed
+1134 -323

No files matched your search

@@ -22,10 +22,11 @@ import {
NTag,
type ScrollbarInst
} from 'naive-ui'
import { computed, ref, watch } from 'vue'
import { computed, inject, ref, watch } from 'vue'
import { useRoute, useRouter, type LocationQueryRaw } from 'vue-router'
import { Check, Circle, UserCheck } from '@lucide/vue'
import { DirectoryItem, EmptyState, StatusBadge } from '../../components/ui'
import { AppDialog, DirectoryItem, EmptyState, StatusBadge } from '../../components/ui'
import { projectSettingsOpenKey } from '../generation-config/context'
import { downloadText } from '../../lib/format'
import ConfirmAction from '../workflows/ConfirmAction.vue'
import { castingStatusLabel, currentAnchor } from './model'
@@ -74,6 +75,8 @@ const {
canGenerateText,
canGenerateImage,
canGenerateCandidate,
canRequestImage,
canRequestCandidate,
activeIdentityGeneration,
batchValid,
candidateLimitValid,
@@ -294,6 +297,59 @@ function retryIdentityImage(imageId: string) {
}
/** 批量操作抽屉显隐状态,新回执到达时自动打开以展示结果。 */
const toolsOpen = ref(false)
/** 缺少模型时只展示轻量引导,不保存配置或启动生成。 */
const modelPromptOpen = ref(false)
/** 复用右上角已有项目配置抽屉。 */
const openProjectSettings = inject(projectSettingsOpenKey, undefined)
/** 从批量抽屉交接到提示弹窗时绑定当前项目。 */
const pendingModelProject = ref('')
/** 提示关闭后才打开现有配置抽屉,避免焦点叠加。 */
const pendingConfigProject = ref('')
/** 批量生图同样等待真实配置读取,读取失败不能当作尚未配置。 */
const modelQueryBlocked = computed(
() => !profileQuery.data.value || profileQuery.loading.value || !!profileQuery.error.value
)
/**
* 共用的生图前置检查,仅缺少配置时显示引导,不默认接受费用。
* @returns 是否可以继续打开生成参数或费用确认
*/
function ensureGenerationProfile(): boolean {
if (blocked.value || modelQueryBlocked.value) return false
if (hasCreativeProfile.value) return true
if (toolsOpen.value) {
pendingModelProject.value = projectId.value
toolsOpen.value = false
} else modelPromptOpen.value = true
return false
}
/**
* 单主体共用生图入口,先检查配置,再显示原有生成表单。
* @param target 当前用户选择的图片生成类型
*/
function requestImage(target: 'image' | 'casting' | 'quality') {
if (!(target === 'casting' ? canRequestCandidate.value : canRequestImage.value) || !ensureGenerationProfile())
return
if (target === 'casting') castingOpen.value = true
else if (target === 'quality') qualityOpen.value = true
else imageOpen.value = true
}
/** 用户主动前往配置,先关闭当前提示,原操作不会自动恢复执行。 */
function requestProjectConfig() {
pendingConfigProject.value = projectId.value
modelPromptOpen.value = false
}
/** 提示完全离场后交给右上角同一个项目配置抽屉。 */
function finishModelPrompt() {
const id = pendingConfigProject.value
pendingConfigProject.value = ''
if (id && id === projectId.value) openProjectSettings?.('generation')
}
/** 切项目时废弃旧的配置交接。 */
watch(projectId, () => {
modelPromptOpen.value = false
pendingModelProject.value = ''
pendingConfigProject.value = ''
})
/** 角色卡片的切换目标,等抽屉离场后再交给详情页处理草稿确认。 */
const overviewSelection = ref('')
/**
@@ -306,6 +362,11 @@ function selectFromOverview(id: string) {
}
/** 抽屉关闭后显示目标角色,清除可能隐藏该角色的目录筛选并保留草稿确认。 */
function finishOverviewSelection() {
if (pendingModelProject.value) {
const project = pendingModelProject.value
pendingModelProject.value = ''
if (project === projectId.value) modelPromptOpen.value = true
}
const id = overviewSelection.value
overviewSelection.value = ''
if (!subjects.value.some(item => item.id === id && item.module === 'character')) return
@@ -365,7 +426,7 @@ const nextAction = computed<{ action: IdentityFlowAction; title: string; descrip
return {
action: 'profile',
title: '先配置生成模型',
description: '选择项目图片与视频模型后才能生图。',
description: '请点击右上角“项目配置”,选择图片与视频模型后再生成身份图。',
label: '配置生成模型'
}
if (!identityTextReady.value)
@@ -414,18 +475,11 @@ const nextAction = computed<{ action: IdentityFlowAction; title: string; descrip
}
})
/** 原配置恢复入口打开标题栏共用的全局配置弹窗。 */
function openProfileSettings() {
if (route.query.configure !== 'profile') void router.replace({ query: { ...route.query, configure: 'profile' } })
}
/** 下一步引导定位单张图片或打开多候选管理,形态图片跳转遵守项目准入规则。 */
function runNextAction() {
if (nextAction.value.action === 'style') void router.push(`/projects/${projectId.value}/visual-style`)
else if (nextAction.value.action === 'profile') openProfileSettings()
else if (nextAction.value.action === 'candidate') {
if (subject.value?.module === 'character') castingOpen.value = true
else imageOpen.value = true
requestImage(subject.value?.module === 'character' ? 'casting' : 'image')
} else if (nextAction.value.action === 'confirm') {
document.querySelector('#identity-reference-gallery')?.scrollIntoView({ behavior: 'smooth', block: 'center' })
} else if (nextAction.value.action === 'lock') {
@@ -568,8 +622,10 @@ function runNextAction() {
<ConfirmAction
:loading="isOperationRunning(operation, '批量生成角色选角候选')"
label="批量生成角色候选图"
:before-open="ensureGenerationProfile"
:disabled="
castingBlocked ||
modelQueryBlocked ||
!hasStyle ||
!batchValid ||
!candidateLimitValid ||
@@ -619,8 +675,10 @@ function runNextAction() {
<ConfirmAction
:loading="isOperationRunning(operation, '批量生成场景身份母版')"
label="生成场景母版"
:before-open="ensureGenerationProfile"
:disabled="
blocked ||
modelQueryBlocked ||
!hasStyle ||
!batchValid ||
!candidateLimitValid ||
@@ -634,8 +692,14 @@ function runNextAction() {
<ConfirmAction
:loading="isOperationRunning(operation, '批量生成道具身份母版')"
label="生成道具母版"
:before-open="ensureGenerationProfile"
:disabled="
blocked || !hasStyle || !batchValid || dirty || !subjects.length
blocked ||
modelQueryBlocked ||
!hasStyle ||
!batchValid ||
dirty ||
!subjects.length
"
acknowledgement
:description="`最多处理 ${candidateLimit} 个道具,可能产生图片生成与质量校验费用。通过校验后自动设为母版并锁定,可能替换尚未锁定的已有母版;已锁定且有有效母版的道具会跳过。`"
@@ -748,17 +812,6 @@ function runNextAction() {
>
</ContextNotice></NScrollbar
>
<ContextNotice
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>
</ContextNotice>
<div v-if="subjects.length" class="identity-workspace-region">
<!-- 以下是与分镜一致的融合工作区模块,目录与详情共用外层背景。 -->
<div class="panel workspace-surface directory-workspace identity-workspace">
@@ -866,7 +919,7 @@ function runNextAction() {
<span>{{ index + 1 }}. {{ step.label }}</span>
</li>
</ol>
<div class="identity-next-action">
<div v-if="nextAction.action !== 'profile'" class="identity-next-action">
<div>
<strong>{{ nextAction.title }}</strong>
<p>{{ nextAction.description }}</p>
@@ -938,17 +991,17 @@ function runNextAction() {
<template #actions>
<NButton
v-if="subject.module === 'scene' || subject.module === 'prop'"
:disabled="!canGenerateImage"
@click="qualityOpen = true"
:disabled="!canRequestImage"
@click="requestImage('quality')"
>生成稳定母版并校验质量</NButton
>
<NButton
v-if="subject.module === 'character'"
:disabled="!canGenerateCandidate"
@click="castingOpen = true"
:disabled="!canRequestCandidate"
@click="requestImage('casting')"
>{{ anchor ? '再生成一张候选' : 'AI 生成角色候选图' }}</NButton
>
<NButton :disabled="!canGenerateImage" @click="imageOpen = true">
<NButton :disabled="!canRequestImage" @click="requestImage('image')">
{{
subject.module === 'character'
? '生成辅助参考图'
@@ -1028,6 +1081,19 @@ function runNextAction() {
:disabled="!canGenerateCandidate"
@generate="submitCastingCandidate"
/></WorkspacePage>
<!-- 以下是点击生图时才展示的模型配置引导,关闭后交给唯一项目配置抽屉 -->
<AppDialog v-model:open="modelPromptOpen" title="需要配置生成模型" status="warning" @closed="finishModelPrompt">
<!-- 以下是独立于标题的配置引导正文,沿用公共弹窗内容与底栏间距 -->
<p class="text-sm leading-7 text-muted">
请在右上角“项目配置”中选择图片与视频模型。配置保存后,请重新点击需要的生成操作;本次尚未生成,也未产生费用。
</p>
<template #footer>
<NButton @click="modelPromptOpen = false">取消</NButton>
<NButton type="primary" :disabled="!openProjectSettings" @click="requestProjectConfig"
>前往项目配置</NButton
>
</template>
</AppDialog>
</template>
<style>
@@ -162,25 +162,33 @@ export function useSubjectIdentity() {
const canGenerateText = computed(
() => !detailBlocked.value && hasStyle.value && !identity.value?.isLocked && !dirty.value
)
const canGenerateImage = computed(
/** 图片入口允许先核对配置;任务、来源、正文和草稿限制仍然有效。 */
const canRequestImage = computed(
() =>
!detailBlocked.value &&
hasStyle.value &&
hasCreativeProfile.value &&
!!profileQuery.data.value &&
!profileQuery.error.value &&
!profileQuery.loading.value &&
!!identity.value?.generationPrompt?.trim() &&
!dirty.value
)
/** 真正生成仍必须具备正式保存的模型配置。 */
const canGenerateImage = computed(() => canRequestImage.value && hasCreativeProfile.value)
const activeIdentityGeneration = computed(() =>
images.value.find(image => image.status === 'pending' || image.status === 'generating')
)
const canGenerateCandidate = computed(
/** 角色候选入口与正式生成共用选角和活动图片限制,缺配置时先引导。 */
const canRequestCandidate = computed(
() =>
canGenerateImage.value &&
canRequestImage.value &&
subject.value?.module === 'character' &&
!!castingQuery.data.value &&
!castingQuery.error.value &&
!activeIdentityGeneration.value
)
/** 角色图片写入不会因为入口可点击而绕过模型配置。 */
const canGenerateCandidate = computed(() => canRequestCandidate.value && hasCreativeProfile.value)
const batchValid = computed(() => Number.isSafeInteger(concurrency.value) && concurrency.value > 0)
const candidateLimitValid = computed(() => Number.isSafeInteger(candidateLimit.value) && candidateLimit.value > 0)
const castingBlocked = computed(
@@ -438,6 +446,7 @@ export function useSubjectIdentity() {
castingBlocked.value ||
!!catalog.data.value?.running ||
!hasStyle.value ||
!hasCreativeProfile.value ||
!batchValid.value ||
!candidateLimitValid.value ||
!castingQuery.data.value?.missingAnchor
@@ -692,6 +701,8 @@ export function useSubjectIdentity() {
canGenerateText,
canGenerateImage,
canGenerateCandidate,
canRequestImage,
canRequestCandidate,
activeIdentityGeneration,
batchValid,
candidateLimitValid,