feat(short-drama-agent-front): 接入素材预览审核并完善创作流程
This commit is contained in:
1 parent
f8b0fbb8ca
commit
dc8bb17a23
66 files changed
+2864
-632
No files matched your search
@@ -1,5 +1,18 @@
|
||||
# 接口数据同步说明
|
||||
|
||||
## 2026-11-01 图片预览、质量门禁与派生任务
|
||||
|
||||
本次只接入后端根目录 `dev` 的正式 `/api` 路由,依据 `subject-form.routes.ts`、`subject-identity.routes.ts`、`production.routes.ts`、`storyboard.routes.ts` 及相应 Service 核对。未接入 3413 隔离验收服务、脚本、测试专用路由或测试页面;测试夹具只用于 Vitest。
|
||||
|
||||
- 身份图、独立选角候选和形态图共用只读预览确认。提交携带 `expectedPreviewFingerprint`;选角预览固定 `viewType=primary,useAnchorReference=false`,实际候选请求沿用正式选角接口。修改目标、参数或重新打开会清除确认,迟到响应不回填。只有 `409 + IMAGE_PREVIEW_STALE` 自动重读预览,之后仍须人工重新确认;不会自动重复生图。保留 Identity 的 `{executionId,image}` 与 Form/Casting 的直接图片回执区别。
|
||||
- 图库区分生成完成、最近审核与已采纳状态。新增正式 Form `POST images/:imageId/validate` 与显式有限预算 `POST images/generate-quality`,默认额外生成次数为 0。主图和母版确认披露可能发生的视觉审核费用,成功后只读刷新;质量失败、证据过期或请求冲突不乐观替换旧图。GET 图库仅查询,不触发模型或主图变更。
|
||||
- 身份与形态共用质量证据展示,按 `requirementId/quantityId` 关联原文、明确数量与实际观察;缺失、重复、不可观察及数量冲突不显示通过。原文与请求字段保持不变,内部编号收在高级详情。当前会话审核结果不冒充服务端长期有效的 Readiness。
|
||||
- 图片页新增 `POST production/plan {stage:'subjectImages'}` 只读检查,展示道具规格、已确认母版依赖顺序及质量问题入口。需准备资料时,经费用确认分别调用既有 `generation-prompt` 或 `prop-structure-spec/generate` 正式文字入口,不自动串联后续生图。未添加诊断脚本、测试路由或批量历史恢复入口。
|
||||
- 导演设计与画面状态任务增加服务端发现;刷新后恢复观察。`failed` 终态保留逐集部分成功、失败及 `manualReviewRequired`,不显示全部成功。订阅断线只重连/查询,离开页面关闭连接,不重提交生成。正式分镜审核和派生资产覆盖分别展示。
|
||||
- 复杂生图和图库处理复用 `AppDrawer`,固定标题与底栏,正文独立滚动,深浅主题复用现有变量。未提交或推送代码。
|
||||
|
||||
验证:类型检查、改动范围 Oxlint / Vue ESLint、全量 Vitest 和 Vite 构建;Chrome 复用 `localhost:4312` 标签,核对真实预览、参数变更清除确认、缺规格阻断、图库只读与费用确认入口、桌面和手机布局、深浅主题及固定底栏。没有执行真实付费生成/视觉审核、候选采纳或正式结果覆盖;这些写操作的成功/失败边界通过无费用自动化替身验证。
|
||||
|
||||
## 2026-10-28 剧本审核人工确认、延期验证与改写预检
|
||||
|
||||
按同级后端 `dev@b26aa94e` 的正式审核路由、人工确认事务、质量问题 Schema 和改写预检接入,前端仅修改根目录 `dev`。
|
||||
|
||||
@@ -1179,8 +1179,8 @@ const isInitialEmpty = computed(
|
||||
@confirm="run('retry')"
|
||||
/><ConfirmAction
|
||||
:loading="isOperationRunning(operation, '正在补齐镜头')"
|
||||
label="补齐缺失镜头"
|
||||
description="保留已经完成的镜头,只补齐缺失的镜头,然后检查并保存。"
|
||||
label="继续整理镜头"
|
||||
description="复用已生成内容,修正可确定的状态标记并补齐缺失镜头,再执行完整质量检查。"
|
||||
acknowledgement
|
||||
:disabled="issueActionsDisabled || !recovery.shots"
|
||||
@confirm="run('resume-shots')"
|
||||
|
||||
@@ -305,7 +305,7 @@ async function repairActions() {
|
||||
description="仅展示当前阻断镜头。逐项选择并填写可观察的动作过程,提交前核对修复摘要。"
|
||||
/>
|
||||
<p v-if="!actionDrafts.length" class="text-xs text-muted">
|
||||
当前阻断不属于批量接口支持的结果状态引用问题,无法在此自动修订。
|
||||
此处仅支持填写结果状态引用的动作修订。其它问题可先使用下方“继续整理镜头”,由系统检查可修正项并保留剩余阻断。
|
||||
</p>
|
||||
<article
|
||||
v-for="draft in actionDrafts"
|
||||
|
||||
@@ -117,7 +117,7 @@ defineExpose({ locate })
|
||||
</p>
|
||||
</div>
|
||||
<ContextNotice v-if="!episode" type="info" :show-icon="false" class="mb-5">
|
||||
本集已完成节拍规划,镜头尚未生成。请等待进度更新,或在确认中断后使用“补齐缺失镜头”。
|
||||
本集已完成节拍规划,镜头尚未生成。请等待进度更新,或在确认中断后使用“继续整理镜头”。
|
||||
</ContextNotice>
|
||||
<section
|
||||
v-for="beat in plan.beats"
|
||||
|
||||
@@ -29,7 +29,14 @@ const nodes = [
|
||||
] as const
|
||||
|
||||
/** 改写相关节点归入已有审核阶段,不影响其它节点的状态。 */
|
||||
const reviewNodes = ['reviewDrama', 'generateRewriteSuggestion', 'rewrite', 'resumeRewrite']
|
||||
const reviewNodes = [
|
||||
'reviewDrama',
|
||||
'generateRewriteSuggestion',
|
||||
'rewrite',
|
||||
'resumeRewrite',
|
||||
'resumeReview',
|
||||
'resolveDramaQuality'
|
||||
]
|
||||
|
||||
/**
|
||||
* 合并当前执行与最新保存记录,既不由节点顺序推断成功,也不复用新任务之前的旧审核结果。
|
||||
@@ -48,6 +55,10 @@ export function dramaStages(
|
||||
!execution ||
|
||||
(!!checkpoint && Date.parse(checkpoint.createdAt) >= Date.parse(execution.startedAt ?? execution.createdAt))
|
||||
const saved = currentSnapshot ? state : undefined
|
||||
// 仅恢复审核时,服务端预检已绑定具体保存记录,前序产物继续有效;旧审核不能当成本轮结论。
|
||||
const reusesReviewSource =
|
||||
execution?.metadata?.action === 'resume-review' && execution.metadata.checkpointId === checkpoint?.checkpointId
|
||||
const savedContent = currentSnapshot || reusesReviewSource ? state : undefined
|
||||
const count = project?.episodeCount ?? saved?.episodeCount
|
||||
const completed: Record<string, boolean> = {
|
||||
// 恢复服务明确复用最新保存记录中的规划;不从 Episode、Character 或执行顺序反推规划成功。
|
||||
@@ -55,10 +66,11 @@ export function dramaStages(
|
||||
!!state?.storyPlan &&
|
||||
(currentSnapshot ||
|
||||
execution?.metadata?.action === 'resume-generation' ||
|
||||
execution?.metadata?.action === 'resume-rewrite'),
|
||||
generateEpisode: !!count && (saved?.episodes?.length ?? 0) >= count,
|
||||
generateCharacter: !!saved?.characters,
|
||||
generateWorld: !!saved?.world,
|
||||
execution?.metadata?.action === 'resume-rewrite' ||
|
||||
reusesReviewSource),
|
||||
generateEpisode: !!count && (savedContent?.episodes?.length ?? 0) >= count,
|
||||
generateCharacter: !!savedContent?.characters,
|
||||
generateWorld: !!savedContent?.world,
|
||||
reviewDrama: typeof saved?.reviewPassed === 'boolean',
|
||||
finishProject: project?.status === 'completed'
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import { useQuery } from '../../../composables/useQuery'
|
||||
import { useProjectContext } from '../../projects/context'
|
||||
import { workflowCheckpoints } from '../../workflows/selectors'
|
||||
import DramaRewriteAction from './DramaRewriteAction.vue'
|
||||
import DramaSystemReviewAction from './DramaSystemReviewAction.vue'
|
||||
import ManualReviewIssueEditor from './ManualReviewIssueEditor.vue'
|
||||
import ReviewUncertaintyCard from './ReviewUncertaintyCard.vue'
|
||||
import { reviewCategoryOptions, suggestionForUncertainty, savedReviewDecisions } from './model'
|
||||
@@ -87,12 +88,12 @@ const hasRewriteTargets = computed(
|
||||
)
|
||||
)
|
||||
/** 当前有效预检只强调一个下一步入口,配色不代替服务端操作权限。 */
|
||||
const primaryAction = computed<'confirm' | 'rewrite' | null>(() => {
|
||||
const primaryAction = computed<'review' | 'rewrite' | null>(() => {
|
||||
if (flow.locked.value || rewriteQuery.loading.value || rewriteQuery.error.value || latest.value?.passed !== false)
|
||||
return null
|
||||
if (currentRewrite.value?.status === 'blocked' || currentRewrite.value?.status === 'stale') return null
|
||||
if (hasRewriteTargets.value) return currentRewrite.value?.ready === true ? 'rewrite' : null
|
||||
return hasManualIssues.value ? 'confirm' : null
|
||||
return hasManualIssues.value ? 'review' : null
|
||||
})
|
||||
/** 剧集范围同样读取真实改写预检,设定单独改写不伪造成剧集任务。 */
|
||||
const rewriteEpisodeSummary = computed(() => {
|
||||
@@ -117,9 +118,9 @@ const nextStep = computed(() => {
|
||||
description: `${scope}已有改写依据。点击“改写预检”核对范围${hasManualIssues.value ? ';待确认问题仍可继续人工处理' : ''}。开始改写前会再次确认费用。`
|
||||
}
|
||||
: {
|
||||
title: '请先核对审核问题',
|
||||
title: '可由系统继续核查',
|
||||
description:
|
||||
'点击“人工确认”对照原文逐项处理。确认后如需改写,会显示“改写预检”入口;所有处理都需要你确认。'
|
||||
'点击“系统重新核查”检查已保存正文,系统会优先复核疑点。只有仍无法确认的关键问题才需要人工处理。'
|
||||
}
|
||||
})
|
||||
/** 正式正文的当前阅读集号。 */
|
||||
@@ -283,10 +284,16 @@ function editorClosed() {
|
||||
:disabled="flow.writing.value"
|
||||
@refresh="flow.query.refresh"
|
||||
/>
|
||||
<DramaSystemReviewAction
|
||||
v-if="latest?.passed === false"
|
||||
:project-id="projectId"
|
||||
:primary="primaryAction === 'review'"
|
||||
:disabled="disabled || flow.locked.value"
|
||||
@started="context.refresh"
|
||||
/>
|
||||
<NButton
|
||||
v-if="hasManualIssues"
|
||||
:class="{ 'workspace-action-button': primaryAction !== 'confirm' }"
|
||||
:type="primaryAction === 'confirm' ? 'primary' : 'default'"
|
||||
class="workspace-action-button"
|
||||
aria-label="人工确认"
|
||||
:disabled="!latest || latest.passed || flow.writing.value"
|
||||
@click="flow.openEditor"
|
||||
@@ -321,6 +328,15 @@ function editorClosed() {
|
||||
reviewUncertain ? '审核状态待核对' : latest.passed ? '当前审核已通过' : '当前审核尚未通过'
|
||||
}}</NTag>
|
||||
</div>
|
||||
<!-- 以下是系统已完成的逐项复核摘要,保留关键待核对数 -->
|
||||
<p v-if="latest.automaticQualityResolution" class="text-sm text-muted">
|
||||
<template v-if="latest.automaticQualityResolution.status === 'completed'">
|
||||
系统复核了 {{ latest.automaticQualityResolution.candidateCount }} 项初审疑点, 其中
|
||||
{{ latest.automaticQualityResolution.resolvedCount }} 项已有依据,
|
||||
{{ latest.automaticQualityResolution.remainingCount }} 项仍需核对。
|
||||
</template>
|
||||
<template v-else>系统复核未完成,原审核疑点已保留。</template>
|
||||
</p>
|
||||
<!-- 以下是当前审核的下一步引导,仅在来源有效且读取完成后显示 -->
|
||||
<ContextNotice
|
||||
v-if="
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onScopeDispose, ref, watch } from 'vue'
|
||||
import { NButton } from 'naive-ui'
|
||||
import { FileSearch } from '@lucide/vue'
|
||||
import { AppDialog, WorkspaceRefreshButton } from '../../../components/ui'
|
||||
import ContextNotice from '../../../components/ui/ContextNotice.vue'
|
||||
import { useQuery } from '../../../composables/useQuery'
|
||||
import { errorMessage } from '../../../lib/http'
|
||||
import { getOperation, runOperation } from '../../workflows/operations'
|
||||
import { useWorkflowExecution } from '../../workflows/execution'
|
||||
import { dramaReviewApi, loadDramaReviewResumePreview } from './api'
|
||||
|
||||
/** 已保存剧本的系统核查入口,沿用项目级活动任务锁。 */
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
/** 当前正式项目。 */ projectId: string
|
||||
/** 当前外部操作锁。 */ disabled?: boolean
|
||||
/** 无明确改写目标时强调系统核查。 */ primary?: boolean
|
||||
}>(),
|
||||
{ disabled: false, primary: false }
|
||||
)
|
||||
/** 后台实际受理后才通知页面刷新。 */
|
||||
const emit = defineEmits<{ started: [executionId: string, projectId: string] }>()
|
||||
/** 费用与范围确认弹窗。 */
|
||||
const open = ref(false)
|
||||
/** 正在提交,防止重复收费请求。 */
|
||||
const writing = ref(false)
|
||||
/** 只展示当前项目的操作错误。 */
|
||||
const actionError = ref('')
|
||||
/** 当前项目的公共操作状态。 */
|
||||
const operation = computed(() => getOperation(props.projectId))
|
||||
/** 弹窗打开后才查询来源。 */
|
||||
const queryKey = computed(() => (open.value ? props.projectId : ''))
|
||||
/** 只读查询可取消,关闭弹窗不启动模型。 */
|
||||
const query = useQuery(queryKey, (id, signal) =>
|
||||
id ? loadDramaReviewResumePreview(id, signal) : Promise.resolve(null)
|
||||
)
|
||||
/** 页面布局观察后台任务,本入口仅保存真实句柄。 */
|
||||
const trackerProject = ref('')
|
||||
/** 与其他创作入口共用持久化任务句柄。 */
|
||||
const tracker = useWorkflowExecution(trackerProject, 'create-drama')
|
||||
/** 当前确认来源版本。 */
|
||||
let revision = 0
|
||||
/** 二次预检的取消控制器。 */
|
||||
let controller: AbortController | undefined
|
||||
watch([open, () => props.projectId], () => {
|
||||
revision++
|
||||
controller?.abort()
|
||||
actionError.value = ''
|
||||
})
|
||||
onScopeDispose(() => {
|
||||
revision++
|
||||
controller?.abort()
|
||||
})
|
||||
/** 仅使用当前预检与真实活动状态开放提交。 */
|
||||
const ready = computed(
|
||||
() =>
|
||||
query.data.value?.ready === true &&
|
||||
!query.loading.value &&
|
||||
!query.error.value &&
|
||||
!props.disabled &&
|
||||
!operation.value.pending &&
|
||||
!writing.value
|
||||
)
|
||||
|
||||
/** 二次核对保存记录后提交一次核查;来源变化或网络不确定时不自动重试。 */
|
||||
async function confirm() {
|
||||
if (!ready.value || !query.data.value) return
|
||||
const expected = query.data.value
|
||||
const id = props.projectId
|
||||
const version = revision
|
||||
writing.value = true
|
||||
actionError.value = ''
|
||||
controller = new AbortController()
|
||||
try {
|
||||
await runOperation(
|
||||
id,
|
||||
'系统核查剧本',
|
||||
async () => {
|
||||
const current = await loadDramaReviewResumePreview(id, controller!.signal)
|
||||
if (version !== revision || props.projectId !== id) throw new Error('当前项目已变化,请重新核对。')
|
||||
if (
|
||||
!current.ready ||
|
||||
current.checkpointId !== expected.checkpointId ||
|
||||
current.episodeCount !== expected.episodeCount
|
||||
) {
|
||||
query.data.value = current
|
||||
throw new Error('保存记录已变化,请重新核对本次范围。')
|
||||
}
|
||||
const started = await dramaReviewApi.resumeReview(id, expected.checkpointId)
|
||||
await tracker.track(started.executionId, id)
|
||||
if (version === revision && props.projectId === id) {
|
||||
emit('started', started.executionId, id)
|
||||
open.value = false
|
||||
}
|
||||
return started
|
||||
},
|
||||
{ type: 'info', content: '系统核查已开始,请查看创作任务进度。' }
|
||||
)
|
||||
if (version === revision && props.projectId === id && getOperation(id).error)
|
||||
actionError.value = getOperation(id).error
|
||||
} catch (cause) {
|
||||
if (version === revision && props.projectId === id) actionError.value = errorMessage(cause)
|
||||
} finally {
|
||||
writing.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span class="inline-flex">
|
||||
<!-- 以下是系统核查入口,打开仅执行只读预检 -->
|
||||
<NButton
|
||||
:type="primary ? 'primary' : 'default'"
|
||||
:disabled="disabled || operation.pending || writing"
|
||||
aria-label="系统重新核查"
|
||||
aria-haspopup="dialog"
|
||||
:aria-expanded="open"
|
||||
@click="open = true"
|
||||
>
|
||||
<template #icon><FileSearch :size="15" aria-hidden="true" /></template>系统重新核查
|
||||
</NButton>
|
||||
<AppDialog
|
||||
v-model:open="open"
|
||||
title="系统重新核查"
|
||||
description="核查已保存的剧本,先由系统处理可确认的问题。"
|
||||
:busy="writing"
|
||||
>
|
||||
<!-- 以下是范围、模型费用与错误反馈模块 -->
|
||||
<div class="grid gap-5">
|
||||
<p v-if="query.loading.value" class="text-sm text-muted">正在核对保存记录…</p>
|
||||
<p v-if="query.data.value" class="text-sm">
|
||||
本次核查已保存的 {{ query.data.value.episodeCount }} 集,不会重写正文、角色设定或世界观。
|
||||
</p>
|
||||
<ContextNotice type="info" title="本次操作会调用模型"
|
||||
>系统会检查完整正文,必要时再复核一次疑点。明确错误会保留为改写依据,无法确认的关键问题仍会保留;请勿重复提交。</ContextNotice
|
||||
>
|
||||
<ContextNotice v-if="query.error.value || actionError" type="error" title="暂不能开始核查">{{
|
||||
actionError || query.error.value
|
||||
}}</ContextNotice>
|
||||
</div>
|
||||
<!-- 以下是固定取消、重新读取与明确开始操作模块 -->
|
||||
<template #footer>
|
||||
<NButton :disabled="writing" @click="open = false">取消</NButton>
|
||||
<WorkspaceRefreshButton
|
||||
label="重新检查"
|
||||
:loading="query.loading.value"
|
||||
:disabled="writing"
|
||||
@refresh="query.refresh"
|
||||
/>
|
||||
<NButton type="primary" :loading="writing" :disabled="!ready" @click="confirm">开始系统核查</NButton>
|
||||
</template>
|
||||
</AppDialog>
|
||||
</span>
|
||||
</template>
|
||||
@@ -3,6 +3,7 @@ import type {
|
||||
ConfirmDramaIssuesInput,
|
||||
ConfirmDramaIssuesResult,
|
||||
DramaReviewPreview,
|
||||
DramaReviewResumePreview,
|
||||
DramaReviewSnapshot,
|
||||
DramaRewritePreview,
|
||||
LatestDramaReview
|
||||
@@ -100,6 +101,28 @@ function validSuggestions(value: unknown): boolean {
|
||||
|
||||
/** 真实剧本审核接口;只读预检和人工确认均不调用模型。 */
|
||||
export const dramaReviewApi = {
|
||||
/**
|
||||
* 读取重新核查已保存剧本的来源,不调用模型。
|
||||
* @param id 正式项目
|
||||
* @param signal 取消过期查询
|
||||
* @returns 可核查的正文版本与集数
|
||||
*/
|
||||
resumePreview: (id: string, signal?: AbortSignal) =>
|
||||
request<DramaReviewResumePreview>(`/projects/${encodeURIComponent(id)}/resume-review/preview`, { signal }),
|
||||
/**
|
||||
* 明确启动当前保存版本的系统核查,不重写正文。
|
||||
* @param id 正式项目
|
||||
* @param expectedCheckpointId 用户核对的来源版本
|
||||
* @returns 持久化任务句柄
|
||||
*/
|
||||
resumeReview: (id: string, expectedCheckpointId: string) =>
|
||||
request<{ executionId: string; projectId: string; status: string }>(
|
||||
`/projects/${encodeURIComponent(id)}/resume-review`,
|
||||
{
|
||||
method: 'POST',
|
||||
body: { confirmed: true, expectedCheckpointId }
|
||||
}
|
||||
),
|
||||
/**
|
||||
* 读取最新正式审核,尚无审核时返回空值。
|
||||
* @param id 正式项目编号
|
||||
@@ -198,3 +221,26 @@ export async function loadDramaReview(id: string, signal?: AbortSignal): Promise
|
||||
return { latest, preview: null, previewError: errorMessage(cause) }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 核对系统核查预检的归属与完整字段,不能据本地状态补造就绪结果。
|
||||
* @param id 正式项目
|
||||
* @param signal 取消过期查询
|
||||
* @returns 当前可信核查预检
|
||||
*/
|
||||
export async function loadDramaReviewResumePreview(
|
||||
id: string,
|
||||
signal?: AbortSignal
|
||||
): Promise<DramaReviewResumePreview> {
|
||||
const value = await dramaReviewApi.resumePreview(id, signal)
|
||||
if (
|
||||
value.projectId !== id ||
|
||||
!value.checkpointId ||
|
||||
value.readOnly !== true ||
|
||||
typeof value.ready !== 'boolean' ||
|
||||
!Number.isSafeInteger(value.episodeCount) ||
|
||||
value.episodeCount < 1
|
||||
)
|
||||
throw new Error('系统核查的保存记录不完整,请重新读取。')
|
||||
return value
|
||||
}
|
||||
@@ -35,6 +35,15 @@ export interface ManualReviewDecision {
|
||||
/** 已保存的后续核验标准。 */ verificationCriteria?: string
|
||||
}
|
||||
|
||||
/** 系统核查已保存正文前的只读来源预检。 */
|
||||
export interface DramaReviewResumePreview {
|
||||
/** 正式项目。 */ projectId: string
|
||||
/** 当前完整正文对应的保存记录。 */ checkpointId: string
|
||||
/** 实际保存的剧集数。 */ episodeCount: number
|
||||
/** 后端已确认可核查。 */ ready: boolean
|
||||
/** 预检不调用模型。 */ readOnly: true
|
||||
}
|
||||
|
||||
/** 最新正式审核,不从保存记录的布尔值虚构明细。 */
|
||||
export interface LatestDramaReview {
|
||||
/** 正式审核编号。 */ id: string
|
||||
@@ -48,6 +57,16 @@ export interface LatestDramaReview {
|
||||
} | null
|
||||
/** 原始待人工确认的问题。 */ pendingQualityIssues: DramaReviewIssue[]
|
||||
/** 已保存的人工裁决。 */ manualUncertaintyDecisions: ManualReviewDecision[]
|
||||
/** 系统逐项复核摘要;不等同于人工确认。 */ automaticQualityResolution?: {
|
||||
/** 本次复核候选数。 */ candidateCount: number
|
||||
/** 已有有效依据的项数。 */ resolvedCount: number
|
||||
/** 仍需核对的项数。 */ remainingCount: number
|
||||
/** 系统复核实际状态。 */ status: 'completed' | 'failed'
|
||||
/** 实际判断依据,仅供追溯。 */ decisions: Array<{
|
||||
/** 本轮候选索引。 */ candidateIndex: number
|
||||
/** 判断原因。 */ reason: string
|
||||
}>
|
||||
} | null
|
||||
/** 已有改写目标集数。 */ affectedEpisodes: number[]
|
||||
/** 敏感词审核结果。 */ hitWords: string[]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import type { CreativeProfile, GenerationModelCatalog, GenerationOptions } from './types'
|
||||
|
||||
/**
|
||||
* 从当前项目与能力目录恢复单图配置,丢弃目录不支持的旧尺寸。
|
||||
* @param catalog 当前模型能力目录
|
||||
* @param profile 当前项目保存的配置
|
||||
* @returns 可用供应方及本次独立的参数副本
|
||||
*/
|
||||
export function imageGenerationDefaults(
|
||||
catalog: GenerationModelCatalog,
|
||||
profile: CreativeProfile
|
||||
): {
|
||||
/** 可用供应方。 */ provider: string
|
||||
/** 模型默认值与项目值合并后的参数。 */ options: GenerationOptions
|
||||
} {
|
||||
const selected =
|
||||
catalog.images.find(item => item.provider === profile.imageProvider && item.enabled) ??
|
||||
catalog.images.find(item => item.enabled)
|
||||
const options: GenerationOptions = {
|
||||
...selected?.defaults,
|
||||
...(selected?.provider === profile.imageProvider ? profile.imageOptions : {})
|
||||
}
|
||||
const size = selected?.generationOptions.find(item => item.key === 'size')
|
||||
if (size?.options?.length && !size.options.some(option => option.value === options.size))
|
||||
options.size = selected?.defaults.size ?? size.options[0]?.value ?? ''
|
||||
return { provider: selected?.provider ?? '', options }
|
||||
}
|
||||
@@ -67,8 +67,9 @@ export const productionApi = {
|
||||
plan: (projectId: string, signal?: AbortSignal, input: ProductionPlanInput = {}) =>
|
||||
request<ProductionPlanResponse>(`${projectPath(projectId)}/production/plan`, {
|
||||
method: 'POST',
|
||||
// 计划只解析这三项;阶段范围及视频参数只由启动接口消费。
|
||||
// 计划携带与当前准备范围一致的阶段,不创建任务。
|
||||
body: {
|
||||
stage: input.stage,
|
||||
imageProvider: input.imageProvider,
|
||||
imageGenerationOptions: input.imageGenerationOptions,
|
||||
videoProvider: input.videoProvider
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { NButton, NCollapse, NCollapseItem, NTag } from 'naive-ui'
|
||||
import { RouterLink } from 'vue-router'
|
||||
import { ArrowUpRight } from '@lucide/vue'
|
||||
import WorkspaceSectionHeading from '../../../components/ui/WorkspaceSectionHeading.vue'
|
||||
import { userFacingText } from '../../../lib/user-facing-text'
|
||||
import type { ProductionPlan } from '../types'
|
||||
|
||||
/** 图片准备与生产计划共用同一份后端规格及依赖。 */
|
||||
const props = defineProps<{
|
||||
/** 当前真实制作计划。 */ plan: ProductionPlan
|
||||
/** 图片准备抽屉允许明确准备文字资料,生产计划仍只读。 */ allowPreparation?: boolean
|
||||
/** 当前项目存在任务或检查未成功时禁止准备。 */ disabled?: boolean
|
||||
}>()
|
||||
/** 从计划转到资产处理时关闭外层检查抽屉。 */
|
||||
const emit = defineEmits<{
|
||||
/** 转到现有资产处理页面。 */ navigate: []
|
||||
/** 确认前选择一次文字准备操作。 */ prepare: [formId: string, kind: 'prompt' | 'structure']
|
||||
}>()
|
||||
/** 顶层规格与稳定母版携带的规格来自同一后端检查。 */
|
||||
const specs = computed(() => props.plan.propStructureSpecs ?? props.plan.stableIdentityAnchors?.propStructureSpecs)
|
||||
/** 以服务端依赖顺序展示母版,未返回顺序时保留原始顺序。 */
|
||||
const anchors = computed(() => {
|
||||
const items = props.plan.stableIdentityAnchors?.items ?? props.plan.details.stableIdentityAnchors ?? []
|
||||
const order = props.plan.stableIdentityAnchors?.dependencyOrder ?? []
|
||||
return items.toSorted((a, b) => {
|
||||
const left = order.indexOf(a.subjectId),
|
||||
right = order.indexOf(b.subjectId)
|
||||
return (left < 0 ? order.length : left) - (right < 0 ? order.length : right)
|
||||
})
|
||||
})
|
||||
/** 主体名称从真实计划取得,不由引用或案例推断。 */
|
||||
const names = computed(() => new Map(anchors.value.map(item => [item.subjectId, item.subjectName])))
|
||||
/** 质量失败或过期只提供候选审核入口,不自动重生。 */
|
||||
const qualityIssues = computed(() =>
|
||||
props.plan.details.subjectImages.filter(item =>
|
||||
item.issues.some(issue => ['quality_failed', 'quality_stale'].includes(issue.code))
|
||||
)
|
||||
)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 以下是道具结构规格准备模块,可准备不等于已经完成 -->
|
||||
<section v-if="specs" class="space-y-4" aria-label="道具结构规格">
|
||||
<WorkspaceSectionHeading
|
||||
title="道具结构规格"
|
||||
description="仅检查已有资料。待准备项需先补齐画面描述或规格,尚未执行。"
|
||||
/>
|
||||
<div class="flex flex-wrap gap-x-5 gap-y-2 text-xs">
|
||||
<span>共 {{ specs.total }} 项</span><span>已就绪 {{ specs.ready }}</span
|
||||
><span>待准备 {{ specs.upstreamResolvable }}</span
|
||||
><span :class="specs.manualBlocked ? 'text-danger' : 'text-muted'"
|
||||
>需人工处理 {{ specs.manualBlocked }}</span
|
||||
>
|
||||
</div>
|
||||
<NCollapse v-if="specs.items.length" :default-expanded-names="specs.manualBlocked ? ['specs'] : []">
|
||||
<NCollapseItem name="specs" title="查看规格准备明细">
|
||||
<ul class="space-y-4 text-xs leading-6">
|
||||
<li v-for="item in specs.items" :key="item.subjectFormId ?? item.subjectId">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<strong>{{ names.get(item.subjectId) ?? item.subjectRef }}</strong
|
||||
><NTag
|
||||
size="small"
|
||||
:bordered="false"
|
||||
:type="item.status === 'blocked' ? 'error' : 'default'"
|
||||
>{{ { ready: '已就绪', upstream: '待准备', blocked: '需人工处理' }[item.status] }}</NTag
|
||||
>
|
||||
</div>
|
||||
<p class="mt-1 wrap-anywhere text-muted">{{ userFacingText(item.reason) }}</p>
|
||||
<NButton
|
||||
v-if="allowPreparation && item.status === 'upstream' && item.subjectFormId"
|
||||
size="small"
|
||||
class="workspace-action-button mt-2"
|
||||
:disabled="disabled"
|
||||
@click="
|
||||
emit('prepare', item.subjectFormId, item.requiresFormPrompt ? 'prompt' : 'structure')
|
||||
"
|
||||
>{{ item.requiresFormPrompt ? '准备形态画面描述' : '准备结构规格' }}</NButton
|
||||
>
|
||||
</li>
|
||||
</ul>
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
</section>
|
||||
<!-- 以下是已确认母版依赖及准备顺序模块 -->
|
||||
<section v-if="anchors.length" class="space-y-4" aria-label="母版准备顺序">
|
||||
<WorkspaceSectionHeading
|
||||
title="母版准备顺序"
|
||||
description="按已确认的共享关系排列;锁定资产和人工阻断需要先核对。"
|
||||
/>
|
||||
<ol class="space-y-4 text-xs leading-6">
|
||||
<li v-for="(item, index) in anchors" :key="item.subjectId" class="min-w-0">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<strong>{{ index + 1 }}. {{ item.subjectName }}</strong
|
||||
><NTag :bordered="false" size="small" :type="item.status === 'blocked' ? 'error' : 'default'">{{
|
||||
{ skipped: '已有母版', ready: '待生成', upstream: '待准备资料', blocked: '需人工处理' }[
|
||||
item.status
|
||||
]
|
||||
}}</NTag>
|
||||
</div>
|
||||
<p v-if="item.dependencySubjectIds?.length" class="mt-1 text-muted">
|
||||
先准备:{{ item.dependencySubjectIds.map(id => names.get(id) ?? '关联主体').join('、') }}
|
||||
</p>
|
||||
<p class="mt-1 wrap-anywhere text-muted">{{ userFacingText(item.reason) }}</p>
|
||||
<RouterLink
|
||||
v-if="item.status === 'blocked'"
|
||||
class="text-button mt-2 inline-flex items-center gap-2"
|
||||
:to="{ path: `/projects/${plan.projectId}/subject-identity`, query: { subjectId: item.subjectId } }"
|
||||
@click="emit('navigate')"
|
||||
><ArrowUpRight :size="14" />查看主体与候选</RouterLink
|
||||
>
|
||||
</li>
|
||||
</ol>
|
||||
</section>
|
||||
<!-- 以下是图片质量问题处理入口模块,保留旧图且不自动生成 -->
|
||||
<section v-if="qualityIssues.length" class="space-y-4 lg:col-span-2" aria-label="图片质量待处理">
|
||||
<WorkspaceSectionHeading
|
||||
title="图片质量待处理"
|
||||
description="审核失败或证据过期时,先核对候选并明确重新审核。"
|
||||
/>
|
||||
<article v-for="item in qualityIssues" :key="item.subjectFormId" class="space-y-2 text-xs leading-6">
|
||||
<strong>{{ item.subjectName }} · {{ item.formName }}</strong>
|
||||
<p
|
||||
v-for="issue in item.issues.filter(issue => ['quality_failed', 'quality_stale'].includes(issue.code))"
|
||||
:key="issue.code"
|
||||
class="text-danger"
|
||||
>
|
||||
{{ userFacingText(issue.reason) }}
|
||||
</p>
|
||||
<RouterLink
|
||||
class="text-button inline-flex items-center gap-2"
|
||||
:to="{
|
||||
path: `/projects/${plan.projectId}/subject-images`,
|
||||
query: { subjectFormId: item.subjectFormId }
|
||||
}"
|
||||
@click="emit('navigate')"
|
||||
><ArrowUpRight :size="14" />查看候选与审核</RouterLink
|
||||
>
|
||||
</article>
|
||||
</section>
|
||||
</template>
|
||||
@@ -1,12 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import ContextNotice from '../../../components/ui/ContextNotice.vue'
|
||||
import ImagePreparationPlan from './ImagePreparationPlan.vue'
|
||||
import { userFacingText } from '../../../lib/user-facing-text'
|
||||
|
||||
import { computed } from 'vue'
|
||||
import { NCollapse, NCollapseItem, NScrollbar } from 'naive-ui'
|
||||
import type { ProductionPlan, ProjectProductionStatus } from '../types'
|
||||
|
||||
/** 展示当前制作计划与真实资产状态,不在页面重复推断业务规则。 */
|
||||
const props = defineProps<{ plan: ProductionPlan; status: ProjectProductionStatus }>()
|
||||
const props = defineProps<{
|
||||
/** 当前真实计划。 */ plan: ProductionPlan
|
||||
/** 可选的已生成资产统计。 */ status?: ProjectProductionStatus
|
||||
}>()
|
||||
/** 生产阶段共享计划字段,角色身份就绪信息单独展示,避免混用不同 DTO。 */
|
||||
const rows = computed(() => [
|
||||
...(props.plan.stableIdentityAnchors ? [{ label: '稳定身份锚点', stage: props.plan.stableIdentityAnchors }] : []),
|
||||
@@ -56,7 +61,7 @@ const problems = computed(() => [
|
||||
{{ plan.characterIdentity.pending }} · 可自动补齐 {{ plan.characterIdentity.autoResolvable }} · 需人工处理
|
||||
{{ plan.characterIdentity.manualBlocked }}
|
||||
</p>
|
||||
<p class="mt-2 text-xs" role="status">
|
||||
<p v-if="status" class="mt-2 text-xs" role="status">
|
||||
当前制作状态:{{ status.completed ? '制作已完成' : `待完成${stageNames[status.stage]}` }} · 有效主体图
|
||||
{{ status.subjectImages.current }}/{{ status.subjectImages.total }} · 有效首帧
|
||||
{{ status.keyframes.skipped }}/{{ status.keyframes.total }} · 有效主视频 {{ status.videos.skipped }}/{{
|
||||
@@ -92,20 +97,22 @@ const problems = computed(() => [
|
||||
</table>
|
||||
</NScrollbar>
|
||||
<p class="mt-2 text-xs text-muted">
|
||||
计划会根据当前素材自动更新。已有有效结果会直接复用;重新生成的过期主体图会自动设为当前主图,手动生成的候选仍可在形态图片页自行确认。
|
||||
计划只反映当前准备情况。图片生成完成后仍需通过质量和来源检查;失败候选会保留,不能用重新生图自动消除质量阻断。
|
||||
</p>
|
||||
<ContextNotice v-if="plan.hasManualBlockers" type="warning" :show-icon="false" class="mt-3">
|
||||
当前有
|
||||
{{ plan.manualBlocked }}
|
||||
项独立准备问题需人工处理。上表各阶段的影响数量可能重叠,不能直接相加。可先生成就绪的主体参考图;成功结果会保留,遇到阻塞时后续阶段可能暂停。
|
||||
</ContextNotice>
|
||||
<!-- 以下是当前道具规格、共享母版依赖与质量处理入口 -->
|
||||
<div class="mt-5 grid items-start gap-6 lg:grid-cols-2"><ImagePreparationPlan :plan="plan" /></div>
|
||||
<NCollapse v-if="problems.length" class="mt-3" :default-expanded-names="['issues']">
|
||||
<NCollapseItem name="issues" title="查看还需要准备的内容">
|
||||
<ul class="space-y-3 text-xs">
|
||||
<li v-for="item in problems" :key="item.key">
|
||||
<strong class="break-all">{{ item.label }}</strong>
|
||||
<p v-for="(issue, index) in item.issues" :key="index" class="mt-1 break-words">
|
||||
{{ issue.reason
|
||||
{{ userFacingText(issue.reason)
|
||||
}}<span v-if="issue.missingSubjects?.length">
|
||||
· 关联主体:{{ issue.missingSubjects.join('、') }}</span
|
||||
>
|
||||
|
||||
@@ -68,6 +68,8 @@ export function issueLabel(code: ProductionIssueCode): string {
|
||||
missing_primary_keyframe: '缺少可用首帧',
|
||||
missing_identity: '缺少角色身份',
|
||||
missing_identity_anchor: '缺少演员母版',
|
||||
quality_failed: '主体图片质量未通过',
|
||||
quality_stale: '主体图片审核需更新',
|
||||
identity_unlocked: '演员身份未锁定',
|
||||
missing_prompt: '缺少视频提示词',
|
||||
stale_prompt: '视频提示词需要更新',
|
||||
|
||||
@@ -11,6 +11,10 @@ export type ProductionIssueCode =
|
||||
| 'missing_primary_keyframe'
|
||||
| 'missing_identity'
|
||||
| 'missing_identity_anchor'
|
||||
/** 当前主图质量未通过。 */
|
||||
| 'quality_failed'
|
||||
/** 当前主图审核证据已失效。 */
|
||||
| 'quality_stale'
|
||||
| 'identity_unlocked'
|
||||
| 'missing_prompt'
|
||||
| 'stale_prompt'
|
||||
@@ -555,9 +559,15 @@ export interface ProductionPlan {
|
||||
characterIdentity?: ProductionCharacterIdentityPlan
|
||||
/** 稳定身份母版阶段与真实逐项计划。 */
|
||||
stableIdentityAnchors?: ProductionPlanStage & {
|
||||
/** 按已确认共享关系给出的准备顺序。 */
|
||||
dependencyOrder?: string[]
|
||||
/** 同源的道具规格统计。 */
|
||||
propStructureSpecs?: PropStructurePreparation
|
||||
/** 稳定主体的逐项就绪结果。 */
|
||||
items?: ProductionStableIdentityItem[]
|
||||
}
|
||||
/** 道具规格准备统计,仅表示当前计划,不代表执行完成。 */
|
||||
propStructureSpecs?: PropStructurePreparation | null
|
||||
stage: ProductionStatusStage
|
||||
hasManualBlockers: boolean
|
||||
manualBlocked: number
|
||||
@@ -746,6 +756,8 @@ export type ProductionStage = 'subjectImages' | 'keyframes' | 'videoPrompts'
|
||||
|
||||
/** 无消耗生产计划与实际启动共用的模型配置。 */
|
||||
export interface ProductionPlanInput {
|
||||
/** 只读核对本轮阶段范围。 */
|
||||
stage?: ProductionStage
|
||||
/** 本轮图片模型供应方。 */
|
||||
imageProvider?: string
|
||||
/** 主体图片与首帧共用的图片生成参数。 */
|
||||
@@ -790,6 +802,8 @@ export interface ProductionCharacterIdentityPlan {
|
||||
|
||||
/** 后端稳定身份母版计划的单个主体。 */
|
||||
export interface ProductionStableIdentityItem {
|
||||
/** 本主体依赖的已确认共享主体编号。 */
|
||||
dependencySubjectIds?: string[]
|
||||
/** 数据库主体 ID。 */
|
||||
subjectId: string
|
||||
/** 主体引用标识。 */
|
||||
@@ -803,3 +817,32 @@ export interface ProductionStableIdentityItem {
|
||||
/** 后端提供的就绪或阻塞原因。 */
|
||||
reason: string
|
||||
}
|
||||
|
||||
/** 只读道具规格的准备情况。 */
|
||||
export interface PropStructurePreparation {
|
||||
/** 规格总数。 */
|
||||
total: number
|
||||
/** 当前有效规格数。 */
|
||||
ready: number
|
||||
/** 需先补描述或规格的数量。 */
|
||||
upstreamResolvable: number
|
||||
/** 需人工处理的数量。 */
|
||||
manualBlocked: number
|
||||
/** 逐形态真实检查结果。 */
|
||||
items: Array<{
|
||||
/** 所属正式主体编号。 */
|
||||
subjectId: string
|
||||
/** 主体引用。 */
|
||||
subjectRef: string
|
||||
/** 正式形态编号,缺少形态时为 null。 */
|
||||
subjectFormId: string | null
|
||||
/** 有效、需准备或人工阻断。 */
|
||||
status: 'ready' | 'upstream' | 'blocked'
|
||||
/** 规格的真实状态。 */
|
||||
specStatus: 'ready' | 'missing' | 'stale' | 'missing_form'
|
||||
/** 是否需先准备正式画面描述。 */
|
||||
requiresFormPrompt: boolean
|
||||
/** 后端具体原因。 */
|
||||
reason: string
|
||||
}>
|
||||
}
|
||||
@@ -77,7 +77,7 @@ const operation = computed(() => getOperation(id.value))
|
||||
const createDramaExecution = useWorkflowExecution(id, 'create-drama', { discover: true })
|
||||
/** 项目内跨页面继续观察首帧后台任务,维持活动锁并在真实终态后释放。 */
|
||||
useWorkflowExecution(id, 'keyframe-quality')
|
||||
/** 既有生成入口在跨页面时继续观察,保持项目活动锁。 */
|
||||
/** 派生设计从服务端发现新任务;其它既有入口继续观察已知任务,保持项目活动锁。 */
|
||||
for (const workflowName of [
|
||||
'storyboard-direction',
|
||||
'storyboard-visual-state',
|
||||
@@ -85,7 +85,9 @@ for (const workflowName of [
|
||||
'keyframe-generation',
|
||||
'video-quality'
|
||||
]) {
|
||||
useWorkflowExecution(id, workflowName)
|
||||
useWorkflowExecution(id, workflowName, {
|
||||
discover: ['storyboard-direction', 'storyboard-visual-state'].includes(workflowName)
|
||||
})
|
||||
}
|
||||
/** 即使直接刷新到生产页,也按真实重生成任务恢复旧剧情快照的失效标记。 */
|
||||
const breakdownExecution = useWorkflowExecution(id, 'breakdown', { discover: true })
|
||||
|
||||
@@ -39,6 +39,7 @@ const durationOptions = [
|
||||
{ label: '固定集数与总时长', value: 'fixed_episode_count' },
|
||||
{ label: '根据单集时长推导集数', value: 'flexible_episode_count' }
|
||||
]
|
||||
/** 根据目标总时长和单集范围推导可行集数,无法满足范围时返回空值。 */
|
||||
const estimatedCount = computed(() => {
|
||||
if (form.durationMode !== 'flexible_episode_count' || form.minSeconds <= 0 || form.maxSeconds < form.minSeconds)
|
||||
return null
|
||||
@@ -49,6 +50,17 @@ const estimatedCount = computed(() => {
|
||||
const midpoint = (form.minSeconds + form.maxSeconds) / 2
|
||||
return Math.max(minimum, Math.min(maximum, Math.round(total / midpoint)))
|
||||
})
|
||||
/** 生成前展示当前模式的集数与时长摘要,便于核对创作规模。 */
|
||||
const durationSummary = computed(() => {
|
||||
if (form.durationMode === 'auto') return `计划 ${form.episodeCount} 集,时长由故事内容规划。`
|
||||
const count = form.durationMode === 'fixed_episode_count' ? form.episodeCount : estimatedCount.value
|
||||
if (!count || form.totalMinutes <= 0) return '调整时长与集数后,可在这里查看创作规模。'
|
||||
const averageSeconds = Math.round((form.totalMinutes * 60) / count)
|
||||
if (form.durationMode === 'fixed_episode_count') {
|
||||
return `计划 ${count} 集,总时长 ${form.totalMinutes} 分钟,平均每集约 ${averageSeconds} 秒。`
|
||||
}
|
||||
return `预计 ${count} 集,总时长 ${form.totalMinutes} 分钟,平均每集约 ${averageSeconds} 秒。`
|
||||
})
|
||||
/** 只发送当前模式所需字段,避免弹性模式携带顶层 episodeCount。 */
|
||||
function durationBudget(): DramaDurationBudget {
|
||||
if (form.durationMode === 'auto') return { mode: 'auto', episodeCount: form.episodeCount }
|
||||
@@ -220,6 +232,8 @@ const rules = computed(() => ({
|
||||
:step="1"
|
||||
></NInputNumber
|
||||
></NFormItem>
|
||||
<!-- 以下是生成前的集数与时长核对摘要模块 -->
|
||||
<p class="text-sm text-muted" role="status" aria-live="polite">{{ durationSummary }}</p>
|
||||
</div>
|
||||
<FeedbackMessage v-if="feedback" :message="feedback" />
|
||||
</AppForm>
|
||||
|
||||
@@ -121,13 +121,14 @@ export interface DramaState {
|
||||
|
||||
/** 项目制作导航使用的服务端统一阶段状态。 */
|
||||
export interface ProjectStageReadiness {
|
||||
projectId: string
|
||||
script: { ready: boolean; reason: string | null }
|
||||
breakdown: { ready: boolean; reason: string | null }
|
||||
visualStyle: { ready: boolean; reason: string | null }
|
||||
identity: { ready: boolean; reason: string | null }
|
||||
subjectAssets: { ready: boolean; reason: string | null }
|
||||
storyboard: { ready: boolean; reason: string | null }
|
||||
/** 正式项目编号。 */ projectId: string
|
||||
/** 剧本审核和保存状态。 */ script: { ready: boolean; reason: string | null }
|
||||
/** 正式分镜完整审核,供镜头设计和制作使用。 */ breakdown: { ready: boolean; reason: string | null }
|
||||
/** 来源、结构和动作自动检查通过,可先准备风格和主体素材。 */ preparation: { ready: boolean; reason: string | null }
|
||||
/** 项目视觉风格是否已保存。 */ visualStyle: { ready: boolean; reason: string | null }
|
||||
/** 角色身份是否已准备。 */ identity: { ready: boolean; reason: string | null }
|
||||
/** 主体素材是否已准备。 */ subjectAssets: { ready: boolean; reason: string | null }
|
||||
/** 镜头设计是否已准备。 */ storyboard: { ready: boolean; reason: string | null }
|
||||
}
|
||||
|
||||
/** 单集分镜时长偏差审计结果。 */
|
||||
|
||||
@@ -25,33 +25,23 @@ export function useProjectStageAccess(projectId: Ref<string>, readiness: Ref<Pro
|
||||
nextLabel: '前往剧本创作'
|
||||
},
|
||||
'visual-style': {
|
||||
...accessState(state?.breakdown.ready, state?.breakdown.reason, '请先完成剧本拆解'),
|
||||
...accessState(state?.preparation?.ready, state?.preparation?.reason, '请先完成剧本拆解'),
|
||||
nextPath: 'breakdown',
|
||||
nextLabel: '前往剧本拆解'
|
||||
},
|
||||
'subject-identity': {
|
||||
enabled: Boolean(state?.breakdown.ready && state?.visualStyle.ready),
|
||||
reason: state?.breakdown.reason || state?.visualStyle.reason || '请先准备视觉风格',
|
||||
nextPath: state?.breakdown.ready ? 'visual-style' : 'breakdown',
|
||||
nextLabel: state?.breakdown.ready ? '前往视觉风格' : '前往剧本拆解'
|
||||
enabled: Boolean(state?.preparation?.ready && state?.visualStyle.ready),
|
||||
reason: state?.preparation?.reason || state?.visualStyle.reason || '请先准备视觉风格',
|
||||
nextPath: state?.preparation?.ready ? 'visual-style' : 'breakdown',
|
||||
nextLabel: state?.preparation?.ready ? '前往视觉风格' : '前往剧本拆解'
|
||||
},
|
||||
'subject-images': {
|
||||
enabled: Boolean(state?.breakdown.ready && state?.visualStyle.ready && state?.identity.ready),
|
||||
reason:
|
||||
state?.breakdown.reason ||
|
||||
state?.visualStyle.reason ||
|
||||
state?.identity.reason ||
|
||||
'请先完成主体身份准备',
|
||||
nextPath: state?.visualStyle.ready
|
||||
? 'subject-identity'
|
||||
: state?.breakdown.ready
|
||||
? 'visual-style'
|
||||
: 'breakdown',
|
||||
nextLabel: state?.visualStyle.ready
|
||||
? '前往主体身份'
|
||||
: state?.breakdown.ready
|
||||
? '前往视觉风格'
|
||||
: '前往剧本拆解'
|
||||
// 此页同时准备单个素材的Prompt与规格;全项目身份未齐备不阻断只读检查和逐项准备。
|
||||
// 付费生成仍由本素材的实际预览、身份/规格与版本门禁决定。
|
||||
enabled: Boolean(state?.preparation?.ready && state?.visualStyle.ready),
|
||||
reason: state?.preparation?.reason || state?.visualStyle.reason || '请先准备视觉风格',
|
||||
nextPath: state?.preparation?.ready ? 'visual-style' : 'breakdown',
|
||||
nextLabel: state?.preparation?.ready ? '前往视觉风格' : '前往剧本拆解'
|
||||
},
|
||||
storyboard: {
|
||||
enabled: Boolean(state?.breakdown.ready && state?.subjectAssets.ready),
|
||||
|
||||
@@ -433,6 +433,18 @@ async function repaired() {
|
||||
title="补齐镜头设计与画面状态"
|
||||
description="先更新镜头设计,再更新画面状态。只补齐缺失或过期结果,生成可能产生模型费用。"
|
||||
/>
|
||||
<p
|
||||
class="text-sm"
|
||||
:class="flow.data.value.entry.storyboardValid === false ? 'text-danger' : 'text-muted'"
|
||||
>
|
||||
正式分镜结构检查:{{
|
||||
flow.data.value.entry.storyboardValid === true
|
||||
? '通过'
|
||||
: flow.data.value.entry.storyboardValid === false
|
||||
? '未通过或已过期'
|
||||
: '待确认'
|
||||
}}。镜头设计和画面状态覆盖单独检查,入口就绪不代表图片质量已通过。
|
||||
</p>
|
||||
<p class="text-sm text-muted">
|
||||
已保存镜头设计 {{ flow.data.value.entry.derivedAssets.directionCount }} /
|
||||
{{ flow.data.value.entry.derivedAssets.shotCount }} · 画面状态
|
||||
|
||||
@@ -10,9 +10,11 @@ import type { StoryboardReceipt } from '../types'
|
||||
|
||||
/** 独立展示提交结果,不能将 HTTP 成功或局部成功显示为整批完成。 */
|
||||
const props = defineProps<{ receipt: StoryboardReceipt }>()
|
||||
/** 部分失败与待人工核对均不表示批次通过。 */
|
||||
const failed = computed(() => {
|
||||
if (props.receipt.kind === 'shots') return !props.receipt.result.storyboardShotValidation.valid
|
||||
if (props.receipt.kind === 'batch') return props.receipt.result.failedEpisodes > 0
|
||||
if (props.receipt.kind === 'batch')
|
||||
return props.receipt.result.failedEpisodes > 0 || props.receipt.result.manualReviewRequired === true
|
||||
return props.receipt.result.failed > 0
|
||||
})
|
||||
|
||||
|
||||
@@ -85,6 +85,8 @@ export interface EpisodeGenerationResult {
|
||||
|
||||
/** 两种设计批处理返回相同的汇总结构。 */
|
||||
export interface StoryboardBatchResult {
|
||||
/** 部分失败后的真实人工核对标记。 */
|
||||
manualReviewRequired?: boolean
|
||||
/** 本轮结束后仍然过期的设计记录,不因覆盖率完整而忽略。 */
|
||||
staleCount?: number
|
||||
projectId: string
|
||||
|
||||
@@ -175,7 +175,7 @@ export function useStoryboard() {
|
||||
if (!record || record.projectId !== id.value || !['completed', 'failed'].includes(record.status)) return
|
||||
const target = getStoryboardSession(record.projectId)
|
||||
if (index === 0 && record.metadata?.action !== 'regenerate-storyboard-episode') return
|
||||
if (record.status === 'completed' && record.result) {
|
||||
if (record.result && (record.status === 'completed' || index === 1 || index === 2)) {
|
||||
if (index === 0) {
|
||||
const result = record.result as unknown as StoryboardShotRegenerationResult
|
||||
const number = record.metadata?.episodeNo
|
||||
|
||||
@@ -91,7 +91,8 @@ const {
|
||||
confirmCasting,
|
||||
validateImage,
|
||||
generateStableAnchorQuality,
|
||||
pendingImageOperation
|
||||
pendingImageOperation,
|
||||
validationResult
|
||||
} = useSubjectIdentity()
|
||||
/** 所有形态图片入口复用侧栏和路由的服务端阶段准入规则。 */
|
||||
const stageAccess = useProjectStageAccess(projectId, projectContext.stageReadiness)
|
||||
@@ -225,30 +226,6 @@ function exportReceipt() {
|
||||
downloadText('subject-identities-receipt.json', JSON.stringify(session.value.receipt, null, 2), 'application/json')
|
||||
}
|
||||
|
||||
/**
|
||||
* 前置校验通过并开始提交时关闭原主体弹窗,后续状态通过消息反馈。
|
||||
* @param input 已确认的身份图生成参数
|
||||
* @returns 提交与详情刷新完成
|
||||
*/
|
||||
async function submitIdentityImage(input: Parameters<typeof generateImage>[0]) {
|
||||
const targetId = selectedId.value
|
||||
await generateImage(input, () => {
|
||||
if (selectedId.value === targetId) imageOpen.value = false
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 前置校验通过并开始提交时关闭原主体选角弹窗,不等待接口返回。
|
||||
* @param input 已确认的选角生成参数
|
||||
* @returns 提交与列表刷新完成
|
||||
*/
|
||||
async function submitCastingCandidate(input: Parameters<typeof generateCastingCandidate>[0]) {
|
||||
const targetId = selectedId.value
|
||||
await generateCastingCandidate(input, () => {
|
||||
if (selectedId.value === targetId) castingOpen.value = false
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 按主体类型确认母版,成功后关闭原主体的管理弹窗。
|
||||
* @param imageId 用户明确选择的图片编号
|
||||
@@ -461,8 +438,7 @@ const nextAction = computed<{ action: IdentityFlowAction; title: string; descrip
|
||||
return {
|
||||
action: 'confirm',
|
||||
title: '第 3 步:确认并锁定',
|
||||
description:
|
||||
'在下方图片卡片中确认母版;其他图片可通过“管理候选”查看。人物会同时锁定,场景和道具还需保存锁定状态。',
|
||||
description: '在下方图片卡片中核对并确认母版,质量通过后会同时锁定身份;其他图片可通过“管理候选”查看。',
|
||||
label: '查看候选并确认'
|
||||
}
|
||||
return {
|
||||
@@ -642,7 +618,7 @@ function runNextAction() {
|
||||
</p>
|
||||
<p class="mt-2 text-xs leading-6 text-muted">
|
||||
未注明人物背景时,AI
|
||||
默认采用中国人物特征;剧本和角色设定优先。点击下方角色可关闭此界面并查看详情,不会确认或更改选角。
|
||||
遵循剧本与角色特征;未明确人物背景时保持地域与族裔中性。点击下方角色可关闭此界面并查看详情,不会确认或更改选角。
|
||||
</p>
|
||||
<div class="casting-list" role="group" aria-label="角色选角进度">
|
||||
<NButton
|
||||
@@ -982,6 +958,7 @@ function runNextAction() {
|
||||
detailBlocked || (subject.module === 'character' && !!castingQuery.error.value)
|
||||
"
|
||||
:pending-operation="pendingImageOperation"
|
||||
:validation-result="validationResult"
|
||||
:retry-disabled-reason="imageRetryDisabledReason"
|
||||
@validate="validateImage"
|
||||
@anchor="chooseAnchor"
|
||||
@@ -1068,7 +1045,7 @@ function runNextAction() {
|
||||
:catalog="generationModelsQuery.data.value"
|
||||
:profile="profileQuery.data.value.profile"
|
||||
:disabled="!canGenerateImage"
|
||||
@generate="submitIdentityImage" />
|
||||
:submit-generation="generateImage" />
|
||||
<CastingCandidateDialog
|
||||
v-if="
|
||||
subject?.module === 'character' && profileQuery.data.value?.profile && generationModelsQuery.data.value
|
||||
@@ -1079,7 +1056,7 @@ function runNextAction() {
|
||||
:catalog="generationModelsQuery.data.value"
|
||||
:profile="profileQuery.data.value.profile"
|
||||
:disabled="!canGenerateCandidate"
|
||||
@generate="submitCastingCandidate"
|
||||
:submit-generation="generateCastingCandidate"
|
||||
/></WorkspacePage>
|
||||
<!-- 以下是点击生图时才展示的模型配置引导,关闭后交给唯一项目配置抽屉 -->
|
||||
<AppDialog v-model:open="modelPromptOpen" title="需要配置生成模型" status="warning" @closed="finishModelPrompt">
|
||||
|
||||
@@ -81,10 +81,10 @@ export const subjectIdentityApi = {
|
||||
timeoutMs: 0
|
||||
}),
|
||||
/**
|
||||
* 读取与实际生图同源的输入预览,道具可能执行已确认的结构模型编译。
|
||||
* 只读编译当前已有资料,与实际生图输入同源,不补齐结构规格。
|
||||
* @param subjectId 正式主体 ID
|
||||
* @param input 与实际生图相同的参数
|
||||
* @param signal 只读预览取消信号,可能付费的道具不传
|
||||
* @param signal 取消过期预览
|
||||
* @returns 后端真实输入与最终参数
|
||||
*/
|
||||
previewImage: (subjectId: string, input: GenerateIdentityImageInput, signal?: AbortSignal) =>
|
||||
@@ -117,19 +117,40 @@ export const subjectIdentityApi = {
|
||||
body: input,
|
||||
timeoutMs: 0
|
||||
}),
|
||||
/**
|
||||
* 确认身份母版,质量审核可能耗时,等待真实服务结果。
|
||||
* @param subjectId 正式主体编号
|
||||
* @param imageId 当前候选编号
|
||||
* @returns 已通过事务确认的图片或锁定回执
|
||||
*/
|
||||
setAnchor: (subjectId: string, imageId: string) =>
|
||||
request<IdentityImage>(`${identityPath(subjectId)}/images/${encodeURIComponent(imageId)}/anchor`, {
|
||||
method: 'PUT'
|
||||
method: 'PUT',
|
||||
timeoutMs: 0
|
||||
}),
|
||||
/**
|
||||
* 确认场景或道具母版,通过质量门禁后锁定身份。
|
||||
* @param subjectId 正式主体编号
|
||||
* @param imageId 当前候选编号
|
||||
* @returns 已通过事务确认的图片或锁定回执
|
||||
*/
|
||||
confirmStableAnchor: (subjectId: string, imageId: string) =>
|
||||
request<ConfirmCastingResult>(
|
||||
`${identityPath(subjectId)}/images/${encodeURIComponent(imageId)}/stable-anchor`,
|
||||
{
|
||||
method: 'PUT'
|
||||
method: 'PUT',
|
||||
timeoutMs: 0
|
||||
}
|
||||
),
|
||||
/**
|
||||
* 确认角色选角,通过质量门禁后锁定演员。
|
||||
* @param subjectId 正式主体编号
|
||||
* @param imageId 当前候选编号
|
||||
* @returns 已通过事务确认的图片或锁定回执
|
||||
*/
|
||||
confirmCasting: (subjectId: string, imageId: string) =>
|
||||
request<ConfirmCastingResult>(`${identityPath(subjectId)}/images/${encodeURIComponent(imageId)}/casting`, {
|
||||
method: 'PUT'
|
||||
method: 'PUT',
|
||||
timeoutMs: 0
|
||||
})
|
||||
}
|
||||
@@ -1,9 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import { imageGenerationDefaults } from '../../generation-config/image-defaults'
|
||||
import ImageGenerationPreview from '../../subject-images/components/ImageGenerationPreview.vue'
|
||||
import { useImageGenerationPreview, type ImageGenerationSubmission } from '../../subject-images/generation-preview'
|
||||
import { subjectIdentityApi } from '../api'
|
||||
import ContextNotice from '../../../components/ui/ContextNotice.vue'
|
||||
|
||||
import { NButton, NCheckbox, NFormItem, NInput } from 'naive-ui'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { AppDialog } from '../../../components/ui'
|
||||
import { AppDrawer } from '../../../components/ui'
|
||||
import AppForm from '../../../components/ui/AppForm.vue'
|
||||
import GenerationModelControls from '../../generation-config/components/GenerationModelControls.vue'
|
||||
import type { CreativeProfile, GenerationModelCatalog, GenerationOptions } from '../../generation-config/types'
|
||||
@@ -11,67 +15,78 @@ import type { GenerateCastingCandidateInput } from '../types'
|
||||
|
||||
/** Character 选角候选表单固定使用 primary,每次独立生成且不会自动选择演员。 */
|
||||
const props = defineProps<{
|
||||
/** 正式主体编号。 */
|
||||
subjectId: string
|
||||
/** 主体名称。 */
|
||||
subjectName: string
|
||||
/** 项目活动任务锁。 */
|
||||
disabled: boolean
|
||||
/** 模型能力目录。 */
|
||||
catalog: GenerationModelCatalog
|
||||
/** 项目默认配置。 */
|
||||
profile: CreativeProfile
|
||||
/** 提交已核对的独立选角输入。 */
|
||||
submitGeneration: (input: GenerateCastingCandidateInput) => Promise<ImageGenerationSubmission>
|
||||
}>()
|
||||
/** 全屏生成表单开关。 */
|
||||
const open = defineModel<boolean>('open', { default: false })
|
||||
const emit = defineEmits<{ generate: [input: GenerateCastingCandidateInput] }>()
|
||||
/** 统一表单校验入口。 */
|
||||
const formRef = ref<InstanceType<typeof AppForm> | null>(null)
|
||||
/** 仅本次使用的完整画面描述。 */
|
||||
const prompt = ref('')
|
||||
/** 当前模型供应方。 */
|
||||
const provider = ref('')
|
||||
/** 模型动态参数。 */
|
||||
const generationOptions = ref<GenerationOptions>({})
|
||||
const acknowledged = ref(false)
|
||||
/** 供应方是否可用。 */
|
||||
const valid = computed(() => Boolean(provider.value))
|
||||
|
||||
/** 每次切换角色或重新打开都恢复项目当前图片模型与参数。 */
|
||||
function reset() {
|
||||
prompt.value = ''
|
||||
provider.value = props.profile.imageProvider
|
||||
const selected =
|
||||
props.catalog.images.find(item => item.provider === props.profile.imageProvider && item.enabled) ??
|
||||
props.catalog.images.find(item => item.enabled)
|
||||
provider.value = selected?.provider ?? ''
|
||||
generationOptions.value = {
|
||||
...selected?.defaults,
|
||||
...(selected?.provider === props.profile.imageProvider ? props.profile.imageOptions : {})
|
||||
}
|
||||
const sizeSchema = selected?.generationOptions.find(item => item.key === 'size')
|
||||
if (
|
||||
sizeSchema?.options?.length &&
|
||||
!sizeSchema.options.some(option => option.value === generationOptions.value.size)
|
||||
) {
|
||||
generationOptions.value.size = selected?.defaults.size ?? sizeSchema.options[0]?.value ?? ''
|
||||
}
|
||||
acknowledged.value = false
|
||||
const defaults = imageGenerationDefaults(props.catalog, props.profile)
|
||||
provider.value = defaults.provider
|
||||
generationOptions.value = defaults.options
|
||||
}
|
||||
watch([() => props.subjectId, open, () => props.profile], reset, { immediate: true })
|
||||
|
||||
/** 候选生成显式携带当前图片 Provider 与动态参数,避免 Seedream 尺寸污染 Qwen。 */
|
||||
function submit() {
|
||||
if (props.disabled || !valid.value || !acknowledged.value) return
|
||||
emit('generate', {
|
||||
...(prompt.value.trim() ? { prompt: prompt.value.trim() } : {}),
|
||||
provider: provider.value,
|
||||
generationOptions: generationOptions.value
|
||||
/** 选角正式请求不接收视角和母版开关,固定规则只传入预览。 */
|
||||
const generationInput = computed<GenerateCastingCandidateInput>(() => ({
|
||||
...(prompt.value.trim() ? { prompt: prompt.value.trim() } : {}),
|
||||
provider: provider.value,
|
||||
generationOptions: { ...generationOptions.value }
|
||||
}))
|
||||
/** 选角使用 primary 且不引用当前母版,与正式候选生成一致。 */
|
||||
const { preview, acknowledged, loading, submitting, error, staleNotice, canSubmit, loadPreview, submit } =
|
||||
useImageGenerationPreview({
|
||||
open,
|
||||
target: () => JSON.stringify([props.subjectId, props.profile]),
|
||||
input: () => generationInput.value,
|
||||
disabled: () => props.disabled || !valid.value,
|
||||
load: (input, signal) =>
|
||||
subjectIdentityApi.previewImage(
|
||||
props.subjectId,
|
||||
{ ...input, viewType: 'primary', useAnchorReference: false },
|
||||
signal
|
||||
),
|
||||
generate: input => props.submitGeneration(input)
|
||||
})
|
||||
}
|
||||
/** 当前描述草稿对应的表单模型。 */
|
||||
const formModel = computed(() => ({ prompt: prompt.value }))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 以下是 AI 生成角色候选图模块,生成后仍需用户确认选角 -->
|
||||
<AppDialog
|
||||
<AppDrawer
|
||||
v-model:open="open"
|
||||
title="AI 生成角色候选图"
|
||||
:busy="submitting"
|
||||
:description="`${subjectName} · 生成后需确认选角,才能设为角色母版`"
|
||||
>
|
||||
<AppForm
|
||||
ref="formRef"
|
||||
:model="formModel"
|
||||
:disabled="disabled"
|
||||
:disabled="disabled || submitting"
|
||||
:reset-key="`${open}:${subjectId}`"
|
||||
validate-on-change
|
||||
class="dialog-form-stack"
|
||||
@@ -88,7 +103,7 @@ const formModel = computed(() => ({ prompt: prompt.value }))
|
||||
:label-props="{ for: 'casting-candidate-prompt' }"
|
||||
>
|
||||
<NInput
|
||||
placeholder="建议留空,自动使用已保存的角色特征;未明确人物背景时默认中国人物"
|
||||
placeholder="建议留空,自动使用已保存的角色特征;未明确人物背景时保持地域与族裔中性"
|
||||
:input-props="{ id: 'casting-candidate-prompt' }"
|
||||
class="min-h-24"
|
||||
v-model:value="prompt"
|
||||
@@ -105,27 +120,32 @@ const formModel = computed(() => ({ prompt: prompt.value }))
|
||||
:provider="provider"
|
||||
:options="generationOptions"
|
||||
:aspect-ratio="profile.aspectRatio"
|
||||
:disabled="disabled"
|
||||
:disabled="disabled || submitting"
|
||||
@update:provider="provider = $event"
|
||||
@update:options="generationOptions = $event"
|
||||
/>
|
||||
<!-- 以下是独立选角的输入预览与费用确认模块 -->
|
||||
<ImageGenerationPreview
|
||||
:preview="preview"
|
||||
:loading="loading"
|
||||
:disabled="disabled || submitting || !valid"
|
||||
:error="error"
|
||||
:stale-notice="staleNotice"
|
||||
@load="loadPreview"
|
||||
/>
|
||||
<NCheckbox
|
||||
id="casting-candidate-cost"
|
||||
v-model:checked="acknowledged"
|
||||
:disabled="!preview || submitting"
|
||||
class="flex items-start gap-2 text-xs leading-6"
|
||||
>我已确认调用图片模型可能产生费用,且当前没有同项目生成任务。
|
||||
>我已核对本次独立选角预览,确认图片模型费用。
|
||||
</NCheckbox>
|
||||
</AppForm>
|
||||
<template #footer>
|
||||
<NButton @click="open = false">取消</NButton>
|
||||
<NButton
|
||||
:disabled="disabled || !valid || !acknowledged"
|
||||
:loading="disabled"
|
||||
type="primary"
|
||||
@click="formRef?.validate(submit)"
|
||||
>
|
||||
{{ disabled ? '生成中…' : 'AI 生成角色候选图' }}
|
||||
<NButton :disabled="submitting" @click="open = false">取消</NButton>
|
||||
<NButton :disabled="!canSubmit" :loading="submitting" type="primary" @click="formRef?.validate(submit)">
|
||||
{{ submitting ? '提交中…' : 'AI 生成角色候选图' }}
|
||||
</NButton>
|
||||
</template>
|
||||
</AppDialog>
|
||||
</AppDrawer>
|
||||
</template>
|
||||
@@ -1,4 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import ImageValidationPanel from '../../subject-images/components/ImageValidationPanel.vue'
|
||||
import type { IdentityValidationResult } from '../types'
|
||||
import { NButton, NTag } from 'naive-ui'
|
||||
import { LoaderCircle } from '@lucide/vue'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
@@ -24,6 +26,8 @@ const props = defineProps<{
|
||||
pendingOperation?: IdentityImageOperation | null
|
||||
/** 重新生成暂不可用的具体恢复步骤。 */
|
||||
retryDisabledReason?: string
|
||||
/** 本主体最近一次显式图片审核结果。 */
|
||||
validationResult?: IdentityValidationResult | null
|
||||
}>()
|
||||
/** 图片操作交给父页面核验并执行,浏览候选不会修改母版。 */
|
||||
const emit = defineEmits<{
|
||||
@@ -133,6 +137,12 @@ defineExpose({ openCandidates, closeCandidates })
|
||||
@regenerate="regenerate"
|
||||
/>
|
||||
</div>
|
||||
<!-- 以下是主页面图片本次审核证据模块 -->
|
||||
<ImageValidationPanel
|
||||
v-if="validationResult && images.some(image => image.id === validationResult?.imageId) && !candidatesOpen"
|
||||
class="mt-5"
|
||||
:result="validationResult"
|
||||
/>
|
||||
<!-- 以下是与镜头生产一致的底部图片操作模块 -->
|
||||
<div class="identity-gallery-actions">
|
||||
<NButton v-if="managedCandidates.length" @click="openCandidates"
|
||||
@@ -147,6 +157,7 @@ defineExpose({ openCandidates, closeCandidates })
|
||||
title="身份候选管理"
|
||||
:description="`${subjectName} 的其他候选与辅助参考图;已在主页面展示的图片不重复列出。辅助参考图不能设为母版。`"
|
||||
:width="candidatesWidth"
|
||||
:busy="!!pendingOperation"
|
||||
>
|
||||
<div class="identity-candidate-grid">
|
||||
<IdentityImageCard
|
||||
@@ -165,6 +176,12 @@ defineExpose({ openCandidates, closeCandidates })
|
||||
@regenerate="regenerate"
|
||||
/>
|
||||
</div>
|
||||
<!-- 以下是候选管理中的审核证据模块 -->
|
||||
<ImageValidationPanel
|
||||
v-if="validationResult && managedCandidates.some(image => image.id === validationResult?.imageId)"
|
||||
class="mt-5"
|
||||
:result="validationResult"
|
||||
/>
|
||||
</AppDialog>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
@@ -132,8 +132,11 @@ function regenerate() {
|
||||
<div class="identity-image-card-body">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<!-- 母版已是完成图,仅保留身份标识;候选继续显示生成状态。 -->
|
||||
<NTag v-if="!image.isAnchor && image.status === 'completed'" :bordered="false" size="small"
|
||||
>图片已生成</NTag
|
||||
>
|
||||
<StatusBadge
|
||||
v-if="!image.isAnchor && !failureNotice"
|
||||
v-else-if="!image.isAnchor && !failureNotice"
|
||||
:status="image.status"
|
||||
:label="image.status === 'pending' ? '排队中' : undefined"
|
||||
/>
|
||||
@@ -236,6 +239,10 @@ function regenerate() {
|
||||
: `确认切换 ${subjectName} 的身份母版?旧母版会保留在候选记录中,后续形态图片生成会使用新母版。`
|
||||
"
|
||||
>
|
||||
<!-- 以下是身份母版采纳的费用与门禁说明模块 -->
|
||||
<p class="text-sm leading-7 text-muted">
|
||||
确认时会核对当前来源和质量,可能调用视觉模型并产生审核费用。通过后才锁定并采纳;未通过时保留旧母版,不自动追加生图。
|
||||
</p>
|
||||
<template #footer>
|
||||
<NButton @click="confirming = false">取消</NButton>
|
||||
<NButton :disabled="!canSelect" type="primary" @click="chooseAnchor">{{
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
<script setup lang="ts">
|
||||
import RawDataDetails from '../../../components/ui/RawDataDetails.vue'
|
||||
import FeedbackMessage from '../../../components/ui/FeedbackMessage.vue'
|
||||
|
||||
import { imageGenerationDefaults } from '../../generation-config/image-defaults'
|
||||
import ImageGenerationPreview from '../../subject-images/components/ImageGenerationPreview.vue'
|
||||
import { useImageGenerationPreview, type ImageGenerationSubmission } from '../../subject-images/generation-preview'
|
||||
import ContextNotice from '../../../components/ui/ContextNotice.vue'
|
||||
|
||||
import { referenceGenerationCatalog, referenceGenerationOptions } from '../reference-generation'
|
||||
import ConfirmAction from '../../workflows/ConfirmAction.vue'
|
||||
import { getOperation, runOperation } from '../../workflows/operations'
|
||||
import AppForm from '../../../components/ui/AppForm.vue'
|
||||
import { NFormItem } from 'naive-ui'
|
||||
import { fieldRule } from '../../../lib/form-rules'
|
||||
import { NButton, NCheckbox, NInput, NSelect } from 'naive-ui'
|
||||
import { computed, onBeforeUnmount, ref, watch } from 'vue'
|
||||
import { AppDialog, FieldLabel } from '../../../components/ui'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { AppDrawer, FieldLabel } from '../../../components/ui'
|
||||
import GenerationModelControls from '../../generation-config/components/GenerationModelControls.vue'
|
||||
import type { CreativeProfile, GenerationModelCatalog, GenerationOptions } from '../../generation-config/types'
|
||||
import { subjectIdentityApi } from '../api'
|
||||
import type { IdentityImagePreview } from '../types'
|
||||
import { currentAnchor, identityViewLabels } from '../model'
|
||||
import type { GenerateIdentityImageInput, IdentityImage, IdentityViewType } from '../types'
|
||||
|
||||
@@ -38,12 +34,14 @@ const props = defineProps<{
|
||||
catalog: GenerationModelCatalog
|
||||
/** 已保存的项目默认生成配置。 */
|
||||
profile: CreativeProfile
|
||||
/** 提交当前参数与已核对的输入版本。 */
|
||||
submitGeneration: (input: GenerateIdentityImageInput) => Promise<ImageGenerationSubmission>
|
||||
}>()
|
||||
/** open 的当前界面状态与输入绑定。 */
|
||||
const open = defineModel<boolean>('open', { default: false })
|
||||
/** emit 的当前界面状态与输入绑定。 */
|
||||
const emit = defineEmits<{ generate: [input: GenerateIdentityImageInput] }>()
|
||||
/** 统一表单校验入口。 */
|
||||
const formRef = ref<InstanceType<typeof AppForm> | null>(null)
|
||||
/** 当前生成视角。 */
|
||||
const viewType = ref<IdentityViewType>('primary')
|
||||
/** referenceImageId 的当前界面状态与输入绑定。 */
|
||||
const referenceImageId = ref('')
|
||||
@@ -51,9 +49,8 @@ const referenceImageId = ref('')
|
||||
const prompt = ref('')
|
||||
/** provider 的当前界面状态与输入绑定。 */
|
||||
const provider = ref('')
|
||||
/** 当前模型参数。 */
|
||||
const generationOptions = ref<GenerationOptions>({})
|
||||
/** acknowledged 的当前界面状态与输入绑定。 */
|
||||
const acknowledged = ref(false)
|
||||
/** anchor 的当前界面状态与输入绑定。 */
|
||||
const anchor = computed(() => currentAnchor(props.images))
|
||||
/** allowedViews 的当前界面状态与输入绑定。 */
|
||||
@@ -82,22 +79,9 @@ watch(
|
||||
: 'primary'
|
||||
referenceImageId.value = ''
|
||||
prompt.value = ''
|
||||
const selected =
|
||||
props.catalog.images.find(item => item.provider === props.profile.imageProvider && item.enabled) ??
|
||||
props.catalog.images.find(item => item.enabled)
|
||||
provider.value = selected?.provider ?? ''
|
||||
generationOptions.value = {
|
||||
...selected?.defaults,
|
||||
...(selected?.provider === props.profile.imageProvider ? props.profile.imageOptions : {})
|
||||
}
|
||||
const sizeSchema = selected?.generationOptions.find(item => item.key === 'size')
|
||||
if (
|
||||
sizeSchema?.options?.length &&
|
||||
!sizeSchema.options.some(option => option.value === generationOptions.value.size)
|
||||
) {
|
||||
generationOptions.value.size = selected?.defaults.size ?? sizeSchema.options[0]?.value ?? ''
|
||||
}
|
||||
acknowledged.value = false
|
||||
const defaults = imageGenerationDefaults(props.catalog, props.profile)
|
||||
provider.value = defaults.provider
|
||||
generationOptions.value = defaults.options
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
@@ -118,69 +102,26 @@ const generationInput = computed<GenerateIdentityImageInput>(() => ({
|
||||
provider: provider.value,
|
||||
generationOptions: { ...compatibleOptions.value }
|
||||
}))
|
||||
/** 当前参数的预览结果。 */
|
||||
const preview = ref<IdentityImagePreview | null>(null)
|
||||
/** 预览读取状态。 */
|
||||
const previewLoading = ref(false)
|
||||
/** 道具预览可能付费,保持项目锁直到真实请求结束,不能因关闭弹窗提前释放。 */
|
||||
const paidPreviewPending = ref(false)
|
||||
/** 预览读取错误。 */
|
||||
const previewError = ref('')
|
||||
/** 用于取消迟到预览的请求控制器。 */
|
||||
let previewController: AbortController | undefined
|
||||
/** 参数、主体或弹窗变化时清除旧结果和费用确认。 */
|
||||
/** 监听界面目标变化并重置关联确认状态。 */
|
||||
watch(
|
||||
() => [props.subjectId, open.value, JSON.stringify(generationInput.value), JSON.stringify(props.images)],
|
||||
() => {
|
||||
previewController?.abort()
|
||||
preview.value = null
|
||||
previewError.value = ''
|
||||
previewLoading.value = false
|
||||
acknowledged.value = false
|
||||
}
|
||||
)
|
||||
/** 卸载时取消未完成的只读请求。 */
|
||||
onBeforeUnmount(() => previewController?.abort())
|
||||
/** 读取当前参数的真实预览;道具后端可能编译结构模型,禁止当作免费读取。 */
|
||||
async function loadPreview() {
|
||||
if (props.disabled || !valid.value || previewLoading.value || paidPreviewPending.value) return
|
||||
previewController?.abort()
|
||||
const controller = new AbortController()
|
||||
previewController = controller
|
||||
const subjectId = props.subjectId
|
||||
const projectId = props.profile.projectId
|
||||
const paid = props.module === 'prop'
|
||||
const input = { ...generationInput.value, generationOptions: { ...generationInput.value.generationOptions } }
|
||||
previewLoading.value = true
|
||||
previewError.value = ''
|
||||
paidPreviewPending.value = paid
|
||||
/** 道具请求不传取消信号,取消客户端展示不能取消后端结构模型的工作。 */
|
||||
const inspect = async () => {
|
||||
const result = await subjectIdentityApi.previewImage(subjectId, input, paid ? undefined : controller.signal)
|
||||
if (!controller.signal.aborted && previewController === controller && subjectId === props.subjectId)
|
||||
preview.value = result
|
||||
}
|
||||
try {
|
||||
if (paid) {
|
||||
const ok = await runOperation(projectId, '预览道具结构输入', inspect)
|
||||
if (!ok && !controller.signal.aborted && subjectId === props.subjectId)
|
||||
previewError.value = getOperation(projectId).error
|
||||
} else await inspect()
|
||||
} catch (error) {
|
||||
if (!controller.signal.aborted)
|
||||
previewError.value = error instanceof Error ? error.message : '身份输入预览读取失败'
|
||||
} finally {
|
||||
paidPreviewPending.value = false
|
||||
if (previewController === controller) previewLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 提交生图参数;省略空参考 ID 以保留后端自动选择逻辑。 */
|
||||
function submit() {
|
||||
if (props.disabled || paidPreviewPending.value || !valid.value || !acknowledged.value) return
|
||||
emit('generate', generationInput.value)
|
||||
}
|
||||
/** 三类生图共用预览版本和确认失效保护,预览本身不收费。 */
|
||||
const {
|
||||
preview,
|
||||
acknowledged,
|
||||
loading: previewLoading,
|
||||
submitting,
|
||||
error: previewError,
|
||||
staleNotice,
|
||||
canSubmit,
|
||||
loadPreview,
|
||||
submit
|
||||
} = useImageGenerationPreview({
|
||||
open,
|
||||
target: () =>
|
||||
JSON.stringify([props.subjectId, props.images.filter(image => image.status === 'completed'), props.profile]),
|
||||
input: () => generationInput.value,
|
||||
disabled: () => props.disabled || !valid.value,
|
||||
load: (input, signal) => subjectIdentityApi.previewImage(props.subjectId, input, signal),
|
||||
generate: input => props.submitGeneration(input)
|
||||
})
|
||||
/** formModel 的当前界面状态与输入绑定。 */
|
||||
const formModel = computed(() => ({
|
||||
prompt: prompt.value,
|
||||
@@ -197,12 +138,12 @@ const rules = {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AppDialog v-model:open="open" title="生成身份参考图" :description="subjectName" :busy="paidPreviewPending">
|
||||
<AppDrawer v-model:open="open" title="生成身份参考图" :description="subjectName" :busy="submitting">
|
||||
<AppForm
|
||||
ref="formRef"
|
||||
:model="formModel"
|
||||
:rules="rules"
|
||||
:disabled="disabled"
|
||||
:disabled="disabled || submitting"
|
||||
:reset-key="`${open}:${subjectId}`"
|
||||
validate-on-change
|
||||
class="dialog-form-stack"
|
||||
@@ -210,7 +151,7 @@ const rules = {
|
||||
>
|
||||
<ContextNotice type="info" :show-icon="false" class="text-xs">
|
||||
调用
|
||||
图片模型,每次新增一张图片,可能产生费用。第一张成功的主视图会成为标准参考图;已经有标准参考图时,新主视图只作为候选保留。
|
||||
图片模型,每次新增一张图片,可能产生费用。新图片只作为候选保留,质量审核通过并由你确认后,才能成为身份母版。
|
||||
</ContextNotice>
|
||||
<!-- 以下是多视角与已有身份图选择模块,单一选项不显示选择器 -->
|
||||
<NFormItem
|
||||
@@ -278,51 +219,32 @@ const rules = {
|
||||
:provider="provider"
|
||||
:options="compatibleOptions"
|
||||
:aspect-ratio="profile.aspectRatio"
|
||||
:disabled="disabled"
|
||||
:disabled="disabled || submitting"
|
||||
@update:provider="provider = $event"
|
||||
@update:options="generationOptions = $event"
|
||||
/>
|
||||
<!-- 以下是真实生图输入预览模块 -->
|
||||
<ConfirmAction
|
||||
v-if="module === 'prop'"
|
||||
label="预览道具真实输入"
|
||||
description="缺少有效结构缓存时可能调用文本模型并产生费用;不会生成身份图片。确认后读取本次最终参数。"
|
||||
:disabled="disabled || !valid || previewLoading"
|
||||
acknowledgement
|
||||
@confirm="loadPreview"
|
||||
<ImageGenerationPreview
|
||||
:preview="preview"
|
||||
:loading="previewLoading"
|
||||
:disabled="disabled || submitting || !valid"
|
||||
:error="previewError"
|
||||
:stale-notice="staleNotice"
|
||||
@load="loadPreview"
|
||||
/>
|
||||
<NButton v-else :disabled="disabled || !valid" :loading="previewLoading" @click="loadPreview"
|
||||
>预览本次真实输入</NButton
|
||||
>
|
||||
<FeedbackMessage v-if="previewError" :message="previewError" />
|
||||
<div v-if="preview" class="text-xs space-y-3">
|
||||
<p>实际供应方:{{ preview.provider }} · 模型:{{ preview.model }}</p>
|
||||
<p class="whitespace-pre-wrap">最终提示词:{{ preview.providerPrompt }}</p>
|
||||
<RawDataDetails
|
||||
:value="{
|
||||
referenceImages: preview.referenceImages,
|
||||
referencePlan: preview.referencePlan,
|
||||
generationConfig: preview.generationConfig
|
||||
}"
|
||||
title="参考图与生成设置(高级)"
|
||||
/>
|
||||
</div>
|
||||
<NCheckbox
|
||||
id="identity-image-cost"
|
||||
v-model:checked="acknowledged"
|
||||
:disabled="!preview || submitting"
|
||||
class="flex items-start gap-2 text-xs leading-6"
|
||||
>我已确认后台没有同项目任务,了解本次会调用模型并可能产生费用。</NCheckbox
|
||||
>我已核对本次预览,确认调用图片模型产生的费用。</NCheckbox
|
||||
>
|
||||
</AppForm>
|
||||
<template #footer>
|
||||
<NButton @click="open = false">取消</NButton
|
||||
><NButton
|
||||
:disabled="disabled || paidPreviewPending || !valid || !acknowledged"
|
||||
type="primary"
|
||||
@click="formRef?.validate(submit)"
|
||||
>
|
||||
<NButton :disabled="submitting" @click="open = false">取消</NButton
|
||||
><NButton :disabled="!canSubmit" :loading="submitting" type="primary" @click="formRef?.validate(submit)">
|
||||
确认生成身份图
|
||||
</NButton>
|
||||
</template>
|
||||
</AppDialog>
|
||||
</AppDrawer>
|
||||
</template>
|
||||
@@ -1,4 +1,6 @@
|
||||
import type { SubjectImageStatus, SubjectFormAsset } from '../subject-images/types'
|
||||
import type { ImageGenerationPreview } from '../subject-images/generation-preview'
|
||||
import type { ImageValidationResult } from '../subject-images/validation'
|
||||
|
||||
/** 只有 primary 视图可以选为身份母版,其余视图是辅助参考。 */
|
||||
export type IdentityViewType = 'primary' | 'front' | 'three-quarter' | 'full-body'
|
||||
@@ -62,19 +64,31 @@ export type SaveIdentityInput = Partial<Pick<SubjectIdentity, 'description' | 'g
|
||||
|
||||
/** 单张身份生图;空 referenceImageId 应省略,由后端自动引用当前母版。 */
|
||||
export interface GenerateIdentityImageInput {
|
||||
/** 本次参考视角。 */
|
||||
viewType: IdentityViewType
|
||||
/** 用户显式选择的同主体参考图。 */
|
||||
referenceImageId?: string
|
||||
/** 是否使用当前母版,选角预览固定为 false。 */
|
||||
useAnchorReference?: boolean
|
||||
/** 用户核对的来源与输入版本。 */
|
||||
expectedPreviewFingerprint?: string
|
||||
/** 本次可选宽度。 */
|
||||
width?: number
|
||||
/** 本次可选高度。 */
|
||||
height?: number
|
||||
/** 本次完整画面描述。 */
|
||||
prompt?: string
|
||||
/** 本次图片供应方。 */
|
||||
provider?: string
|
||||
/** 模型支持的动态参数。 */
|
||||
generationOptions?: Record<string, string | number | boolean>
|
||||
}
|
||||
|
||||
/** Character 选角候选固定独立生成 primary,不复用旧 Anchor,也不会自动成为新 Anchor。 */
|
||||
export interface GenerateCastingCandidateInput {
|
||||
prompt?: string
|
||||
provider?: string
|
||||
generationOptions?: Record<string, string | number | boolean>
|
||||
}
|
||||
export type GenerateCastingCandidateInput = Omit<
|
||||
GenerateIdentityImageInput,
|
||||
'viewType' | 'referenceImageId' | 'useAnchorReference'
|
||||
>
|
||||
|
||||
/** 身份文本批量生成回执,不代表已生成参考图。 */
|
||||
export interface IdentityBatchResult {
|
||||
@@ -189,41 +203,10 @@ export type IdentityReceipt =
|
||||
| { kind: 'stable-anchors'; title: string; result: StableAnchorBatchResult }
|
||||
|
||||
/** 最终身份图片 Provider 输入,直接对应身份预览接口。 */
|
||||
export interface IdentityImagePreview {
|
||||
/** 实际供应方。 */
|
||||
provider: string
|
||||
/** 实际模型。 */
|
||||
model: string
|
||||
/** 最终提示词。 */
|
||||
providerPrompt: string
|
||||
/** 实际引用图片地址。 */
|
||||
referenceImages: string[]
|
||||
/** 后端参考图选择计划。 */
|
||||
referencePlan: Record<string, unknown>
|
||||
/** 后端解析后的生成配置。 */
|
||||
generationConfig: Record<string, unknown>
|
||||
}
|
||||
export type IdentityImagePreview = ImageGenerationPreview
|
||||
|
||||
/** 指定身份图片的视觉校验回执。 */
|
||||
export interface IdentityValidationResult {
|
||||
/** 正式主体 ID。 */
|
||||
subjectId: string
|
||||
/** 被校验的图片 ID。 */
|
||||
imageId: string
|
||||
/** 是否通过本次校验。 */
|
||||
passed: boolean
|
||||
/** 校验总结。 */
|
||||
summary: string
|
||||
/** 具体问题。 */
|
||||
issues: Array<{
|
||||
/** 问题类型。 */
|
||||
type: string
|
||||
/** 严重程度。 */
|
||||
severity: string
|
||||
/** 问题描述。 */
|
||||
description: string
|
||||
}>
|
||||
}
|
||||
export type IdentityValidationResult = ImageValidationResult
|
||||
|
||||
/** 有限预算的单主体稳定母版生成参数。 */
|
||||
export interface StableAnchorQualityInput {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { imageValidationPassed } from '../subject-images/validation'
|
||||
import type { ImageGenerationSubmission } from '../subject-images/generation-preview'
|
||||
import { computed, ref, shallowRef, watch } from 'vue'
|
||||
import { usePolling } from '../../composables/usePolling'
|
||||
import { visualStyleApi } from '../visual-style'
|
||||
@@ -5,7 +7,7 @@ import { useProjectGenerationRevision } from '../generation-config/context'
|
||||
import { generationConfigApi } from '../generation-config/api'
|
||||
import { subjectImagesApi } from '../subject-images/api'
|
||||
import { hasRunningImages } from '../subject-images/model'
|
||||
import { batchResultNotice, runOperation, type OperationNotice } from '../workflows/operations'
|
||||
import { batchResultNotice, getOperation, runOperation, type OperationNotice } from '../workflows/operations'
|
||||
import { useProjectMutationGuard } from '../workflows/useProjectMutationGuard'
|
||||
import { useProjectContext } from '../projects/context'
|
||||
import { subjectIdentityApi } from './api'
|
||||
@@ -207,6 +209,18 @@ export function useSubjectIdentity() {
|
||||
const validationResults = ref<Record<string, IdentityValidationResult>>({})
|
||||
/** 质量闭环结果以正式主体 ID 保存。 */
|
||||
const qualityResults = ref<Record<string, StableAnchorQualityResult>>({})
|
||||
/** 审核只适用于本次主体、身份版本和图片输入。 */
|
||||
const validationSourceKey = computed(() =>
|
||||
JSON.stringify([projectId.value, selectedId.value, identity.value, images.value])
|
||||
)
|
||||
/** 来源变化或切换主体后清除旧审核展示,不能沿用历史通过。 */
|
||||
watch(
|
||||
validationSourceKey,
|
||||
() => {
|
||||
delete validationResults.value[selectedId.value]
|
||||
},
|
||||
{ flush: 'sync' }
|
||||
)
|
||||
/** 当前主体的指定图片校验结果。 */
|
||||
const validationResult = computed(() => validationResults.value[selectedId.value] ?? null)
|
||||
/** 当前主体的质量闭环回执。 */
|
||||
@@ -261,6 +275,7 @@ export function useSubjectIdentity() {
|
||||
const id = subject.value.id
|
||||
const name = subject.value.name
|
||||
delete validationResults.value[id]
|
||||
const sourceKey = validationSourceKey.value
|
||||
await runImageOperation(
|
||||
'validate',
|
||||
imageId,
|
||||
@@ -269,12 +284,12 @@ export function useSubjectIdentity() {
|
||||
const result = await subjectIdentityApi.validateImage(id, imageId)
|
||||
if (result.subjectId !== id || result.imageId !== imageId)
|
||||
throw new Error('身份校验回执与提交目标不匹配')
|
||||
validationResults.value[id] = result
|
||||
if (validationSourceKey.value === sourceKey) validationResults.value[id] = result
|
||||
return result
|
||||
},
|
||||
result => ({
|
||||
type: result.passed ? 'success' : 'warning',
|
||||
content: `${name} 的身份图片校验${result.passed ? '通过' : '未通过'}:${result.summary}`
|
||||
type: imageValidationPassed(result) ? 'success' : 'warning',
|
||||
content: `${name} 的身份图片校验${imageValidationPassed(result) ? '通过' : '未通过或待复核'}:${result.summary}`
|
||||
})
|
||||
)
|
||||
}
|
||||
@@ -478,26 +493,25 @@ export function useSubjectIdentity() {
|
||||
/**
|
||||
* 生图不修改文字锁定;即使有自定义提示词,也需已有身份提示词与项目风格。
|
||||
* @param input 已确认的视图、模型与参考图片参数
|
||||
* @param onSubmitStarted 通过前置检查并开始提交时的回调
|
||||
* @returns 任务创建结果及原始错误
|
||||
*/
|
||||
async function generateImage(input: GenerateIdentityImageInput, onSubmitStarted?: () => void) {
|
||||
if (!canGenerateImage.value || !subject.value || !identity.value) return
|
||||
async function generateImage(input: GenerateIdentityImageInput): Promise<ImageGenerationSubmission> {
|
||||
if (!canGenerateImage.value || !subject.value || !identity.value) return { accepted: false }
|
||||
if (
|
||||
input.referenceImageId &&
|
||||
!images.value.some(
|
||||
image => image.id === input.referenceImageId && image.status === 'completed' && image.imageUrl
|
||||
)
|
||||
)
|
||||
return
|
||||
return { accepted: false }
|
||||
const id = subject.value.id
|
||||
const identityId = identity.value.id
|
||||
const project = projectId.value
|
||||
const name = subject.value.name
|
||||
await runOperation(
|
||||
const accepted = await runOperation(
|
||||
project,
|
||||
`提交 ${name} 身份参考图生成`,
|
||||
async () => {
|
||||
onSubmitStarted?.()
|
||||
const started = await subjectIdentityApi.generateImage(id, input)
|
||||
const image = started?.image
|
||||
if (
|
||||
@@ -521,24 +535,24 @@ export function useSubjectIdentity() {
|
||||
},
|
||||
{ type: 'info', content: `${name} 的身份参考图已提交生成,完成后会显示结果。` }
|
||||
)
|
||||
return { accepted, cause: getOperation(project).cause }
|
||||
}
|
||||
|
||||
/**
|
||||
* 单角色候选图固定独立生成,不复用旧母版,生成成功后仍需人工确认选角。
|
||||
* @param input 已确认的候选图模型与生成参数
|
||||
* @param onSubmitStarted 通过前置检查并开始提交时的回调
|
||||
* @returns 任务创建结果及原始错误
|
||||
*/
|
||||
async function generateCastingCandidate(input: GenerateCastingCandidateInput, onSubmitStarted?: () => void) {
|
||||
if (!canGenerateCandidate.value || !subject.value || !identity.value) return
|
||||
async function generateCastingCandidate(input: GenerateCastingCandidateInput): Promise<ImageGenerationSubmission> {
|
||||
if (!canGenerateCandidate.value || !subject.value || !identity.value) return { accepted: false }
|
||||
const id = subject.value.id
|
||||
const identityId = identity.value.id
|
||||
const project = projectId.value
|
||||
const name = subject.value.name
|
||||
await runOperation(
|
||||
const accepted = await runOperation(
|
||||
project,
|
||||
`提交 ${name} 角色候选图生成`,
|
||||
async () => {
|
||||
onSubmitStarted?.()
|
||||
const image = await subjectIdentityApi.generateCastingCandidate(id, input)
|
||||
if (!image || image.identityId !== identityId || !['pending', 'generating'].includes(image.status)) {
|
||||
throw new Error(image?.error || '选角候选任务未成功创建,请刷新后重试。')
|
||||
@@ -552,6 +566,7 @@ export function useSubjectIdentity() {
|
||||
},
|
||||
{ type: 'info', content: `${name} 的角色候选图已提交生成,完成后会显示结果。` }
|
||||
)
|
||||
return { accepted, cause: getOperation(project).cause }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,14 +14,25 @@ import WorkspaceTools from '../../components/ui/WorkspaceTools.vue'
|
||||
import { NButton, NCheckbox, NInput, NInputNumber, NPopover, NScrollbar, NSelect, NTag } from 'naive-ui'
|
||||
import { computed, onScopeDispose, ref, watch, type Directive } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { Search, Download, ImagePlus, ArrowLeft, LayoutGrid, Columns3, LoaderCircle, Settings2 } from '@lucide/vue'
|
||||
import {
|
||||
Search,
|
||||
Download,
|
||||
ImagePlus,
|
||||
ArrowLeft,
|
||||
LayoutGrid,
|
||||
Columns3,
|
||||
LoaderCircle,
|
||||
Settings2,
|
||||
ClipboardCheck
|
||||
} from '@lucide/vue'
|
||||
import { AssetImage, EmptyState, StatusBadge } from '../../components/ui'
|
||||
import { downloadText } from '../../lib/format'
|
||||
import ConfirmAction from '../workflows/ConfirmAction.vue'
|
||||
import { useSubjectImages } from './useSubjectImages'
|
||||
import { hasRunningImages, primaryImage, isIdentityAnchorReuse } from './model'
|
||||
import type { GenerateFormImageInput, SubjectFormAsset } from './types'
|
||||
import type { SubjectFormAsset } from './types'
|
||||
import GenerateImageDialog from './components/GenerateImageDialog.vue'
|
||||
import ImagePreparationDrawer from './components/ImagePreparationDrawer.vue'
|
||||
import ImageGalleryDialog from './components/ImageGalleryDialog.vue'
|
||||
import FormPromptDialog from './components/FormPromptDialog.vue'
|
||||
import FormPromptBatch from './components/FormPromptBatch.vue'
|
||||
@@ -107,6 +118,8 @@ const impactOptions = computed(() => {
|
||||
}))
|
||||
})
|
||||
const toolsOpen = ref(false)
|
||||
/** 免费检查图片阶段规格和母版依赖。 */
|
||||
const preparationOpen = ref(false)
|
||||
/** 移动端禁用纯图标按钮的悬浮说明,避免触摸操作弹出多余浮层。 */
|
||||
const isMobile = ref(false)
|
||||
if (typeof window !== 'undefined') {
|
||||
@@ -262,10 +275,6 @@ function openGallery(form: SubjectFormAsset) {
|
||||
galleryId.value = form.id
|
||||
galleryOpen.value = true
|
||||
}
|
||||
/** 本次提交的 ID 和配置由弹窗固定,关闭弹窗不会取消制作任务。 */
|
||||
function submitGenerate(formId: string, input: GenerateFormImageInput) {
|
||||
void generate(formId, input)
|
||||
}
|
||||
/** 导出真实批量回执供排障,不构造成功图片地址。 */
|
||||
function exportReceipt() {
|
||||
downloadText('subject-images-receipt.json', JSON.stringify(session.value.receipt, null, 2), 'application/json')
|
||||
@@ -316,7 +325,7 @@ const rules = { concurrency: integerRule('批量并发'), limit: integerRule('
|
||||
</div>
|
||||
</div>
|
||||
<DetailDisclosure title="母版继承与过期处理" class="mt-4">
|
||||
人物、场景、道具的基础形态默认复用已确认并锁定的身份母版,无需再次生图。其他形态仍需单独生成。自动复用的主图随母版更新;你手选或独立生成的主图保留,母版变化后需要核对。
|
||||
基础形态可复用已确认并锁定的身份母版,其他形态仍需单独生成。浏览图库不会补建或切换主图;母版变化后,已有图片保留并需重新核对来源与质量。
|
||||
</DetailDisclosure>
|
||||
<FormPromptBatch
|
||||
:generating="isOperationRunning(operation, '批量生成形态正式提示词')"
|
||||
@@ -351,7 +360,7 @@ const rules = { concurrency: integerRule('批量并发'), limit: integerRule('
|
||||
</p>
|
||||
</div>
|
||||
<p class="mt-2 text-[11px] leading-6 text-muted">
|
||||
图库在进入和操作完成后读取最新记录。基础形态会自动复用已锁定身份母版,主图可直接供分镜引用;独立候选与历史失败记录均保留。
|
||||
图库仅查看已保存的图片。已有主图仍须通过当前来源和质量检查,才能用于后续分镜;独立候选与历史失败记录均保留。
|
||||
</p>
|
||||
<section class="mt-4 pt-4">
|
||||
<h3 class="text-sm font-semibold">项目批量生图</h3>
|
||||
@@ -581,6 +590,18 @@ const rules = { concurrency: integerRule('批量并发'), limit: integerRule('
|
||||
<span class="filter-result-count">{{ filtered.length }} 个形态</span>
|
||||
<!-- 四个纯图标按钮使用统一间距;桌面端通过 Popover 解释用途。 -->
|
||||
<div class="gallery-layout-switch" role="group" aria-label="图库视图与操作">
|
||||
<!-- 以下是图片阶段免费准备检查入口 -->
|
||||
<NPopover trigger="hover" placement="top" :disabled="preparationOpen">
|
||||
<template #trigger
|
||||
><NButton
|
||||
class="icon-button"
|
||||
size="small"
|
||||
aria-label="图片准备检查"
|
||||
@click="preparationOpen = true"
|
||||
><template #icon><ClipboardCheck :size="16" /></template></NButton
|
||||
></template>
|
||||
图片准备检查
|
||||
</NPopover>
|
||||
<NPopover trigger="hover" placement="top" :disabled="isMobile">
|
||||
<template #trigger>
|
||||
<NButton
|
||||
@@ -734,7 +755,7 @@ const rules = { concurrency: integerRule('批量并发'), limit: integerRule('
|
||||
: form.images.some(image => image.status === 'completed' && image.imageUrl)
|
||||
? '已有候选图,请确认主参考图'
|
||||
: form.isDefault
|
||||
? '确认并锁定身份母版后自动复用'
|
||||
? '请先确认并锁定身份母版'
|
||||
: '尚未生成主参考图'
|
||||
"
|
||||
/>
|
||||
@@ -842,13 +863,15 @@ const rules = { concurrency: integerRule('批量并发'), limit: integerRule('
|
||||
:catalog="generationModelsQuery.data.value"
|
||||
:profile="profileQuery.data.value.profile"
|
||||
:disabled="blocked || !generateForm || hasRunningImages(generateForm.images)"
|
||||
@generate="submitGenerate" /><ImageGalleryDialog
|
||||
:submit-generation="generate" /><ImageGalleryDialog
|
||||
v-model:open="galleryOpen"
|
||||
:project-id="id"
|
||||
:form="galleryForm"
|
||||
:disabled="blocked || !galleryForm"
|
||||
@changed="refreshAssets" /></template
|
||||
></WorkspacePage>
|
||||
<!-- 以下是免费图片准备计划全屏模块 -->
|
||||
<ImagePreparationDrawer v-model:open="preparationOpen" :project-id="id" />
|
||||
</template>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { request } from '../../lib/http'
|
||||
import type { ImageValidationResult } from './validation'
|
||||
import type {
|
||||
GenerateFormImageInput,
|
||||
FormImageQualityInput,
|
||||
FormImageQualityResult,
|
||||
GenerateProjectImagesInput,
|
||||
GenerateFormPromptsInput,
|
||||
FormPromptResult,
|
||||
@@ -17,6 +20,16 @@ function formPath(id: string) {
|
||||
|
||||
/** 形态图库 API:读取与生成分离,生成不自动重试,不设置客户端短超时。 */
|
||||
export const subjectImagesApi = {
|
||||
/**
|
||||
* 显式准备道具结构规格,可能调用文字模型,不生成图片。
|
||||
* @param formId 正式形态编号
|
||||
* @returns 当前结构规格,页面随后重新读取正式准备状态
|
||||
*/
|
||||
prepareStructure: (formId: string) =>
|
||||
request<Record<string, unknown>>(`/subject-forms/${encodeURIComponent(formId)}/prop-structure-spec/generate`, {
|
||||
method: 'POST',
|
||||
timeoutMs: 0
|
||||
}),
|
||||
/** 生成并保存正式生图提示词;force 仅覆盖提示词,不生成或替换图片。 */
|
||||
generatePrompt: (formId: string, force: boolean) =>
|
||||
request<FormPromptResult | null>(`/subject-forms/${encodeURIComponent(formId)}/generation-prompt`, {
|
||||
@@ -34,10 +47,41 @@ export const subjectImagesApi = {
|
||||
listForms: (projectId: string, signal?: AbortSignal) =>
|
||||
request<SubjectFormAsset[]>(`/projects/${encodeURIComponent(projectId)}/subject-forms`, { signal }),
|
||||
listImages: (formId: string, signal?: AbortSignal) => request<SubjectImage[]>(formPath(formId), { signal }),
|
||||
/** 解析正式 Prompt、参考图顺序与后端生成配置,不创建图片任务。 */
|
||||
/** 预览与本次生成使用相同的提示词、模型和参数。 */
|
||||
preview: (formId: string, input: Pick<GenerateFormImageInput, 'prompt' | 'provider' | 'generationOptions'> = {}) =>
|
||||
request<SubjectImageGenerationPreview>(`${formPath(formId)}/preview`, { method: 'POST', body: input }),
|
||||
/**
|
||||
* 用户确认费用后审核指定候选,不自动切换主图。
|
||||
* @param formId 正式形态编号
|
||||
* @param imageId 本形态的图片编号
|
||||
* @returns 本次结构化审核与原始定义证据
|
||||
*/
|
||||
validate: (formId: string, imageId: string) =>
|
||||
request<ImageValidationResult>(`${formPath(formId)}/${encodeURIComponent(imageId)}/validate`, {
|
||||
method: 'POST',
|
||||
timeoutMs: 0
|
||||
}),
|
||||
/**
|
||||
* 按用户明确预算审核并修复已有候选,通过后才晋升主图。
|
||||
* @param formId 正式形态编号
|
||||
* @param input 候选、供应方与有限修复次数
|
||||
* @returns 各轮候选和主图变化的真实回执
|
||||
*/
|
||||
generateQuality: (formId: string, input: FormImageQualityInput) =>
|
||||
request<FormImageQualityResult>(`${formPath(formId)}/generate-quality`, {
|
||||
method: 'POST',
|
||||
body: input,
|
||||
timeoutMs: 0
|
||||
}),
|
||||
/**
|
||||
* 只读编译当前已有资料,不自动补齐描述或规格。
|
||||
* @param formId 正式形态编号
|
||||
* @param input 本次生成参数
|
||||
* @param signal 取消过期预览
|
||||
* @returns 绑定来源版本的实际输入
|
||||
*/
|
||||
preview: (
|
||||
formId: string,
|
||||
input: Omit<GenerateFormImageInput, 'setPrimary' | 'expectedPreviewFingerprint'> = {},
|
||||
signal?: AbortSignal
|
||||
) => request<SubjectImageGenerationPreview>(`${formPath(formId)}/preview`, { method: 'POST', body: input, signal }),
|
||||
generate: (formId: string, input: GenerateFormImageInput) =>
|
||||
request<SubjectImage | null>(formPath(formId), { method: 'POST', body: input, timeoutMs: 0 }),
|
||||
generateProject: (projectId: string, input: GenerateProjectImagesInput) =>
|
||||
@@ -46,6 +90,15 @@ export const subjectImagesApi = {
|
||||
body: input,
|
||||
timeoutMs: 0
|
||||
}),
|
||||
/**
|
||||
* 当前质量和来源检查通过后切换主图,不提前乐观更新。
|
||||
* @param formId 正式形态编号
|
||||
* @param imageId 当前候选编号
|
||||
* @returns 已确认的正式主图
|
||||
*/
|
||||
setPrimary: (formId: string, imageId: string) =>
|
||||
request<SubjectImage | null>(`${formPath(formId)}/${encodeURIComponent(imageId)}/primary`, { method: 'PUT' })
|
||||
request<SubjectImage | null>(`${formPath(formId)}/${encodeURIComponent(imageId)}/primary`, {
|
||||
method: 'PUT',
|
||||
timeoutMs: 0
|
||||
})
|
||||
}
|
||||
@@ -1,225 +1,146 @@
|
||||
<script setup lang="ts">
|
||||
import ContextNotice from '../../../components/ui/ContextNotice.vue'
|
||||
|
||||
import AppForm from '../../../components/ui/AppForm.vue'
|
||||
import { NFormItem } from 'naive-ui'
|
||||
import { NButton, NCheckbox, NCollapse, NCollapseItem, NInput, NTag } from 'naive-ui'
|
||||
import { imageGenerationDefaults } from '../../generation-config/image-defaults'
|
||||
import { NButton, NCheckbox, NCollapse, NCollapseItem, NFormItem, NInput } from 'naive-ui'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { AppDialog } from '../../../components/ui'
|
||||
import { errorMessage } from '../../../lib/http'
|
||||
import { subjectImagesApi } from '../api'
|
||||
import { AppDrawer } from '../../../components/ui'
|
||||
import AppForm from '../../../components/ui/AppForm.vue'
|
||||
import ContextNotice from '../../../components/ui/ContextNotice.vue'
|
||||
import GenerationModelControls from '../../generation-config/components/GenerationModelControls.vue'
|
||||
import type { CreativeProfile, GenerationModelCatalog, GenerationOptions } from '../../generation-config/types'
|
||||
import { subjectImagesApi } from '../api'
|
||||
import { useImageGenerationPreview, type ImageGenerationSubmission } from '../generation-preview'
|
||||
import { primaryImage } from '../model'
|
||||
import type { GenerateFormImageInput, SubjectFormAsset, SubjectImageGenerationPreview } from '../types'
|
||||
import type { GenerateFormImageInput, SubjectFormAsset } from '../types'
|
||||
import ImageGenerationPreview from './ImageGenerationPreview.vue'
|
||||
|
||||
/** 单形态生成确认:尺寸与自定义 Prompt 只用于本次请求。 */
|
||||
/** 单形态生图先核对最终输入,再明确提交一次。 */
|
||||
const props = defineProps<{
|
||||
/** 当前正式形态。 */
|
||||
form: SubjectFormAsset | null
|
||||
/** 项目或图片任务锁。 */
|
||||
disabled: boolean
|
||||
/** 模型参数目录。 */
|
||||
catalog: GenerationModelCatalog
|
||||
/** 项目默认配置。 */
|
||||
profile: CreativeProfile
|
||||
/** 提交固定形态与预览版本,返回任务是否已创建。 */
|
||||
submitGeneration: (formId: string, input: GenerateFormImageInput) => Promise<ImageGenerationSubmission>
|
||||
}>()
|
||||
/** 全屏表单开关。 */
|
||||
const open = defineModel<boolean>('open', { default: false })
|
||||
const emit = defineEmits<{ generate: [formId: string, input: GenerateFormImageInput] }>()
|
||||
const formRef = ref<InstanceType<typeof AppForm> | null>(null)
|
||||
/** 仅本次使用的完整描述。 */
|
||||
const prompt = ref('')
|
||||
/** 当前图片供应方。 */
|
||||
const provider = ref('')
|
||||
/** 当前模型动态参数。 */
|
||||
const generationOptions = ref<GenerationOptions>({})
|
||||
/** 明确选择质量通过后切换主图,默认只保留候选。 */
|
||||
const setPrimary = ref(false)
|
||||
const acknowledged = ref(false)
|
||||
const preview = ref<SubjectImageGenerationPreview | null>(null)
|
||||
const previewError = ref('')
|
||||
const previewPending = ref(false)
|
||||
/** 预览与当前形态、提示词及模型配置绑定,避免显示过期结果。 */
|
||||
const previewKey = computed(() =>
|
||||
JSON.stringify([props.form?.id, prompt.value, provider.value, generationOptions.value])
|
||||
)
|
||||
watch(previewKey, () => {
|
||||
preview.value = null
|
||||
previewError.value = ''
|
||||
})
|
||||
|
||||
/** 每次打开重新建立表单,避免把另一形态的 Prompt 或尺寸带入请求。 */
|
||||
/** 预览与生成共用同一份输入。 */
|
||||
const generationInput = computed<GenerateFormImageInput>(() => ({
|
||||
...(prompt.value.trim() ? { prompt: prompt.value.trim() } : {}),
|
||||
provider: provider.value,
|
||||
generationOptions: { ...generationOptions.value },
|
||||
setPrimary: setPrimary.value
|
||||
}))
|
||||
/** 表单模型用于统一禁用与间距。 */
|
||||
const formModel = computed(() => ({ prompt: prompt.value }))
|
||||
/** 目标、参数与可见周期变化后废弃旧确认。 */
|
||||
const { preview, acknowledged, loading, submitting, error, staleNotice, canSubmit, loadPreview, submit } =
|
||||
useImageGenerationPreview({
|
||||
open,
|
||||
target: () =>
|
||||
JSON.stringify([props.form?.id, props.form?.generationPrompt, props.form?.subject.identity, props.profile]),
|
||||
input: () => generationInput.value,
|
||||
disabled: () => props.disabled || !props.form || !provider.value,
|
||||
load: async (input, signal) => {
|
||||
const formId = props.form!.id
|
||||
const { setPrimary: _setPrimary, ...previewInput } = input
|
||||
const result = await subjectImagesApi.preview(formId, previewInput, signal)
|
||||
if (result.subjectFormId !== formId) throw new Error('预览结果与当前形态不匹配,请重新读取。')
|
||||
return result
|
||||
},
|
||||
generate: input => props.submitGeneration(props.form!.id, input)
|
||||
})
|
||||
/** 每次打开恢复项目配置,不沿用其它形态的草稿。 */
|
||||
watch(
|
||||
() => [open.value, props.form?.id],
|
||||
() => {
|
||||
prompt.value = ''
|
||||
const selected =
|
||||
props.catalog.images.find(item => item.provider === props.profile.imageProvider && item.enabled) ??
|
||||
props.catalog.images.find(item => item.enabled)
|
||||
provider.value = selected?.provider ?? ''
|
||||
generationOptions.value = {
|
||||
...selected?.defaults,
|
||||
...(selected?.provider === props.profile.imageProvider ? props.profile.imageOptions : {})
|
||||
}
|
||||
const sizeSchema = selected?.generationOptions.find(item => item.key === 'size')
|
||||
if (
|
||||
sizeSchema?.options?.length &&
|
||||
!sizeSchema.options.some(option => option.value === generationOptions.value.size)
|
||||
) {
|
||||
generationOptions.value.size = selected?.defaults.size ?? sizeSchema.options[0]?.value ?? ''
|
||||
}
|
||||
acknowledged.value = false
|
||||
preview.value = null
|
||||
previewError.value = ''
|
||||
previewPending.value = false
|
||||
setPrimary.value = props.form ? !primaryImage(props.form.images) : false
|
||||
const defaults = imageGenerationDefaults(props.catalog, props.profile)
|
||||
provider.value = defaults.provider
|
||||
generationOptions.value = defaults.options
|
||||
setPrimary.value = false
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
/** 预览由后端按当前正式配置编译,不提交图片生成任务。 */
|
||||
async function loadPreview() {
|
||||
if (!props.form || previewPending.value) return
|
||||
previewPending.value = true
|
||||
previewError.value = ''
|
||||
const requestKey = previewKey.value
|
||||
try {
|
||||
const result = await subjectImagesApi.preview(props.form.id, {
|
||||
...(prompt.value.trim() ? { prompt: prompt.value.trim() } : {}),
|
||||
provider: provider.value,
|
||||
generationOptions: generationOptions.value
|
||||
})
|
||||
if (requestKey !== previewKey.value || !open.value) return
|
||||
if (!result || result.subjectFormId !== props.form.id) throw new Error('预览结果与当前形态不匹配。')
|
||||
preview.value = result
|
||||
} catch (cause) {
|
||||
if (requestKey === previewKey.value && open.value) {
|
||||
preview.value = null
|
||||
previewError.value = errorMessage(cause)
|
||||
}
|
||||
} finally {
|
||||
previewPending.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 完成前置确认后只发出一次明确的生图请求,不触发整条生产流程。 */
|
||||
function submit() {
|
||||
if (!props.form || props.disabled || !provider.value || !acknowledged.value) return
|
||||
emit('generate', props.form.id, {
|
||||
setPrimary: setPrimary.value,
|
||||
...(prompt.value.trim() ? { prompt: prompt.value.trim() } : {}),
|
||||
provider: provider.value,
|
||||
generationOptions: generationOptions.value
|
||||
})
|
||||
open.value = false
|
||||
}
|
||||
const formModel = computed(() => ({ prompt: prompt.value }))
|
||||
const rules = {}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 以下是宽版形态图片生成弹窗模块,长提示词与模型参数保留完整空间 -->
|
||||
<AppDialog
|
||||
<!-- 以下是生成配置与实际输入核对模块,正文独立滚动,操作固定在底栏 -->
|
||||
<AppDrawer
|
||||
v-model:open="open"
|
||||
title="生成形态图片"
|
||||
wide
|
||||
:description="`${form?.subject.name || ''} · ${form?.name || ''}`"
|
||||
:busy="submitting"
|
||||
>
|
||||
<AppForm
|
||||
ref="formRef"
|
||||
:model="formModel"
|
||||
:rules="rules"
|
||||
:disabled="disabled"
|
||||
:reset-key="`${open}:${form?.id}`"
|
||||
validate-on-change
|
||||
class="dialog-form-stack"
|
||||
@submit="submit"
|
||||
>
|
||||
<ContextNotice type="info" :show-icon="false" class="text-xs"
|
||||
>使用当前配置的图片模型生成一张新图,可能产生费用。已有图片会保留。</ContextNotice
|
||||
<AppForm :model="formModel" :disabled="disabled || submitting" class="dialog-form-stack" @submit="submit">
|
||||
<ContextNotice type="info" :show-icon="false"
|
||||
>新增图片可能产生费用,已有图片会保留。图片生成完成后仍需质量审核。</ContextNotice
|
||||
>
|
||||
<p class="text-xs leading-6 text-muted">
|
||||
基础形态默认复用已确认并锁定的身份母版,无需重复生成。此处会调用图片模型新增独立候选,用于不同形态或需要调整外观的情况;是否替换主图由下方选项决定。
|
||||
</p>
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<NButton :loading="previewPending" :disabled="!form" @click="loadPreview">预览实际生成输入</NButton>
|
||||
<span class="text-xs text-muted">只查看本次生成图片会用到的参考图和描述,不生成图片。</span>
|
||||
</div>
|
||||
<ContextNotice v-if="previewError" type="error" :show-icon="false">{{ previewError }}</ContextNotice>
|
||||
<div v-if="preview" class="dialog-result-card text-xs leading-6">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<strong>{{ preview.provider }} / {{ preview.model }}</strong>
|
||||
<NTag size="small" :bordered="false">{{ preview.references.length }} 张参考图</NTag>
|
||||
</div>
|
||||
<ul v-if="preview.references.length" class="mt-3 space-y-1 text-muted">
|
||||
<li v-for="item in preview.references" :key="`${item.imageNumber}:${item.imageId}`">
|
||||
图 {{ item.imageNumber }} · {{ item.role }} · <code>{{ item.imageId }}</code>
|
||||
</li>
|
||||
</ul>
|
||||
<p v-else class="mt-3 text-muted">本次没有图片参考。</p>
|
||||
<NCollapse class="mt-3" :default-expanded-names="['prompt']">
|
||||
<NCollapseItem name="prompt" title="本次实际使用的画面描述">
|
||||
<p class="mt-3 whitespace-pre-wrap">{{ preview.providerPrompt }}</p>
|
||||
</NCollapseItem>
|
||||
<NCollapseItem name="config" title="生成配置">
|
||||
<pre class="mt-3 whitespace-pre-wrap">{{
|
||||
JSON.stringify(preview.generationConfig, null, 2)
|
||||
}}</pre>
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
</div>
|
||||
<NFormItem
|
||||
class="block"
|
||||
path="prompt"
|
||||
label="自定义提示词(可选,仅用于本次)"
|
||||
:label-props="{ for: 'image-prompt' }"
|
||||
><NInput
|
||||
placeholder="可留空使用已保存的画面描述;尚未准备时会先自动补齐。"
|
||||
<NFormItem label="自定义画面描述(可选,仅用于本次)" :label-props="{ for: 'image-prompt' }">
|
||||
<NInput
|
||||
:input-props="{ id: 'image-prompt' }"
|
||||
class="min-h-28"
|
||||
v-model:value="prompt"
|
||||
type="textarea"
|
||||
:disabled="submitting"
|
||||
:autosize="{ minRows: 3, maxRows: 12 }"
|
||||
></NInput>
|
||||
placeholder="留空使用已保存的画面描述;缺少资料时请先准备,再读取预览。"
|
||||
/>
|
||||
</NFormItem>
|
||||
<NCollapse
|
||||
v-if="form?.generationPrompt || form?.appearancePrompt"
|
||||
class="text-xs"
|
||||
:default-expanded-names="['details']"
|
||||
><NCollapseItem name="details"
|
||||
><template #header>{{
|
||||
form?.generationPrompt ? '查看正式生图提示词' : '查看原始外观素材(不是最终提示词)'
|
||||
}}</template>
|
||||
<p class="mt-3 whitespace-pre-wrap leading-6">
|
||||
<NCollapse v-if="form?.generationPrompt || form?.appearancePrompt">
|
||||
<NCollapseItem
|
||||
name="saved"
|
||||
:title="form?.generationPrompt ? '查看已保存的画面描述' : '查看原始外观说明'"
|
||||
>
|
||||
<p class="whitespace-pre-wrap wrap-anywhere text-xs leading-6">
|
||||
{{ form.generationPrompt ?? form.appearancePrompt }}
|
||||
</p></NCollapseItem
|
||||
></NCollapse
|
||||
>
|
||||
</p>
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
<GenerationModelControls
|
||||
type="image"
|
||||
:catalog="catalog"
|
||||
:provider="provider"
|
||||
:options="generationOptions"
|
||||
:aspect-ratio="profile.aspectRatio"
|
||||
:disabled="disabled"
|
||||
:disabled="disabled || submitting"
|
||||
@update:provider="provider = $event"
|
||||
@update:options="generationOptions = $event"
|
||||
/>
|
||||
<p v-if="!form?.generationPrompt" class="text-xs leading-6 text-muted">
|
||||
未填写自定义描述时,会先整理画面描述,再生成图片;这两个步骤都可能产生费用。角色的原始外观说明会先整理后使用。
|
||||
<!-- 以下是主图切换选择模块,生成完成不等于审核通过 -->
|
||||
<NCheckbox v-model:checked="setPrimary" :disabled="submitting">生成并通过质量审核后设为主参考图</NCheckbox>
|
||||
<p v-if="setPrimary" class="text-xs leading-6 text-muted">
|
||||
会调用视觉审核并可能产生额外费用。{{
|
||||
form && primaryImage(form.images) ? '审核未通过时保留旧主图。' : '审核未通过时仅保留候选图。'
|
||||
}}不会自动重试或追加生图。
|
||||
</p>
|
||||
<NCheckbox v-model:checked="setPrimary" class="flex gap-2 text-sm">生成成功后设为此形态主参考图</NCheckbox>
|
||||
<p v-if="setPrimary && form && primaryImage(form.images)" class="text-xs text-muted">
|
||||
会替换当前主图标记,旧图片保留。已有视频提示词不会自动更新。
|
||||
</p>
|
||||
<NCheckbox
|
||||
id="confirm-image-cost"
|
||||
v-model:checked="acknowledged"
|
||||
class="flex items-start gap-2 text-xs leading-6"
|
||||
>我已确认后台没有同项目的生成任务,了解本次会调用模型并产生费用。</NCheckbox
|
||||
<!-- 以下是与当前参数绑定的只读预览及费用确认模块 -->
|
||||
<ImageGenerationPreview
|
||||
:preview="preview"
|
||||
:loading="loading"
|
||||
:disabled="disabled || submitting || !form || !provider"
|
||||
:error="error"
|
||||
:stale-notice="staleNotice"
|
||||
@load="loadPreview"
|
||||
/>
|
||||
<NCheckbox id="confirm-image-cost" v-model:checked="acknowledged" :disabled="!preview || submitting"
|
||||
>我已核对本次预览和主图选项,确认模型费用。</NCheckbox
|
||||
>
|
||||
</AppForm>
|
||||
<template #footer>
|
||||
<NButton @click="open = false">取消</NButton
|
||||
><NButton
|
||||
:disabled="disabled || !form || !provider || !acknowledged"
|
||||
type="primary"
|
||||
@click="formRef?.validate(submit)"
|
||||
>
|
||||
确认生成图片
|
||||
</NButton>
|
||||
<NButton :disabled="submitting" @click="open = false">取消</NButton>
|
||||
<NButton type="primary" :disabled="!canSubmit" :loading="submitting" @click="submit">确认生成图片</NButton>
|
||||
</template>
|
||||
</AppDialog>
|
||||
</AppDrawer>
|
||||
</template>
|
||||
@@ -1,36 +1,59 @@
|
||||
<script setup lang="ts">
|
||||
import RawDataDetails from '../../../components/ui/RawDataDetails.vue'
|
||||
import ImageValidationPanel from './ImageValidationPanel.vue'
|
||||
import { imageValidationPassed, type ImageValidationResult } from '../validation'
|
||||
import { errorMessage } from '../../../lib/http'
|
||||
import { userFacingText } from '../../../lib/user-facing-text'
|
||||
import ContextNotice from '../../../components/ui/ContextNotice.vue'
|
||||
|
||||
import { NScrollbar, NButton, NTag } from 'naive-ui'
|
||||
import { NScrollbar, NButton, NTag, NInputNumber, NCollapse, NCollapseItem } from 'naive-ui'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { ExternalLink, RefreshCw } from '@lucide/vue'
|
||||
import { AppDialog, AssetImage, StatusBadge } from '../../../components/ui'
|
||||
import { ExternalLink, RefreshCw, ShieldCheck, Check, WandSparkles, Eye } from '@lucide/vue'
|
||||
import { AppDrawer, AssetImage, StatusBadge } from '../../../components/ui'
|
||||
import { useQuery } from '../../../composables/useQuery'
|
||||
import { referenceImageUrl } from '../../../lib/assets'
|
||||
import { formatDate } from '../../../lib/format'
|
||||
import { getOperation, runOperation } from '../../workflows/operations'
|
||||
import { subjectImagesApi } from '../api'
|
||||
import { hasRunningImages, primaryImage, currentIdentityAnchorId, isIdentityAnchorReuse } from '../model'
|
||||
import type { SubjectFormAsset } from '../types'
|
||||
import type { SubjectFormAsset, FormImageQualityResult } from '../types'
|
||||
|
||||
/** 形态图片历史与主图选择;历史查询只在弹窗打开时进行。 */
|
||||
const props = defineProps<{ projectId: string; form: SubjectFormAsset | null; disabled: boolean }>()
|
||||
/** 全屏图库开关。 */
|
||||
const open = defineModel<boolean>('open', { default: false })
|
||||
/** 成功保存质量或主图后刷新外部列表。 */
|
||||
const emit = defineEmits<{ changed: [] }>()
|
||||
/** 当前查看的图片编号。 */
|
||||
const selectedId = ref('')
|
||||
const confirming = ref(false)
|
||||
/** 当前底栏确认操作,打开图库时不会自动调用审核。 */
|
||||
const confirming = ref<'primary' | 'validate' | 'quality' | null>(null)
|
||||
/** 当前请求对应的操作和图片,避免切换时加载状态串到其它图片。 */
|
||||
const pending = ref<{ kind: 'primary' | 'validate' | 'quality'; imageId: string } | null>(null)
|
||||
/** 当前选中图片本次审核结果。 */
|
||||
const validation = ref<ImageValidationResult | null>(null)
|
||||
/** 当前图库操作失败原因。 */
|
||||
const actionError = ref('')
|
||||
/** 修复默认不追加生图,必须由用户明确增加次数。 */
|
||||
const maxRepairAttempts = ref(0)
|
||||
/** 有限预算质量流程的真实终态。 */
|
||||
const qualityResult = ref<FormImageQualityResult | null>(null)
|
||||
/** 打开周期中的正式形态查询键。 */
|
||||
const key = computed(() => (open.value ? (props.form?.id ?? '') : ''))
|
||||
/** 只读图库查询,不补建主图。 */
|
||||
const query = useQuery(key, async (id, signal) => {
|
||||
if (!id) return null
|
||||
const rows = await subjectImagesApi.listImages(id, signal)
|
||||
if (rows.some(image => image.subjectFormId !== id)) throw new Error('图片记录与当前形态不匹配,请刷新后重试。')
|
||||
return rows
|
||||
})
|
||||
/** 最近读取的正式图片。 */
|
||||
const images = computed(() => query.data.value ?? [])
|
||||
/** 当前图片,优先展示主图。 */
|
||||
const selected = computed(
|
||||
() => images.value.find(image => image.id === selectedId.value) ?? primaryImage(images.value) ?? images.value[0]
|
||||
)
|
||||
/** 项目内的真实活动锁。 */
|
||||
const operation = computed(() => getOperation(props.projectId))
|
||||
/** 历史复用图失去当前母版或基础形态条件时只供查看,不能重新设为主图。 */
|
||||
const reusedImageUnavailable = computed(
|
||||
@@ -45,58 +68,157 @@ const canSetPrimary = computed(
|
||||
() =>
|
||||
!props.disabled &&
|
||||
!operation.value.pending &&
|
||||
!pending.value &&
|
||||
!query.loading.value &&
|
||||
!query.error.value &&
|
||||
!hasRunningImages(images.value) &&
|
||||
selected.value?.status === 'completed' &&
|
||||
!!selected.value.imageUrl &&
|
||||
!selected.value.isPrimary &&
|
||||
selected.value.qualityPassed !== false &&
|
||||
!selected.value.qualityIssues?.some(issue => issue.severity === 'error') &&
|
||||
!(validation.value?.imageId === selected.value.id && !imageValidationPassed(validation.value)) &&
|
||||
!reusedImageUnavailable.value
|
||||
)
|
||||
/** 已完成候选允许显式重新审核,即使此前质量未通过。 */
|
||||
const canValidate = computed(
|
||||
() =>
|
||||
!props.disabled &&
|
||||
!operation.value.pending &&
|
||||
!pending.value &&
|
||||
!query.loading.value &&
|
||||
!query.error.value &&
|
||||
!hasRunningImages(images.value) &&
|
||||
selected.value?.status === 'completed' &&
|
||||
!!selected.value.imageUrl
|
||||
)
|
||||
/** 底栏确认只对当前可用操作开放。 */
|
||||
const canConfirm = computed(() =>
|
||||
confirming.value === 'primary'
|
||||
? canSetPrimary.value
|
||||
: canValidate.value &&
|
||||
(confirming.value === 'validate' ||
|
||||
(confirming.value === 'quality' &&
|
||||
Number.isInteger(maxRepairAttempts.value) &&
|
||||
maxRepairAttempts.value >= 0 &&
|
||||
maxRepairAttempts.value <= 3))
|
||||
)
|
||||
/** 当前选中图片的公开原图地址。 */
|
||||
const imageUrl = computed(() => (selected.value?.imageUrl ? referenceImageUrl(selected.value.imageUrl) : null))
|
||||
watch(key, () => {
|
||||
selectedId.value = ''
|
||||
confirming.value = false
|
||||
confirming.value = null
|
||||
validation.value = null
|
||||
actionError.value = ''
|
||||
maxRepairAttempts.value = 0
|
||||
qualityResult.value = null
|
||||
})
|
||||
watch(
|
||||
() => selected.value?.id,
|
||||
() => {
|
||||
confirming.value = false
|
||||
confirming.value = null
|
||||
validation.value = null
|
||||
actionError.value = ''
|
||||
maxRepairAttempts.value = 0
|
||||
qualityResult.value = null
|
||||
}
|
||||
)
|
||||
|
||||
/** 切换主图只调用 PUT,不调用模型;目标在提交时固定。 */
|
||||
async function choosePrimary() {
|
||||
if (!canSetPrimary.value || !confirming.value || !selected.value || !props.form) return
|
||||
/** 打开有限预算确认,默认不允许追加生图。 */
|
||||
function requestQuality() {
|
||||
if (!canValidate.value) return
|
||||
maxRepairAttempts.value = 0
|
||||
confirming.value = 'quality'
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅在用户核对费用后执行审核或主图切换,失败保留原主图。
|
||||
* @returns 当前请求处理及只读刷新完成
|
||||
*/
|
||||
async function confirmAction() {
|
||||
if (!canConfirm.value || !selected.value || !props.form || !confirming.value) return
|
||||
const formId = props.form.id
|
||||
const imageId = selected.value.id
|
||||
const subjectId = props.form.subjectId
|
||||
const projectId = props.projectId
|
||||
confirming.value = false
|
||||
await runOperation(projectId, `设置 ${props.form.subject.name} · ${props.form.name} 主图`, async () => {
|
||||
const result = await subjectImagesApi.setPrimary(formId, imageId)
|
||||
if (
|
||||
!result ||
|
||||
result.id !== imageId ||
|
||||
result.subjectFormId !== formId ||
|
||||
!result.isPrimary ||
|
||||
result.status !== 'completed'
|
||||
)
|
||||
throw new Error('主图切换结果尚未确认,请先刷新图片列表后核对。')
|
||||
})
|
||||
emit('changed')
|
||||
await query.refresh()
|
||||
const kind = confirming.value
|
||||
const provider = selected.value.provider
|
||||
const budget = maxRepairAttempts.value
|
||||
const requestKey = key.value
|
||||
selectedId.value = imageId
|
||||
pending.value = { kind, imageId }
|
||||
actionError.value = ''
|
||||
const ok = await runOperation(
|
||||
projectId,
|
||||
`${kind === 'quality' ? '审核与修复' : kind === 'validate' ? '审核' : '设置主图'} · ${props.form.subject.name}`,
|
||||
async () => {
|
||||
if (kind === 'quality') {
|
||||
const result = await subjectImagesApi.generateQuality(formId, {
|
||||
imageId,
|
||||
provider,
|
||||
maxRepairAttempts: budget
|
||||
})
|
||||
if (
|
||||
result.subjectFormId !== formId ||
|
||||
result.initialImageId !== imageId ||
|
||||
!result.finalImageId ||
|
||||
!Array.isArray(result.attempts) ||
|
||||
result.maxRepairAttempts !== budget
|
||||
)
|
||||
throw new Error('质量处理回执不完整,请刷新图库核对。')
|
||||
if (key.value === requestKey && selected.value?.id === imageId) qualityResult.value = result
|
||||
return null
|
||||
}
|
||||
if (kind === 'validate') {
|
||||
const result = await subjectImagesApi.validate(formId, imageId)
|
||||
if (result.imageId !== imageId || result.subjectFormId !== formId || result.subjectId !== subjectId)
|
||||
throw new Error('审核结果与当前图片不匹配,请刷新后核对。')
|
||||
if (key.value === requestKey && selected.value?.id === imageId) validation.value = result
|
||||
return result
|
||||
}
|
||||
const result = await subjectImagesApi.setPrimary(formId, imageId)
|
||||
if (
|
||||
!result ||
|
||||
result.id !== imageId ||
|
||||
result.subjectFormId !== formId ||
|
||||
!result.isPrimary ||
|
||||
result.status !== 'completed'
|
||||
)
|
||||
throw new Error('主图切换结果尚未确认,请刷新后核对。')
|
||||
return null
|
||||
},
|
||||
result =>
|
||||
result
|
||||
? {
|
||||
type: imageValidationPassed(result) ? 'success' : 'warning',
|
||||
content: imageValidationPassed(result)
|
||||
? '本次图片审核通过,尚未切换主图。'
|
||||
: '本次图片审核未通过或待复核,原主图保留。'
|
||||
}
|
||||
: kind === 'quality'
|
||||
? { type: 'info', content: '质量处理已返回,请核对逐次审核和主图变化。' }
|
||||
: { type: 'success', content: '主参考图已更新。' }
|
||||
)
|
||||
if (key.value === requestKey) {
|
||||
confirming.value = null
|
||||
if (!ok) actionError.value = errorMessage(getOperation(projectId).cause)
|
||||
await query.refresh()
|
||||
if (ok) emit('changed')
|
||||
}
|
||||
pending.value = null
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AppDialog
|
||||
<AppDrawer
|
||||
v-model:open="open"
|
||||
:title="`${form?.subject.name || ''} · ${form?.name || '形态图片'}`"
|
||||
description="主参考图会供后续分镜使用。切换主图不会重新生成已有视频提示词。"
|
||||
wide
|
||||
:busy="!!pending"
|
||||
>
|
||||
<div class="mt-5 flex items-center justify-between">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<span class="text-xs text-muted">{{ images.length }} 条图片记录</span
|
||||
><NButton :disabled="query.loading.value" @click="query.refresh" text size="small"
|
||||
><NButton :disabled="query.loading.value || !!pending" @click="query.refresh" text size="small"
|
||||
><RefreshCw :size="13" :class="{ 'animate-spin': query.loading.value }" />刷新图片
|
||||
</NButton>
|
||||
</div>
|
||||
@@ -131,6 +253,7 @@ async function choosePrimary() {
|
||||
:key="image.id"
|
||||
:aria-label="`查看图片 ${image.id}`"
|
||||
:aria-pressed="image.id === selected.id"
|
||||
:disabled="!!pending"
|
||||
@click="selectedId = image.id"
|
||||
class="image-history-item"
|
||||
:class="{ selected: image.id === selected.id }"
|
||||
@@ -155,8 +278,24 @@ async function choosePrimary() {
|
||||
>
|
||||
</NScrollbar>
|
||||
<div class="mt-4 flex flex-wrap items-center justify-between gap-3">
|
||||
<div class="flex items-center gap-2">
|
||||
<StatusBadge :status="selected.status" />
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<NTag v-if="selected.status === 'completed'" :bordered="false" size="small">图片已生成</NTag>
|
||||
<StatusBadge v-else :status="selected.status" />
|
||||
<NTag
|
||||
v-if="selected.status === 'completed'"
|
||||
:bordered="false"
|
||||
size="small"
|
||||
:type="selected.qualityPassed === false ? 'error' : 'default'"
|
||||
>{{
|
||||
selected.qualityPassed === true
|
||||
? '最近审核通过'
|
||||
: selected.qualityPassed === false
|
||||
? '质量未通过'
|
||||
: isIdentityAnchorReuse(selected)
|
||||
? '未单独审核形态'
|
||||
: '尚未审核'
|
||||
}}</NTag
|
||||
>
|
||||
<!-- 以下是形态图片的真实来源模块 -->
|
||||
<NTag v-if="isIdentityAnchorReuse(selected)" size="small" :bordered="false">复用身份母版</NTag>
|
||||
<NTag v-if="selected.isPrimary" size="small" :bordered="false">当前主参考图</NTag
|
||||
@@ -179,31 +318,146 @@ async function choosePrimary() {
|
||||
class="mt-3 whitespace-pre-wrap"
|
||||
>{{ userFacingText(selected.error) }}</ContextNotice
|
||||
>
|
||||
<!-- 以下是明确费用的候选审核和主图操作模块 -->
|
||||
<div class="mt-4 flex flex-wrap items-center gap-3">
|
||||
<NButton v-if="!selected.isPrimary" :disabled="!canSetPrimary" @click="confirming = true">
|
||||
设为主参考图</NButton
|
||||
><span class="text-[11px] text-muted"
|
||||
<NButton
|
||||
class="workspace-action-button"
|
||||
:disabled="!canValidate"
|
||||
:loading="pending?.kind === 'validate' && pending.imageId === selected.id"
|
||||
@click="confirming = 'validate'"
|
||||
><template #icon><ShieldCheck :size="16" /></template>审核此图片</NButton
|
||||
>
|
||||
<NButton
|
||||
v-if="!selected.isPrimary"
|
||||
class="workspace-action-button"
|
||||
:disabled="!canSetPrimary"
|
||||
:loading="pending?.kind === 'primary' && pending.imageId === selected.id"
|
||||
@click="confirming = 'primary'"
|
||||
><template #icon><Check :size="16" /></template>设为主参考图</NButton
|
||||
>
|
||||
<NButton
|
||||
class="workspace-action-button"
|
||||
:disabled="!canValidate"
|
||||
:loading="pending?.kind === 'quality'"
|
||||
@click="requestQuality"
|
||||
><template #icon><WandSparkles :size="16" /></template>审核与修复</NButton
|
||||
>
|
||||
<span class="text-[11px] text-muted"
|
||||
>{{ selected.provider }} · {{ selected.model }} · {{ formatDate(selected.createdAt) }}</span
|
||||
>
|
||||
</div>
|
||||
<ContextNotice v-if="actionError" type="error" :show-icon="false" class="mt-4">{{
|
||||
actionError
|
||||
}}</ContextNotice>
|
||||
<ContextNotice v-if="selected.qualityPassed === false" type="error" :show-icon="false" class="mt-4">
|
||||
<p>这张图片未通过最近一次质量审核,候选已保留。可明确重新审核或选择其它候选,原主图不会被替换。</p>
|
||||
<p v-for="(issue, index) in selected.qualityIssues" :key="index" class="mt-2">
|
||||
{{ userFacingText(issue.description) }}
|
||||
</p>
|
||||
</ContextNotice>
|
||||
<p v-else-if="selected.status === 'completed'" class="mt-3 text-xs leading-6 text-muted">
|
||||
复用母版与单独审核形态是不同记录。最近审核记录不保证当前来源仍有效;来源或母版变化后需明确重新审核,切换主图时会再次检查。
|
||||
</p>
|
||||
<ImageValidationPanel v-if="validation?.imageId === selected.id" class="mt-5" :result="validation" />
|
||||
<!-- 以下是按明确预算完成的质量处理回执,失败不覆盖原主图 -->
|
||||
<ContextNotice
|
||||
v-if="qualityResult"
|
||||
:type="qualityResult.passed ? 'success' : 'error'"
|
||||
:show-icon="false"
|
||||
class="mt-4"
|
||||
>
|
||||
<p>
|
||||
{{ qualityResult.passed ? '最终候选审核通过' : '最终候选未通过审核,候选已保留' }};{{
|
||||
qualityResult.primaryChanged ? '主图已更新' : '主图未切换'
|
||||
}}。
|
||||
</p>
|
||||
<p class="mt-1">
|
||||
实际修复 {{ qualityResult.repairAttempts }} 次 / 最多 {{ qualityResult.maxRepairAttempts }} 次。
|
||||
</p>
|
||||
<NButton
|
||||
v-if="
|
||||
qualityResult.finalImageId !== selected.id &&
|
||||
images.some(image => image.id === qualityResult?.finalImageId)
|
||||
"
|
||||
class="workspace-action-button mt-3"
|
||||
@click="selectedId = qualityResult.finalImageId"
|
||||
><template #icon><Eye :size="16" /></template>查看最终候选</NButton
|
||||
>
|
||||
<NCollapse class="mt-3"
|
||||
><NCollapseItem name="attempts" title="查看逐次审核">
|
||||
<div
|
||||
v-for="attempt in qualityResult.attempts"
|
||||
:key="attempt.attempt"
|
||||
class="mt-3 text-xs leading-6"
|
||||
>
|
||||
<strong
|
||||
>{{ attempt.attempt === 0 ? '初始候选' : `修复 ${attempt.attempt}` }} ·
|
||||
{{ attempt.passed ? '通过' : '未通过' }}</strong
|
||||
>
|
||||
<p v-for="(issue, index) in attempt.issues" :key="index">
|
||||
{{ userFacingText(issue.description) }}
|
||||
</p>
|
||||
</div>
|
||||
</NCollapseItem></NCollapse
|
||||
>
|
||||
</ContextNotice>
|
||||
<!-- 以下是失效复用历史的说明模块 -->
|
||||
<p v-if="reusedImageUnavailable" class="mt-3 text-xs text-muted">
|
||||
此图片复用的身份母版已变更,或当前形态不再满足复用条件,仅保留作历史查看。
|
||||
</p>
|
||||
<ContextNotice v-if="confirming" type="info" :show-icon="false" class="mt-3"
|
||||
><p class="text-xs">确认将这张图用于此形态后续的分镜参考?旧主图仍会保留,此操作不调用模型。</p>
|
||||
<div class="mt-3 flex gap-3">
|
||||
<NButton :disabled="!canSetPrimary" @click="choosePrimary" type="primary"> 确认切换主图</NButton
|
||||
><NButton @click="confirming = false" text size="small">取消</NButton>
|
||||
</div></ContextNotice
|
||||
>
|
||||
<p class="mt-3 break-all font-mono text-[10px] text-muted">图片编号 · {{ selected.id }}</p>
|
||||
<p v-if="form && currentIdentityAnchorId(form)" class="mt-2 break-all text-[11px] text-muted">
|
||||
当前已锁定身份母版 ID:{{ currentIdentityAnchorId(form) }}
|
||||
</p>
|
||||
<ContextNotice v-if="confirming" type="info" :show-icon="false" class="mt-4">
|
||||
{{
|
||||
confirming === 'quality'
|
||||
? '将审核当前候选,通过后设为主图;未通过时按下方预算最多追加生图。可能产生文字准备、视觉审核和图片生成费用,使用该候选供应方及当前项目配置。失败保留旧主图和所有候选。'
|
||||
: confirming === 'validate'
|
||||
? '将调用视觉模型并产生审核费用,只保存质量证据,不切换主图。'
|
||||
: '将检查当前来源与质量证据;缺少可复用审核时可能调用视觉模型并产生费用。通过后才切换主图,失败保留原主图。'
|
||||
}}
|
||||
</ContextNotice>
|
||||
<div v-if="confirming === 'quality'" class="mt-4 space-y-2">
|
||||
<label for="quality-repair-budget" class="block text-xs"
|
||||
>最多额外生成次数(0 表示只审核,不追加生图)</label
|
||||
>
|
||||
<NInputNumber
|
||||
:input-props="{ id: 'quality-repair-budget' }"
|
||||
v-model:value="maxRepairAttempts"
|
||||
:min="0"
|
||||
:max="3"
|
||||
:precision="0"
|
||||
:disabled="!!pending"
|
||||
/>
|
||||
</div>
|
||||
<!-- 以下是默认收起的图片来源标识,日常操作不展示内部编号 -->
|
||||
<RawDataDetails
|
||||
:value="{
|
||||
imageId: selected.id,
|
||||
identityAnchorImageId: selected.identityAnchorImageId,
|
||||
currentIdentityAnchorImageId: form ? currentIdentityAnchorId(form) : undefined
|
||||
}"
|
||||
title="图片来源详情"
|
||||
/>
|
||||
</div>
|
||||
<p v-else class="py-10 text-center text-sm text-muted">
|
||||
{{ query.loading.value ? '正在读取图片记录…' : '此形态尚无图片记录,可以先生成一张。' }}
|
||||
</p>
|
||||
</AppDialog>
|
||||
<template #footer>
|
||||
<NButton :disabled="!!pending" @click="confirming ? (confirming = null) : (open = false)">{{
|
||||
confirming ? '取消' : '关闭'
|
||||
}}</NButton>
|
||||
<NButton
|
||||
v-if="confirming"
|
||||
type="primary"
|
||||
:disabled="!canConfirm"
|
||||
:loading="!!pending"
|
||||
@click="confirmAction"
|
||||
>{{
|
||||
confirming === 'quality'
|
||||
? '确认费用并执行'
|
||||
: confirming === 'validate'
|
||||
? '确认费用并审核'
|
||||
: '确认费用并设为主图'
|
||||
}}</NButton
|
||||
>
|
||||
</template>
|
||||
</AppDrawer>
|
||||
</template>
|
||||
@@ -0,0 +1,92 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { NButton, NCollapse, NCollapseItem, NTag } from 'naive-ui'
|
||||
import { Eye } from '@lucide/vue'
|
||||
import ContextNotice from '../../../components/ui/ContextNotice.vue'
|
||||
import RawDataDetails from '../../../components/ui/RawDataDetails.vue'
|
||||
import WorkspaceSectionHeading from '../../../components/ui/WorkspaceSectionHeading.vue'
|
||||
import type { ImageGenerationPreview } from '../generation-preview'
|
||||
|
||||
/** 三个图片入口共用的最终输入与参考职责展示。 */
|
||||
const props = defineProps<{
|
||||
/** 当前有效预览。 */
|
||||
preview: ImageGenerationPreview | null
|
||||
/** 预览读取中。 */
|
||||
loading: boolean
|
||||
/** 当前不能读取预览。 */
|
||||
disabled?: boolean
|
||||
/** 读取或提交错误。 */
|
||||
error: string
|
||||
/** 来源变化后的重新确认说明。 */
|
||||
staleNotice: string
|
||||
}>()
|
||||
/** 预览由当前表单按真实参数读取。 */
|
||||
const emit = defineEmits<{ load: [] }>()
|
||||
/** 参考职责统一中文展示,不展示内部图片编号。 */
|
||||
const roles: Record<string, string> = {
|
||||
'identity-anchor': '主体外观母版',
|
||||
'layout-master': '空间布局母版',
|
||||
'style-character': '人物风格',
|
||||
'style-scene': '场景风格',
|
||||
'style-prop': '道具风格',
|
||||
'style-overall': '整体风格',
|
||||
'form-primary': '形态主图',
|
||||
'structure-reference': '结构参考'
|
||||
}
|
||||
/** 形态按真实顺序展示;身份预览从同源参考计划取得职责。 */
|
||||
const references = computed(() => {
|
||||
if (props.preview?.references)
|
||||
return props.preview.references.map(item => ({
|
||||
order: item.imageNumber,
|
||||
label: roles[item.role] ?? '图片参考'
|
||||
}))
|
||||
const selected = props.preview?.referencePlan?.selected
|
||||
return Array.isArray(selected)
|
||||
? selected.map((item: { role?: string }, index) => ({
|
||||
order: index + 1,
|
||||
label: roles[item.role ?? ''] ?? '图片参考'
|
||||
}))
|
||||
: []
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 以下是免费实际输入预览模块,参数调整后必须重新读取 -->
|
||||
<section class="min-w-0 space-y-4" aria-label="本次生成预览">
|
||||
<WorkspaceSectionHeading
|
||||
title="本次生成预览"
|
||||
description="只检查已有描述、规格和参考图,不生成图片,也不自动补齐资料。"
|
||||
/>
|
||||
<NButton
|
||||
class="workspace-action-button"
|
||||
:loading="loading"
|
||||
:disabled="disabled || loading"
|
||||
@click="emit('load')"
|
||||
>
|
||||
<template #icon><Eye :size="16" /></template>预览实际生成输入
|
||||
</NButton>
|
||||
<ContextNotice v-if="staleNotice" type="warning" :show-icon="false">{{ staleNotice }}</ContextNotice>
|
||||
<ContextNotice v-if="error" type="error" :show-icon="false">{{ error }}</ContextNotice>
|
||||
<div v-if="preview" class="min-w-0 space-y-3 text-xs leading-6">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<strong>{{ preview.provider }} / {{ preview.model }}</strong>
|
||||
<NTag :bordered="false" size="small"
|
||||
>{{ preview.actualProviderReferenceCount ?? preview.referenceImages.length }} 张参考图</NTag
|
||||
>
|
||||
</div>
|
||||
<ul v-if="references.length" class="flex flex-wrap gap-x-5 gap-y-1 text-muted">
|
||||
<li v-for="item in references" :key="item.order">图 {{ item.order }} · {{ item.label }}</li>
|
||||
</ul>
|
||||
<p v-else-if="!preview.referenceImages.length" class="text-muted">本次没有图片参考。</p>
|
||||
<NCollapse :default-expanded-names="['prompt']">
|
||||
<NCollapseItem name="prompt" title="本次实际使用的画面描述">
|
||||
<p class="whitespace-pre-wrap wrap-anywhere">{{ preview.providerPrompt }}</p>
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
<RawDataDetails
|
||||
:value="{ generationConfig: preview.generationConfig, referencePlan: preview.referencePlan }"
|
||||
title="生成参数与参考图详情"
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -0,0 +1,147 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { NButton } from 'naive-ui'
|
||||
import { RefreshCw } from '@lucide/vue'
|
||||
import { AppDrawer } from '../../../components/ui'
|
||||
import ContextNotice from '../../../components/ui/ContextNotice.vue'
|
||||
import { useQuery } from '../../../composables/useQuery'
|
||||
import { productionApi } from '../../production/api'
|
||||
import ImagePreparationPlan from '../../production/components/ImagePreparationPlan.vue'
|
||||
import { userFacingText } from '../../../lib/user-facing-text'
|
||||
import { getOperation, runOperation } from '../../workflows/operations'
|
||||
import { subjectImagesApi } from '../api'
|
||||
|
||||
/** 在图片阶段核对准备依赖,无需先进入镜头生产。 */
|
||||
const props = defineProps<{ /** 正式项目编号。 */ projectId: string }>()
|
||||
/** 全屏只读检查开关。 */
|
||||
const open = defineModel<boolean>('open', { default: false })
|
||||
/** 关闭或切项目时取消旧请求。 */
|
||||
const key = computed(() => (open.value ? props.projectId : ''))
|
||||
/** 用户选择并待确认费用的文字准备项。 */
|
||||
const selected = ref<{ formId: string; kind: 'prompt' | 'structure' } | null>(null)
|
||||
/** 仅当前准备请求阻止关闭。 */
|
||||
const pending = ref(false)
|
||||
/** 项目级活动任务阻止并行写入。 */
|
||||
const operation = computed(() => getOperation(props.projectId))
|
||||
/** 关闭或切项目后清除待确认项。 */
|
||||
watch(key, () => {
|
||||
selected.value = null
|
||||
})
|
||||
/** 仅预检主体图片阶段,不调用任何生成模型。 */
|
||||
const query = useQuery(key, async (id, signal) => {
|
||||
if (!id) return null
|
||||
const result = await productionApi.plan(id, signal, { stage: 'subjectImages' })
|
||||
if (result.projectId !== id) throw new Error('图片准备检查与当前项目不匹配,请刷新重试。')
|
||||
return result
|
||||
})
|
||||
/** 只有完整计划才展示统计,配置阻断不冒充空计划。 */
|
||||
const plan = computed(() => (query.data.value?.stage !== 'configuration_required' ? query.data.value : null))
|
||||
/** 费用确认展示真实主体和形态,避免多个准备项混淆。 */
|
||||
const selectedLabel = computed(() => {
|
||||
if (!selected.value || !plan.value) return ''
|
||||
const form = plan.value.details.subjectImages.find(item => item.subjectFormId === selected.value?.formId)
|
||||
return form ? `${form.subjectName} · ${form.formName}` : '所选形态'
|
||||
})
|
||||
/** 明确费用后只准备所选资料,不自动串联下一项或生图。 */
|
||||
async function prepare() {
|
||||
if (
|
||||
!selected.value ||
|
||||
!plan.value ||
|
||||
query.error.value ||
|
||||
query.loading.value ||
|
||||
operation.value.pending ||
|
||||
pending.value
|
||||
)
|
||||
return
|
||||
const target = selected.value
|
||||
const projectId = props.projectId
|
||||
const item =
|
||||
plan.value.propStructureSpecs?.items.find(row => row.subjectFormId === target.formId) ??
|
||||
plan.value.stableIdentityAnchors?.propStructureSpecs?.items.find(row => row.subjectFormId === target.formId)
|
||||
if (!item || item.status !== 'upstream' || (item.requiresFormPrompt ? 'prompt' : 'structure') !== target.kind)
|
||||
return
|
||||
pending.value = true
|
||||
try {
|
||||
const ok = await runOperation(
|
||||
projectId,
|
||||
target.kind === 'prompt' ? '准备形态画面描述' : '准备道具结构规格',
|
||||
async () => {
|
||||
if (target.kind === 'prompt') await subjectImagesApi.generatePrompt(target.formId, false)
|
||||
else await subjectImagesApi.prepareStructure(target.formId)
|
||||
},
|
||||
{ type: 'info', content: '资料准备已返回,请以更新后的检查状态为准。' }
|
||||
)
|
||||
if (props.projectId === projectId && open.value) {
|
||||
if (ok) selected.value = null
|
||||
await query.refresh()
|
||||
}
|
||||
} finally {
|
||||
pending.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 以下是只读图片准备检查抽屉,关闭不受加载限制 -->
|
||||
<AppDrawer
|
||||
v-model:open="open"
|
||||
title="图片准备检查"
|
||||
description="检查免费。需要补充资料时,可逐项确认文字模型费用后准备,不会自动生图。"
|
||||
:busy="pending"
|
||||
>
|
||||
<div class="space-y-6">
|
||||
<ContextNotice v-if="query.error.value" type="error" :show-icon="false">{{
|
||||
query.error.value
|
||||
}}</ContextNotice>
|
||||
<p v-if="query.loading.value && !query.data.value" class="text-sm text-muted">正在检查当前准备情况…</p>
|
||||
<template v-else-if="plan">
|
||||
<p class="text-sm leading-7 text-muted">
|
||||
主体参考图共 {{ plan.subjectImages.total }} 项,已有可用结果
|
||||
{{ plan.subjectImages.skipped }} 项,需人工处理
|
||||
{{ plan.subjectImages.manualBlocked }} 项。准备计划不代表图片已经通过审核。
|
||||
</p>
|
||||
<div class="grid items-start gap-6 lg:grid-cols-2">
|
||||
<ImagePreparationPlan
|
||||
:plan="plan"
|
||||
allow-preparation
|
||||
:disabled="operation.pending || pending || query.loading.value || !!query.error.value"
|
||||
@navigate="open = false"
|
||||
@prepare="(formId, kind) => (selected = { formId, kind })"
|
||||
/>
|
||||
</div>
|
||||
<p v-if="!plan.propStructureSpecs && !plan.stableIdentityAnchors" class="text-sm text-muted">
|
||||
当前服务尚未提供规格与母版依赖明细,请核对服务版本后刷新。
|
||||
</p>
|
||||
</template>
|
||||
<ContextNotice v-else-if="query.data.value" type="warning" :show-icon="false">{{
|
||||
userFacingText(query.data.value.configuration?.reason) || '项目生成配置尚未就绪,请先完善项目配置。'
|
||||
}}</ContextNotice>
|
||||
<ContextNotice v-if="selected" type="info" :show-icon="false"
|
||||
>本次为「{{ selectedLabel }}」{{
|
||||
selected.kind === 'prompt' ? '准备该形态的画面描述' : '生成或更新该道具的结构规格'
|
||||
}},可能调用文字模型并产生费用。不会生成图片,也不会自动继续其它准备项。</ContextNotice
|
||||
>
|
||||
</div>
|
||||
<template #footer>
|
||||
<NButton :disabled="pending" @click="selected ? (selected = null) : (open = false)">{{
|
||||
selected ? '取消' : '关闭'
|
||||
}}</NButton>
|
||||
<NButton
|
||||
v-if="selected"
|
||||
type="primary"
|
||||
:loading="pending"
|
||||
:disabled="operation.pending || query.loading.value || !!query.error.value"
|
||||
@click="prepare"
|
||||
>确认费用并准备</NButton
|
||||
>
|
||||
<NButton
|
||||
v-else
|
||||
class="workspace-action-button"
|
||||
:disabled="pending"
|
||||
:loading="query.loading.value"
|
||||
@click="query.refresh"
|
||||
><template #icon><RefreshCw :size="16" /></template>刷新检查</NButton
|
||||
>
|
||||
</template>
|
||||
</AppDrawer>
|
||||
</template>
|
||||
@@ -0,0 +1,86 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { NCollapse, NCollapseItem, NTag } from 'naive-ui'
|
||||
import ContextNotice from '../../../components/ui/ContextNotice.vue'
|
||||
import { userFacingText } from '../../../lib/user-facing-text'
|
||||
import { imageValidationPassed, sourceRequirementRows, type ImageValidationResult } from '../validation'
|
||||
|
||||
/** 展示指定图片本次审核与原始定义对照,不推断主图或母版已采纳。 */
|
||||
const props = defineProps<{
|
||||
/** 明确绑定当前图片的正式审核结果。 */
|
||||
result: ImageValidationResult
|
||||
}>()
|
||||
/** 只有证据完整才使用成功状态。 */
|
||||
const passed = computed(() => imageValidationPassed(props.result))
|
||||
/** 原文与观测按标识关联,内部标识不出现在标题中。 */
|
||||
const requirements = computed(() => sourceRequirementRows(props.result))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 以下是当前图片的审核摘要模块,审核不自动切换主图或母版 -->
|
||||
<section class="min-w-0 space-y-4" aria-label="图片质量审核结果">
|
||||
<ContextNotice :type="passed ? 'success' : 'error'" :show-icon="false">
|
||||
<p class="font-medium">{{ passed ? '本次质量审核通过' : '本次质量审核未通过或仍待复核' }}</p>
|
||||
<p class="mt-1 whitespace-pre-wrap wrap-anywhere">{{ userFacingText(result.summary) }}</p>
|
||||
</ContextNotice>
|
||||
<p class="text-xs leading-6 text-muted">
|
||||
审核只保存质量证据,不会自动采纳图片。资料或图片变化后需重新核对;最终可用性以当前制作准备检查为准。
|
||||
</p>
|
||||
<ul v-if="result.issues.length" class="space-y-2 text-xs leading-6">
|
||||
<li v-for="(issue, index) in result.issues" :key="index" class="whitespace-pre-wrap wrap-anywhere">
|
||||
<NTag
|
||||
:type="issue.severity === 'error' ? 'error' : 'warning'"
|
||||
:bordered="false"
|
||||
size="small"
|
||||
class="mr-2"
|
||||
>{{ issue.severity === 'error' ? '需处理' : '需核对' }}</NTag
|
||||
>{{ userFacingText(issue.description) }}
|
||||
</li>
|
||||
</ul>
|
||||
<!-- 以下是原始外观定义及明确数量的逐条审核模块 -->
|
||||
<NCollapse v-if="requirements.length" :default-expanded-names="['source']">
|
||||
<NCollapseItem name="source" title="原始外观定义核对">
|
||||
<div class="space-y-5 text-xs leading-6">
|
||||
<article v-for="(item, index) in requirements" :key="item.id" class="min-w-0 space-y-2">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<strong>{{ item.subjectName }} · 定义 {{ index + 1 }}</strong
|
||||
><NTag
|
||||
:type="item.passed ? 'success' : item.label === '未通过' ? 'error' : 'warning'"
|
||||
:bordered="false"
|
||||
size="small"
|
||||
>{{ item.label }}</NTag
|
||||
>
|
||||
</div>
|
||||
<p class="whitespace-pre-wrap wrap-anywhere">原文:{{ item.sourceQuote }}</p>
|
||||
<p class="whitespace-pre-wrap wrap-anywhere text-muted">
|
||||
观察:{{ userFacingText(item.evidence) }}
|
||||
</p>
|
||||
<ul v-if="item.quantities.length" class="space-y-1">
|
||||
<li
|
||||
v-for="quantity in item.quantities"
|
||||
:key="quantity.id"
|
||||
class="flex flex-wrap gap-x-4 gap-y-1"
|
||||
>
|
||||
<span>{{ quantity.sourcePhrase }}</span
|
||||
><span>要求 {{ quantity.expectedCount }}</span
|
||||
><span :class="quantity.matches ? 'text-muted' : 'text-danger'"
|
||||
>实际观察 {{ quantity.observed ?? '无法确认' }}</span
|
||||
>
|
||||
</li>
|
||||
</ul>
|
||||
</article>
|
||||
</div>
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
<p v-else-if="result.sourceRequirementsPassed !== true" class="text-xs text-muted">
|
||||
原始定义审核证据尚未确认,请重新审核后核对。
|
||||
</p>
|
||||
<p class="text-xs text-muted">
|
||||
{{
|
||||
result.identityAnchorCompared
|
||||
? '本次审核已提供当前主体母版作为对照。'
|
||||
: '本次审核未提供母版像素对照,不能据此证明与母版一致。'
|
||||
}}
|
||||
</p>
|
||||
</section>
|
||||
</template>
|
||||
@@ -0,0 +1,176 @@
|
||||
import { computed, onBeforeUnmount, ref, shallowRef, watch, type Ref } from 'vue'
|
||||
import { ApiError, errorMessage } from '../../lib/http'
|
||||
|
||||
/** 三类图片入口共用的实际生成预览。 */
|
||||
export interface ImageGenerationPreview {
|
||||
/** 实际供应方。 */
|
||||
provider: string
|
||||
/** 实际模型。 */
|
||||
model: string
|
||||
/** 最终画面描述。 */
|
||||
providerPrompt: string
|
||||
/** 本次预览绑定的来源与配置版本。 */
|
||||
previewFingerprint: string
|
||||
/** 实际传入模型的参考图。 */
|
||||
referenceImages: string[]
|
||||
/** 已解析的生成配置。 */
|
||||
generationConfig: Record<string, unknown>
|
||||
/** 参考图顺序和职责等诊断信息。 */
|
||||
referencePlan?: Record<string, unknown>
|
||||
/** 形态接口给出的有序参考图明细。 */
|
||||
references?: Array<{
|
||||
/** 传入模型的顺序。 */
|
||||
imageNumber: number
|
||||
/** 参考图职责。 */
|
||||
role: string
|
||||
/** 正式图片编号。 */
|
||||
imageId: string
|
||||
/** 可展示的图片地址。 */
|
||||
imageUrl: string
|
||||
}>
|
||||
/** 含布局母版的真实参考图数量。 */
|
||||
actualProviderReferenceCount?: number
|
||||
}
|
||||
|
||||
/** 提交结果只说明任务是否创建,不代表图片质量通过。 */
|
||||
export interface ImageGenerationSubmission {
|
||||
/** 已确认创建后台任务。 */
|
||||
accepted: boolean
|
||||
/** 原始错误用于识别预览过期,不能仅按 409 猜测原因。 */
|
||||
cause?: unknown
|
||||
}
|
||||
|
||||
/** 预览、确认和提交所需的当前界面上下文。 */
|
||||
interface PreviewOptions<Input extends object, Preview extends ImageGenerationPreview> {
|
||||
/** 当前表单可见状态。 */
|
||||
open: Ref<boolean>
|
||||
/** 主体、形态及已有来源的稳定标识。 */
|
||||
target: () => string
|
||||
/** 当前完整生成参数。 */
|
||||
input: () => Input
|
||||
/** 当前是否允许提交。 */
|
||||
disabled: () => boolean
|
||||
/** 只读预览,不创建或补齐任何资产。 */
|
||||
load: (input: Input, signal: AbortSignal) => Promise<Preview>
|
||||
/** 用户明确确认后仅提交一次。 */
|
||||
generate: (input: Input & { expectedPreviewFingerprint: string }) => Promise<ImageGenerationSubmission>
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定预览与提交参数,处理过期响应、关闭及 409 重新确认。
|
||||
* @param options 当前表单、正式预览与生成操作
|
||||
* @returns 预览、确认、加载、错误和显式提交操作
|
||||
*/
|
||||
export function useImageGenerationPreview<Input extends object, Preview extends ImageGenerationPreview>(
|
||||
options: PreviewOptions<Input, Preview>
|
||||
) {
|
||||
/** 当前有效的实际输入。 */
|
||||
const preview = shallowRef<Preview | null>(null)
|
||||
/** 用户核对当前预览及费用后的确认。 */
|
||||
const acknowledged = ref(false)
|
||||
/** 只读查询状态,不阻止关闭。 */
|
||||
const loading = ref(false)
|
||||
/** 已提交的请求尚未返回时防重复及误关闭。 */
|
||||
const submitting = ref(false)
|
||||
/** 当前读取或提交错误。 */
|
||||
const error = ref('')
|
||||
/** 过期说明在新预览返回后仍保留,提醒再次确认。 */
|
||||
const staleNotice = ref('')
|
||||
/** 输入快照同时绑定界面目标和显隐周期。 */
|
||||
const key = computed(() => JSON.stringify([options.open.value, options.target(), options.input()]))
|
||||
/** 请求序号防止相同参数的旧响应回填。 */
|
||||
let revision = 0
|
||||
/** 预览请求取消句柄;生成提交不取消或重试。 */
|
||||
let controller: AbortController | undefined
|
||||
/** 当前界面的预览必须完整且费用已确认。 */
|
||||
const canSubmit = computed(
|
||||
() =>
|
||||
options.open.value &&
|
||||
!options.disabled() &&
|
||||
!submitting.value &&
|
||||
!loading.value &&
|
||||
!!preview.value &&
|
||||
acknowledged.value
|
||||
)
|
||||
|
||||
/** 参数或目标变化立即废弃预览和确认。 */
|
||||
function invalidate() {
|
||||
revision++
|
||||
controller?.abort()
|
||||
preview.value = null
|
||||
acknowledged.value = false
|
||||
loading.value = false
|
||||
error.value = ''
|
||||
staleNotice.value = ''
|
||||
}
|
||||
watch(key, invalidate, { flush: 'sync' })
|
||||
onBeforeUnmount(invalidate)
|
||||
|
||||
/** 只读取当前参数;失败保留原因,迟到响应不回填。 */
|
||||
async function loadPreview() {
|
||||
if (!options.open.value || submitting.value) return
|
||||
controller?.abort()
|
||||
const current = ++revision
|
||||
const abort = new AbortController()
|
||||
controller = abort
|
||||
preview.value = null
|
||||
acknowledged.value = false
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
const input = JSON.parse(JSON.stringify(options.input())) as Input
|
||||
try {
|
||||
const result = await options.load(input, abort.signal)
|
||||
if (current !== revision || abort.signal.aborted) return
|
||||
if (
|
||||
!result ||
|
||||
!/^[a-f0-9]{64}$/i.test(result.previewFingerprint) ||
|
||||
!result.providerPrompt?.trim() ||
|
||||
!result.provider ||
|
||||
!result.model ||
|
||||
!Array.isArray(result.referenceImages)
|
||||
)
|
||||
throw new Error('生成预览不完整,请刷新预览后再确认。')
|
||||
preview.value = result
|
||||
} catch (cause) {
|
||||
if (current === revision && !abort.signal.aborted) error.value = errorMessage(cause)
|
||||
} finally {
|
||||
if (current === revision) loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 明确提交一次;预览过期只重读预览,绝不自动重新生成。 */
|
||||
async function submit() {
|
||||
if (!canSubmit.value || !preview.value) return
|
||||
const current = revision
|
||||
const input = JSON.parse(JSON.stringify(options.input())) as Input
|
||||
const fingerprint = preview.value.previewFingerprint
|
||||
submitting.value = true
|
||||
error.value = ''
|
||||
let result: ImageGenerationSubmission
|
||||
try {
|
||||
result = await options.generate({ ...input, expectedPreviewFingerprint: fingerprint })
|
||||
} catch (cause) {
|
||||
result = { accepted: false, cause }
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
if (current !== revision) return
|
||||
if (result.accepted) {
|
||||
options.open.value = false
|
||||
return
|
||||
}
|
||||
acknowledged.value = false
|
||||
if (
|
||||
result.cause instanceof ApiError &&
|
||||
result.cause.status === 409 &&
|
||||
result.cause.code === 'IMAGE_PREVIEW_STALE'
|
||||
) {
|
||||
invalidate()
|
||||
staleNotice.value = '生成依据或配置已变化,本次未生成图片。请核对更新后的预览并重新确认。'
|
||||
await loadPreview()
|
||||
} else {
|
||||
error.value = result.cause ? errorMessage(result.cause) : '当前暂不能提交,请刷新项目状态后重试。'
|
||||
}
|
||||
}
|
||||
return { preview, acknowledged, loading, submitting, error, staleNotice, canSubmit, loadPreview, submit }
|
||||
}
|
||||
@@ -1,8 +1,15 @@
|
||||
import type { ImageGenerationPreview } from './generation-preview'
|
||||
import type { ImageQualityIssue } from './validation'
|
||||
|
||||
/** 后端图片记录的持久化状态,不以 HTTP 请求完成代替生成成功。 */
|
||||
export type SubjectImageStatus = 'pending' | 'generating' | 'completed' | 'failed'
|
||||
|
||||
/** 图库列表返回的图片元数据;正式图片 ID 与形态 ID 均来自数据库。 */
|
||||
export interface SubjectImage {
|
||||
/** 最近一次结构化质量结论;缺失或 null 不代表通过。 */
|
||||
qualityPassed?: boolean | null
|
||||
/** 最近一次质量问题;最新可用性仍以制作准备检查为准。 */
|
||||
qualityIssues?: ImageQualityIssue[]
|
||||
/** 图片来源;旧后端未提供时按独立生成处理。 */
|
||||
source?: 'generated' | 'identity-anchor'
|
||||
/** 生成或复用时记录的身份母版编号。 */
|
||||
@@ -50,9 +57,21 @@ export interface SubjectFormAsset {
|
||||
|
||||
/** 单形态生图配置;实际模型统一由后端 IMAGE 配置决定。 */
|
||||
export interface GenerateFormImageInput {
|
||||
/** 用户已核对的实际输入版本。 */
|
||||
expectedPreviewFingerprint?: string
|
||||
/** 本次可选图片宽度。 */
|
||||
width?: number
|
||||
/** 本次可选图片高度。 */
|
||||
height?: number
|
||||
/** 本次负面提示词。 */
|
||||
negativePrompt?: string
|
||||
/** 本次完整画面描述。 */
|
||||
prompt?: string
|
||||
/** 图片供应方。 */
|
||||
provider?: string
|
||||
/** 模型支持的动态参数。 */
|
||||
generationOptions?: Record<string, string | number | boolean>
|
||||
/** 生成并通过质量门禁后是否切换主图。 */
|
||||
setPrimary: boolean
|
||||
}
|
||||
|
||||
@@ -95,18 +114,9 @@ export interface GenerateFormPromptsInput {
|
||||
export type SubjectModule = 'character' | 'scene' | 'prop'
|
||||
|
||||
/** 形态生图前的无费用实际输入预览。 */
|
||||
export interface SubjectImageGenerationPreview {
|
||||
export interface SubjectImageGenerationPreview extends ImageGenerationPreview {
|
||||
/** 正式形态编号,用于核对响应目标。 */
|
||||
subjectFormId: string
|
||||
provider: string
|
||||
model: string
|
||||
generationConfig: Record<string, unknown>
|
||||
references: Array<{
|
||||
imageNumber: number
|
||||
role: string
|
||||
imageId: string
|
||||
imageUrl: string
|
||||
}>
|
||||
providerPrompt: string
|
||||
}
|
||||
|
||||
/** 长请求的回执按项目隔离,在会话内切换页面后仍可查看。 */
|
||||
@@ -115,3 +125,46 @@ export interface ImageSession {
|
||||
/** 提示词回执独立保存,避免覆盖最近一次生图回执。 */
|
||||
promptReceipt?: { title: string; result: ImageBatchResult } | null
|
||||
}
|
||||
|
||||
/** 明确选择候选及额外生图预算的质量处理请求。 */
|
||||
export interface FormImageQualityInput {
|
||||
/** 初始审核的已有候选。 */
|
||||
imageId: string
|
||||
/** 本轮图片供应方,修复继续使用该供应方。 */
|
||||
provider: string
|
||||
/** 最多额外生成次数,0 表示不追加生图。 */
|
||||
maxRepairAttempts: number
|
||||
}
|
||||
|
||||
/** 后端质量闭环回执,与单次视觉审核区分。 */
|
||||
export interface FormImageQualityResult {
|
||||
/** 所属形态。 */
|
||||
subjectFormId: string
|
||||
/** 初始候选编号。 */
|
||||
initialImageId: string
|
||||
/** 最终候选编号。 */
|
||||
finalImageId: string
|
||||
/** 原主图编号。 */
|
||||
originalPrimaryId?: string
|
||||
/** 最终审核通过。 */
|
||||
passed: boolean
|
||||
/** 是否发生修复生图。 */
|
||||
repaired: boolean
|
||||
/** 实际修复次数。 */
|
||||
repairAttempts: number
|
||||
/** 用户授权的最多修复次数。 */
|
||||
maxRepairAttempts: number
|
||||
/** 当前主图是否发生切换。 */
|
||||
primaryChanged: boolean
|
||||
/** 每次候选的真实审核记录。 */
|
||||
attempts: Array<{
|
||||
/** 从零起算的轮次。 */
|
||||
attempt: number
|
||||
/** 本轮候选编号。 */
|
||||
imageId: string
|
||||
/** 本轮审核通过。 */
|
||||
passed: boolean
|
||||
/** 本轮问题。 */
|
||||
issues: ImageQualityIssue[]
|
||||
}>
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { ImageGenerationSubmission } from './generation-preview'
|
||||
import { computed, ref } from 'vue'
|
||||
import { usePolling } from '../../composables/usePolling'
|
||||
import { ApiError } from '../../lib/http'
|
||||
@@ -143,21 +144,28 @@ export function useSubjectImages() {
|
||||
await query.refresh()
|
||||
}
|
||||
|
||||
/** 捕获正式 Form ID,生成后重新读取图片;刷新失败也不自动重发有费用的请求。 */
|
||||
async function generate(formId: string, input: GenerateFormImageInput) {
|
||||
if (blocked.value) return
|
||||
/**
|
||||
* 按已核对的预览创建单图任务,失败时将原始原因交回表单。
|
||||
* @param formId 正式形态编号
|
||||
* @param input 当前参数与预览版本
|
||||
* @returns 是否创建任务及原始失败原因
|
||||
*/
|
||||
async function generate(formId: string, input: GenerateFormImageInput): Promise<ImageGenerationSubmission> {
|
||||
if (blocked.value) return { accepted: false }
|
||||
const form = forms.value.find(item => item.id === formId)
|
||||
if (!form || hasRunningImages(form.images)) return
|
||||
if (!form || hasRunningImages(form.images)) return { accepted: false }
|
||||
const projectId = id.value
|
||||
const ok = await runOperation(projectId, `提交 ${form.subject.name} · ${form.name} 图片生成`, async () => {
|
||||
const image = await subjectImagesApi.generate(formId, input)
|
||||
if (!image || image.subjectFormId !== formId || !['pending', 'generating'].includes(image.status))
|
||||
throw new Error(image?.error || '图片生成任务未成功创建,请刷新后重试。')
|
||||
})
|
||||
if (ok) {
|
||||
const cause = getOperation(projectId).cause
|
||||
if (ok && id.value === projectId) {
|
||||
await query.refresh()
|
||||
operation.value.notice = `${form.subject.name} · ${form.name} 已提交生成,可稍后刷新图库查看结果。`
|
||||
}
|
||||
return { accepted: ok, cause }
|
||||
}
|
||||
|
||||
/** 批量始终面向整个项目,不受页面筛选影响;force 仅新增候选图,不替换已有主图。 */
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
/** 服务端保留的图片质量问题。 */
|
||||
export interface ImageQualityIssue {
|
||||
/** 原始问题分类,不用于中文标题。 */
|
||||
type: string
|
||||
/** 问题严重程度。 */
|
||||
severity: 'warning' | 'error'
|
||||
/** 业务原因。 */
|
||||
description: string
|
||||
}
|
||||
|
||||
/** 原始创作中能唯一绑定当前主体的外观定义。 */
|
||||
export interface SourceVisualRequirement {
|
||||
/** 原始定义关联标识,仅用于匹配。 */
|
||||
id: string
|
||||
/** 正式主体编号。 */
|
||||
subjectId: string
|
||||
/** 正式主体名称。 */
|
||||
subjectName: string
|
||||
/** 逐字保留的来源原文。 */
|
||||
sourceQuote: string
|
||||
/** 可以由原文直接确定的数量。 */
|
||||
quantities: Array<{
|
||||
/** 数量证据关联标识。 */
|
||||
id: string
|
||||
/** 原始数量短语。 */
|
||||
sourcePhrase: string
|
||||
/** 原文明确要求的数量。 */
|
||||
expectedCount: number
|
||||
}>
|
||||
}
|
||||
|
||||
/** 视觉审核对一条原始定义的真实观察。 */
|
||||
export interface SourceVisualRequirementResult {
|
||||
/** 所属原始定义。 */
|
||||
requirementId: string
|
||||
/** 单项审核状态。 */
|
||||
status: 'passed' | 'failed' | 'unobservable' | 'needs_review'
|
||||
/** 可观察证据或未能确认的原因。 */
|
||||
evidence: string
|
||||
/** 按像素观察到的数量,null 表示无法确认。 */
|
||||
quantities?: Array<{
|
||||
/** 所属数量证据。 */
|
||||
quantityId: string
|
||||
/** 真实观察数量。 */
|
||||
observedCount: number | null
|
||||
}>
|
||||
}
|
||||
|
||||
/** 身份与形态图片共用的正式视觉审核结果。 */
|
||||
export interface ImageValidationResult {
|
||||
/** 正式主体编号。 */
|
||||
subjectId: string
|
||||
/** 主体引用。 */
|
||||
subjectRef?: string
|
||||
/** 正式形态编号;身份审核不得据此推断母版采纳。 */
|
||||
subjectFormId?: string
|
||||
/** 本次被审核的图片。 */
|
||||
imageId: string
|
||||
/** 图片地址。 */
|
||||
imageUrl?: string
|
||||
/** 形态主图标记,不能当作身份母版标记。 */
|
||||
isPrimary?: boolean
|
||||
/** 服务端本次总审核结论。 */
|
||||
passed: boolean
|
||||
/** 外观是否一致。 */
|
||||
formConsistent?: boolean
|
||||
/** 物理结构是否有效。 */
|
||||
physicalStructureValid?: boolean
|
||||
/** 空间布局是否有效。 */
|
||||
spatialLayoutValid?: boolean
|
||||
/** 本次质量问题。 */
|
||||
issues: ImageQualityIssue[]
|
||||
/** 业务摘要。 */
|
||||
summary: string
|
||||
/** 实际向审核模型提供了当前母版像素,不代表审核通过。 */
|
||||
identityAnchorCompared?: boolean
|
||||
/** 本次对照的母版编号。 */
|
||||
identityAnchorImageId?: string | null
|
||||
/** 原始定义是否具备完整审核证据。 */
|
||||
sourceRequirementsPassed?: boolean
|
||||
/** 实际提交审核的原始定义。 */
|
||||
sourceVisualRequirements?: SourceVisualRequirement[]
|
||||
/** 逐项真实像素观察。 */
|
||||
sourceVisualRequirementResults?: SourceVisualRequirementResult[]
|
||||
/** 构图检查的必要审核状态。 */
|
||||
compositionReview?: {
|
||||
/** 仍须人工核对。 */ requiresManualReview?: boolean
|
||||
/** 其它服务端证据。 */ [key: string]: unknown
|
||||
} | null
|
||||
/** 原始构图规则证据。 */
|
||||
compositionRuleResults?: unknown[]
|
||||
}
|
||||
|
||||
/**
|
||||
* 按唯一证据逐项核对原始定义,缺失、重复或不可见均不显示通过。
|
||||
* @param result 后端本次审核结果
|
||||
* @returns 面向用户的原文、数量与观察状态
|
||||
*/
|
||||
export function sourceRequirementRows(result: ImageValidationResult) {
|
||||
return (result.sourceVisualRequirements ?? []).map(requirement => {
|
||||
const matches = (result.sourceVisualRequirementResults ?? []).filter(
|
||||
item => item.requirementId === requirement.id
|
||||
)
|
||||
const observation = matches.length === 1 ? matches[0] : undefined
|
||||
const quantities = requirement.quantities.map(quantity => {
|
||||
const matched = observation?.quantities?.filter(item => item.quantityId === quantity.id) ?? []
|
||||
const observed = matched.length === 1 ? (matched[0]?.observedCount ?? null) : null
|
||||
return { ...quantity, observed, matches: observed === quantity.expectedCount }
|
||||
})
|
||||
const passed =
|
||||
observation?.status === 'passed' && !!observation.evidence?.trim() && quantities.every(item => item.matches)
|
||||
const failed =
|
||||
observation?.status === 'failed' || quantities.some(item => item.observed !== null && !item.matches)
|
||||
return {
|
||||
...requirement,
|
||||
quantities,
|
||||
evidence:
|
||||
observation?.evidence || (matches.length > 1 ? '审核记录重复,需重新核对。' : '尚无完整审核证据。'),
|
||||
passed,
|
||||
label: failed ? '未通过' : passed ? '通过' : observation?.status === 'unobservable' ? '无法观察' : '待复核'
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示成功必须同时具备服务端通过结论和完整原始定义证据。
|
||||
* @param result 当前图片审核结果
|
||||
* @returns 是否可以展示本次审核通过
|
||||
*/
|
||||
export function imageValidationPassed(result: ImageValidationResult): boolean {
|
||||
return (
|
||||
result.passed === true &&
|
||||
result.sourceRequirementsPassed === true &&
|
||||
Array.isArray(result.sourceVisualRequirements) &&
|
||||
!result.issues.some(issue => issue.severity === 'error') &&
|
||||
result.formConsistent !== false &&
|
||||
result.physicalStructureValid !== false &&
|
||||
result.spatialLayoutValid !== false &&
|
||||
!result.compositionReview?.requiresManualReview &&
|
||||
sourceRequirementRows(result).every(item => item.passed)
|
||||
)
|
||||
}
|
||||
@@ -164,7 +164,7 @@ function removeImage(image: VisualStyleImage) {
|
||||
<h3 class="font-medium">风格生成规则</h3>
|
||||
<p class="mt-3 text-xs leading-6 text-muted">
|
||||
AI
|
||||
生成时,若项目和世界观没有明确其它人物背景,人物风格默认采用中国人物选角基线;人工填写的人物背景和角色事实优先。修改风格只影响之后的生成,旧资产不会自动更新。
|
||||
生成时遵循剧本与角色已明确的外观和人物背景;未明确时保持地域与族裔中性,不从姓名或视觉媒介推断。修改风格只影响之后的生成,旧资产不会自动更新。
|
||||
</p>
|
||||
</section>
|
||||
<!-- 以下是风格编辑与始终展开的分类补充模块 -->
|
||||
|
||||
@@ -106,7 +106,7 @@ function save() {
|
||||
><NInput
|
||||
:input-props="{ 'aria-label': '人物风格与选角背景' }"
|
||||
:disabled="disabled"
|
||||
placeholder="人物质感、妆造与默认选角背景;留空时 AI 默认采用中国人物基线"
|
||||
placeholder="人物质感、妆造与已明确的选角背景;未明确时保持地域与族裔中性"
|
||||
class="min-h-32"
|
||||
v-model:value="form.characterPrompt"
|
||||
type="textarea"
|
||||
|
||||
@@ -34,6 +34,32 @@ const props = withDefaults(
|
||||
const emit = defineEmits<{ refresh: []; dismiss: [] }>()
|
||||
const percentage = computed(() => executionPercentage(props.execution?.current ?? 0, props.execution?.total ?? 0))
|
||||
const result = computed(() => props.execution?.result ?? {})
|
||||
/** 导演设计和画面状态的逐集结果独立于任务执行终态。 */
|
||||
const derivedTask = computed(() =>
|
||||
['storyboard-direction', 'storyboard-visual-state'].includes(props.execution?.workflowName ?? '')
|
||||
)
|
||||
/** 部分失败和人工核对标记不能显示为全部完成。 */
|
||||
const derivedNeedsReview = computed(
|
||||
() =>
|
||||
derivedTask.value &&
|
||||
(result.value.manualReviewRequired === true ||
|
||||
Number(result.value.failedEpisodes) > 0 ||
|
||||
Number(result.value.staleCount) > 0)
|
||||
)
|
||||
/** 逐集记录仅保留实际返回的集号、状态与业务原因。 */
|
||||
const derivedEpisodes = computed(() => {
|
||||
if (!derivedTask.value || !Array.isArray(result.value.episodes)) return []
|
||||
return result.value.episodes.flatMap((item: unknown) => {
|
||||
if (!item || typeof item !== 'object' || !('episodeNo' in item) || typeof item.episodeNo !== 'number') return []
|
||||
return [
|
||||
{
|
||||
episodeNo: item.episodeNo,
|
||||
status: 'status' in item && typeof item.status === 'string' ? item.status : '',
|
||||
error: 'error' in item && typeof item.error === 'string' ? item.error : ''
|
||||
}
|
||||
]
|
||||
})
|
||||
})
|
||||
/** 只改变旧记录的展示语义,不改写原始任务或审核结果。 */
|
||||
const historical = computed(
|
||||
() =>
|
||||
@@ -95,6 +121,10 @@ const statusLabel = computed(() => {
|
||||
const labels = { pending: '等待开始', running: '执行中', completed: '已完成', failed: '失败' }
|
||||
if (!props.execution) return ''
|
||||
if (historical.value) return '历史执行记录'
|
||||
if (derivedTask.value && ['completed', 'failed'].includes(props.execution.status))
|
||||
return props.execution.status === 'failed' || derivedNeedsReview.value
|
||||
? '执行结束 · 需核对部分结果'
|
||||
: '执行结束 · 请核对覆盖情况'
|
||||
if (scriptCreation.value && props.execution.status === 'completed') {
|
||||
if (result.value.projectStatus === 'need_review') return '执行结束 · 待修订'
|
||||
if (result.value.projectStatus !== 'completed') return '执行结束 · 结果待确认'
|
||||
@@ -122,6 +152,8 @@ const staleMotionPlanCount = computed(() => {
|
||||
/** 业务未通过或结果未知时,不把任务执行结束展示为全成功。 */
|
||||
const statusType = computed(() => {
|
||||
if (historical.value) return 'default'
|
||||
if (derivedTask.value)
|
||||
return props.execution?.status === 'failed' ? 'error' : derivedNeedsReview.value ? 'warning' : 'default'
|
||||
if (scriptCreation.value && props.execution?.status === 'completed')
|
||||
return result.value.projectStatus === 'completed'
|
||||
? 'success'
|
||||
@@ -306,7 +338,13 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
v-if="execution.total > 0 && ((!breakdownTask && !diagnosisTask) || !finished)"
|
||||
type="line"
|
||||
:percentage="percentage"
|
||||
:color="scriptCreation && result.projectStatus !== 'completed' ? 'var(--app-muted)' : undefined"
|
||||
:color="
|
||||
execution.status === 'failed' ||
|
||||
derivedTask ||
|
||||
(scriptCreation && result.projectStatus !== 'completed')
|
||||
? 'var(--app-muted)'
|
||||
: undefined
|
||||
"
|
||||
:height="5"
|
||||
:show-indicator="false"
|
||||
class="mt-4"
|
||||
@@ -345,28 +383,32 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
<ContextNotice
|
||||
v-else-if="execution.status === 'completed' && showStatusHint && !historical"
|
||||
:type="
|
||||
scriptCreation
|
||||
? result.projectStatus === 'completed'
|
||||
? 'success'
|
||||
: result.projectStatus === 'need_review'
|
||||
? 'warning'
|
||||
: 'info'
|
||||
: diagnosisTask
|
||||
? 'info'
|
||||
: breakdownInvalid
|
||||
derivedTask
|
||||
? derivedNeedsReview
|
||||
? 'warning'
|
||||
: keyframeEdit
|
||||
? result.passed === true
|
||||
? 'success'
|
||||
: result.validationSkipped === true
|
||||
? 'info'
|
||||
: 'warning'
|
||||
: videoQuality && staleMotionPlanCount > 0
|
||||
: 'info'
|
||||
: scriptCreation
|
||||
? result.projectStatus === 'completed'
|
||||
? 'success'
|
||||
: result.projectStatus === 'need_review'
|
||||
? 'warning'
|
||||
: keyframeQuality &&
|
||||
(!keyframeCounts || keyframeCounts.repairFailed + keyframeCounts.failed > 0)
|
||||
: 'info'
|
||||
: diagnosisTask
|
||||
? 'info'
|
||||
: breakdownInvalid
|
||||
? 'warning'
|
||||
: keyframeEdit
|
||||
? result.passed === true
|
||||
? 'success'
|
||||
: result.validationSkipped === true
|
||||
? 'info'
|
||||
: 'warning'
|
||||
: videoQuality && staleMotionPlanCount > 0
|
||||
? 'warning'
|
||||
: 'success'
|
||||
: keyframeQuality &&
|
||||
(!keyframeCounts || keyframeCounts.repairFailed + keyframeCounts.failed > 0)
|
||||
? 'warning'
|
||||
: 'success'
|
||||
"
|
||||
:show-icon="embedded"
|
||||
:emphasized="embedded"
|
||||
@@ -391,7 +433,9 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
? result.projectStatus === 'need_review'
|
||||
? '剧本创作任务已结束,审核仍需处理,请查看当前审核结果。'
|
||||
: '剧本创作任务已结束,可查看最新剧本内容。'
|
||||
: '本轮任务已结束,可查看最新镜头资产状态。'
|
||||
: derivedTask
|
||||
? '本轮派生设计已结束,请分别核对成功、失败及过期记录。'
|
||||
: '本轮任务已结束,可查看最新镜头资产状态。'
|
||||
}}
|
||||
</p>
|
||||
<p v-if="videoQuality" class="mt-2 text-xs">
|
||||
@@ -426,7 +470,7 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
<template v-else>首帧检查结果尚不完整,请刷新任务详情后核对。</template>
|
||||
</p>
|
||||
<p v-else-if="diagnosisTask" class="mt-2 text-xs">具体冲突与证据情况以最新诊断列表为准。</p>
|
||||
<p v-else-if="!videoQuality && !scriptCreation && !breakdownTask" class="mt-2 text-xs">
|
||||
<p v-else-if="!videoQuality && !scriptCreation && !breakdownTask && !derivedTask" class="mt-2 text-xs">
|
||||
共 {{ result.total ?? execution.total }} · 生成 {{ result.generated ?? execution.current }} · 跳过
|
||||
{{ result.skipped ?? 0 }} · 阻塞 {{ result.blocked ?? 0 }} · 失败 {{ result.failed ?? 0 }}
|
||||
</p>
|
||||
@@ -450,6 +494,30 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
}}
|
||||
</p>
|
||||
</ContextNotice>
|
||||
<!-- 以下是派生任务的部分成功与失败明细,失败终态也保留已有结果 -->
|
||||
<div v-if="derivedTask && finished" class="mt-4 space-y-3 text-xs leading-6" aria-label="逐集设计结果">
|
||||
<p>
|
||||
共 {{ result.episodeCount ?? '待确认' }} 集 · 已保存 {{ result.completedEpisodes ?? '待确认' }} 集 ·
|
||||
跳过 {{ result.skippedEpisodes ?? '待确认' }} 集 · 失败 {{ result.failedEpisodes ?? '待确认' }} 集
|
||||
</p>
|
||||
<p v-if="derivedNeedsReview" class="text-danger">
|
||||
已成功结果会保留;请先核对失败剧集和仍过期的设计,不会自动重新提交生成。
|
||||
</p>
|
||||
<ul v-if="derivedEpisodes.length" class="space-y-2">
|
||||
<li v-for="item in derivedEpisodes" :key="item.episodeNo" class="wrap-anywhere">
|
||||
第 {{ item.episodeNo }} 集 ·
|
||||
{{
|
||||
item.error || item.status === 'failed'
|
||||
? '失败'
|
||||
: item.status === 'skipped'
|
||||
? '跳过'
|
||||
: item.status === 'completed'
|
||||
? '已保存'
|
||||
: '状态待确认'
|
||||
}}<span v-if="item.error">:{{ userFacingText(item.error) }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<!-- 以下是诊断中断恢复摘要,未知费用与人工核查直接显示 -->
|
||||
<div v-if="diagnosisTask && finished" class="mt-3 space-y-2 text-xs" aria-label="动作诊断任务统计">
|
||||
<p v-if="diagnosisRecovery">需要人工核查:中断时的模型请求可能已产生费用,系统不会自动重新诊断。</p>
|
||||
|
||||
@@ -59,6 +59,8 @@ export function executionStageLabel(stage: string | null) {
|
||||
finishProject: '完成剧本创作',
|
||||
resumeGeneration: '恢复剧本创作',
|
||||
resumeRewrite: '恢复剧本改写',
|
||||
resumeReview: '系统核查剧本',
|
||||
resolveDramaQuality: '复核剧本疑点',
|
||||
breakdown: '拆解剧本',
|
||||
subject_ready: '主体已整理完成',
|
||||
subject_candidate_ready: '主体候选已就绪',
|
||||
@@ -255,6 +257,8 @@ export function useWorkflowExecution(
|
||||
}
|
||||
const storyboardValidation = result.storyboardShotValidation
|
||||
const failures =
|
||||
result.manualReviewRequired === true ||
|
||||
(typeof result.failedEpisodes === 'number' && result.failedEpisodes > 0) ||
|
||||
(storyboardValidation &&
|
||||
typeof storyboardValidation === 'object' &&
|
||||
'valid' in storyboardValidation &&
|
||||
|
||||
@@ -37,13 +37,19 @@ const terms: [RegExp, string][] = [
|
||||
[/\bBreakdown\b/gi, '剧本拆解'],
|
||||
[/\bKeyframe\b/gi, '首帧'],
|
||||
[/Creative Profile/gi, '项目生成配置'],
|
||||
[/Visual Style/gi, '视觉风格'],
|
||||
[/Visual\s*Style/gi, '视觉风格'],
|
||||
[/GenerationSpec/gi, '镜头生成方案'],
|
||||
[/generationPrompt/gi, '正式生图提示词'],
|
||||
[/VisualState/gi, '画面即时状态'],
|
||||
[/\bSubjectRefs?\b/gi, '主体引用'],
|
||||
[/\bSubjectForms?\b/gi, '主体形态'],
|
||||
[/Identity Anchor/gi, '身份母版'],
|
||||
[/Prop Structure Spec|Structure Spec/gi, '道具结构规格'],
|
||||
[/Form Prompt/gi, '形态画面描述'],
|
||||
[/\bIdentity\b/g, '主体身份'],
|
||||
[/\bAnchor\b/g, '身份母版'],
|
||||
[/\bProduction\b/g, '制作准备'],
|
||||
[/\bProp\b/g, '道具'],
|
||||
[/Motion Plan/gi, '动作设计'],
|
||||
[/Video Prompt/gi, '视频提示词'],
|
||||
[/Negative\s*prompt/gi, '避免出现的内容'],
|
||||
@@ -86,6 +92,9 @@ export function userFacingText(value: string | null | undefined, fallback = '暂
|
||||
let text = value?.trim() ?? ''
|
||||
const codeLabels: Record<string, string> = {
|
||||
...configurationErrorLabels,
|
||||
PROP_STRUCTURE_SPEC_NOT_READY: '道具结构规格尚未就绪,请在形态图片的“图片准备检查”中准备资料后重新预览。',
|
||||
IMAGE_PREVIEW_STALE: '生成依据或配置已变化,请重新预览并确认后再生成。',
|
||||
INVALID_IMAGE_PREVIEW_FINGERPRINT: '预览版本无效,请重新读取生成预览。',
|
||||
QUALITY_POLICY_RECONFIRM_REQUIRED: '质量规则或正式分镜来源需要重新核对并确认。',
|
||||
QUALITY_POLICY_NOT_CONFIRMED: '请先核对并确认项目质量规则。',
|
||||
QUALITY_POLICY_VERSION_CONFLICT: '质量规则已更新,请重新核对后操作。',
|
||||
@@ -97,6 +106,8 @@ export function userFacingText(value: string | null | undefined, fallback = '暂
|
||||
const code = Object.keys(codeLabels).find(
|
||||
key => text === key || text.startsWith(`${key}:`) || text.startsWith(`${key}:`)
|
||||
)
|
||||
if (code === 'PROP_STRUCTURE_SPEC_NOT_READY' || code === 'INVALID_IMAGE_PREVIEW_FINGERPRINT')
|
||||
return codeLabels[code]!
|
||||
if (code)
|
||||
text =
|
||||
text
|
||||
|
||||
@@ -246,6 +246,10 @@ body {
|
||||
.dialog-form-stack > * {
|
||||
margin-block: 0 !important;
|
||||
}
|
||||
/* 全屏抽屉由标题区提供间距,表单不再叠加弹窗顶部留白。 */
|
||||
.app-drawer .dialog-form-stack {
|
||||
margin-top: 0;
|
||||
}
|
||||
.dialog-result-card {
|
||||
padding: 16px;
|
||||
background: var(--app-subtle);
|
||||
|
||||
@@ -27,6 +27,7 @@ export function testProjectContext(id = 'capability-test'): ReturnType<typeof us
|
||||
projectId: id,
|
||||
script: { ready: true, reason: null },
|
||||
breakdown: { ready: true, reason: null },
|
||||
preparation: { ready: true, reason: null },
|
||||
visualStyle: { ready: true, reason: null },
|
||||
identity: { ready: true, reason: null },
|
||||
subjectAssets: { ready: true, reason: null },
|
||||
|
||||
@@ -14,8 +14,11 @@ import { requiredTextRule } from '@/lib/form-rules'
|
||||
|
||||
/** 当前测试使用真实目录契约构造项目模型配置。 */
|
||||
const creativeProfile = generationProfile('gallery-test')
|
||||
/** 生成提交由测试替身接收,绝不调用真实模型。 */
|
||||
const submitGeneration = vi.fn<() => Promise<{ accepted: boolean }>>(async () => ({ accepted: true }))
|
||||
let wrapper: VueWrapper | undefined
|
||||
afterEach(() => {
|
||||
submitGeneration.mockClear()
|
||||
wrapper?.unmount()
|
||||
wrapper = undefined
|
||||
document.body.innerHTML = ''
|
||||
@@ -109,7 +112,14 @@ describe('统一的 Naive UI 表单校验', () => {
|
||||
it('图片尺寸采用目录必填枚举,切换目标清空提示词和费用确认', async () => {
|
||||
wrapper = mount(GenerateImageDialog, {
|
||||
attachTo: document.body,
|
||||
props: { open: true, form: formFixture(), disabled: false, catalog: imageCatalog, profile: creativeProfile }
|
||||
props: {
|
||||
submitGeneration,
|
||||
open: true,
|
||||
form: formFixture(),
|
||||
disabled: false,
|
||||
catalog: imageCatalog,
|
||||
profile: creativeProfile
|
||||
}
|
||||
})
|
||||
await flushPromises()
|
||||
const size = wrapper.findAllComponents(NSelect).find(select => select.props('value') === '2048*2048')!
|
||||
@@ -120,7 +130,7 @@ describe('统一的 Naive UI 表单校验', () => {
|
||||
await input('#image-prompt', '仅用于上一形态')
|
||||
document.querySelector<HTMLElement>('#confirm-image-cost')!.click()
|
||||
await flushPromises()
|
||||
expect(button('确认生成图片').disabled).toBe(false)
|
||||
expect(button('确认生成图片').disabled).toBe(true)
|
||||
await wrapper.setProps({ form: { ...formFixture(), id: 'other-form' } })
|
||||
await flushPromises()
|
||||
expect(document.querySelector<HTMLTextAreaElement>('#image-prompt')?.value).toBe('')
|
||||
|
||||
@@ -464,6 +464,7 @@ describe('管理后台组件边界', () => {
|
||||
projectId: 'navigation-test',
|
||||
script: { ready: true, reason: null },
|
||||
breakdown: { ready: true, reason: null },
|
||||
preparation: { ready: true, reason: null },
|
||||
visualStyle: { ready: true, reason: null },
|
||||
identity: { ready: true, reason: null },
|
||||
subjectAssets: { ready: true, reason: null },
|
||||
|
||||
@@ -549,6 +549,7 @@ function mountPage(records = [checkpoint()], episodes = 1): ReturnType<typeof us
|
||||
projectId: project.id,
|
||||
script: { ready: true, reason: null },
|
||||
breakdown: { ready: true, reason: null },
|
||||
preparation: { ready: true, reason: null },
|
||||
visualStyle: { ready: true, reason: null },
|
||||
identity: { ready: true, reason: null },
|
||||
subjectAssets: { ready: true, reason: null },
|
||||
@@ -971,7 +972,7 @@ describe('拆解页内容滚动', () => {
|
||||
await flushPromises()
|
||||
const issues = new DOMWrapper(document.querySelector<HTMLElement>('.app-drawer[aria-label="拆解问题"]')!)
|
||||
expect(issues.text()).toContain('待修复问题')
|
||||
for (const label of ['读取修复清单', '重试失败抽取', '补齐缺失镜头', '修复分镜绑定']) {
|
||||
for (const label of ['读取修复清单', '重试失败抽取', '继续整理镜头', '修复分镜绑定']) {
|
||||
const action = issues.findAll('button').find(button => button.text() === label)!
|
||||
expect((action.element as HTMLButtonElement).disabled).toBe(true)
|
||||
}
|
||||
|
||||
@@ -109,6 +109,36 @@ afterEach(() => {
|
||||
})
|
||||
|
||||
describe('故事规划创作进度与恢复', () => {
|
||||
it('只恢复审核时沿用已核对的正文和派生进度,不显示重新生成前序节点', async () => {
|
||||
context = testProjectContext('resume-system-review')
|
||||
context.data.value!.project.status = 'need_review'
|
||||
const saved = {
|
||||
...checkpoint(
|
||||
{
|
||||
storyPlan,
|
||||
episodes: context.project.value!.episodes,
|
||||
characters: { characters: [] },
|
||||
world: {},
|
||||
reviewPassed: false
|
||||
},
|
||||
'reviewDrama'
|
||||
),
|
||||
createdAt: '2026-10-27T00:00:00Z'
|
||||
}
|
||||
context.data.value!.checkpoints = [saved]
|
||||
const page = await open(
|
||||
execution(context.project.value!.id, {
|
||||
stage: 'resumeReview',
|
||||
metadata: { action: 'resume-review', checkpointId: saved.checkpointId }
|
||||
})
|
||||
)
|
||||
expect(page.get('[data-stage="generateEpisode"]').text()).toContain('已完成')
|
||||
expect(page.get('[data-stage="generateCharacter"]').text()).toContain('已完成')
|
||||
expect(page.get('[data-stage="generateWorld"]').text()).toContain('已完成')
|
||||
expect(page.get('[data-stage="reviewDrama"]').text()).toContain('进行中')
|
||||
expect(page.get('.script-task-summary').text()).toContain('系统核查剧本')
|
||||
})
|
||||
|
||||
it('人工审核已完成时,旧任务的待修订回执只作为历史记录展示', async () => {
|
||||
context = testProjectContext('manual-review-current-complete')
|
||||
context.data.value!.checkpoints = [
|
||||
|
||||
@@ -29,9 +29,9 @@ describe('审核记录中的人工问题处理', () => {
|
||||
it.each([
|
||||
{
|
||||
episodes: [],
|
||||
title: '请先核对审核问题',
|
||||
description: '点击“人工确认”对照原文逐项处理',
|
||||
actions: [['人工确认', 'primary']]
|
||||
title: '可由系统继续核查',
|
||||
description: '点击“系统重新核查”检查已保存正文',
|
||||
actions: [['人工确认', 'default']]
|
||||
},
|
||||
{
|
||||
episodes: [2],
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
import { DOMWrapper, flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import DramaReviewPanel from '@/features/create-drama/review/DramaReviewPanel.vue'
|
||||
import { dramaReviewApi } from '@/features/create-drama/review/api'
|
||||
import { projectContextKey } from '@/features/projects/context'
|
||||
import { testProjectContext } from '@/testing/project-context'
|
||||
import { confirmationPreview, latestReview, rewritePreview } from './fixtures'
|
||||
|
||||
/** 当前挂载的真实审核面板。 */
|
||||
let wrapper: VueWrapper | undefined
|
||||
|
||||
/**
|
||||
* 挂载审核面板并从系统核查入口打开真实确认弹窗。
|
||||
* @param id 当前测试项目
|
||||
* @returns 系统核查弹窗
|
||||
*/
|
||||
async function openSystemReview(id: string) {
|
||||
vi.spyOn(dramaReviewApi, 'latest').mockResolvedValue(latestReview(id))
|
||||
vi.spyOn(dramaReviewApi, 'preview').mockResolvedValue(confirmationPreview(id))
|
||||
vi.spyOn(dramaReviewApi, 'rewritePreview').mockResolvedValue({
|
||||
...rewritePreview(id),
|
||||
ready: false,
|
||||
status: 'needs_review',
|
||||
rewriteCharacters: false,
|
||||
rewriteWorld: false,
|
||||
rewriteEpisodes: false,
|
||||
episodeNumbers: []
|
||||
})
|
||||
wrapper = mount(DramaReviewPanel, {
|
||||
attachTo: document.body,
|
||||
props: { projectId: id },
|
||||
global: { provide: { [projectContextKey as symbol]: testProjectContext(id) } }
|
||||
})
|
||||
await flushPromises()
|
||||
const entry = wrapper.findAll('button').find(button => button.text() === '系统重新核查')
|
||||
expect(entry).toBeDefined()
|
||||
await entry!.trigger('click')
|
||||
await flushPromises()
|
||||
return new DOMWrapper(document.querySelector<HTMLElement>('.app-dialog[aria-label="系统重新核查"]')!)
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
wrapper?.unmount()
|
||||
wrapper = undefined
|
||||
document.body.innerHTML = ''
|
||||
localStorage.clear()
|
||||
})
|
||||
|
||||
describe('系统核查已保存剧本', () => {
|
||||
it('打开或取消仅预检,不自动调用模型', async () => {
|
||||
const fetcher = vi.fn<typeof fetch>().mockResolvedValue(
|
||||
new Response(
|
||||
JSON.stringify({
|
||||
data: {
|
||||
projectId: 'system-cancel',
|
||||
checkpointId: 'cp1',
|
||||
episodeCount: 2,
|
||||
ready: true,
|
||||
readOnly: true
|
||||
}
|
||||
})
|
||||
)
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const dialog = await openSystemReview('system-cancel')
|
||||
expect(dialog.text()).toContain('已保存的 2 集')
|
||||
expect(dialog.text()).toContain('不会重写正文')
|
||||
await dialog
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '取消')!
|
||||
.trigger('click')
|
||||
await flushPromises()
|
||||
expect(fetcher.mock.calls.every(([, options]) => !options?.method || options.method === 'GET')).toBe(true)
|
||||
})
|
||||
|
||||
it('确认前版本变化时禁止发起收费审核请求', async () => {
|
||||
let reads = 0
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(
|
||||
async () =>
|
||||
new Response(
|
||||
JSON.stringify({
|
||||
data: {
|
||||
projectId: 'system-stale',
|
||||
checkpointId: ++reads === 1 ? 'cp1' : 'cp2',
|
||||
episodeCount: 2,
|
||||
ready: true,
|
||||
readOnly: true
|
||||
}
|
||||
})
|
||||
)
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const dialog = await openSystemReview('system-stale')
|
||||
await dialog
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '开始系统核查')!
|
||||
.trigger('click')
|
||||
await flushPromises()
|
||||
expect(dialog.text()).toContain('已变化')
|
||||
expect(fetcher.mock.calls.every(([, options]) => !options?.method || options.method === 'GET')).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -27,6 +27,7 @@ function readiness(id: string, ready = true): ProjectStageReadiness {
|
||||
projectId: id,
|
||||
script: stage(),
|
||||
breakdown: stage(),
|
||||
preparation: stage(),
|
||||
visualStyle: stage(),
|
||||
identity: stage(),
|
||||
subjectAssets: stage(),
|
||||
@@ -133,6 +134,7 @@ describe('剧本完成前的下游访问限制', () => {
|
||||
const state = readiness(id, false)
|
||||
state.script = { ready: true, reason: null }
|
||||
state.breakdown = { ready: true, reason: null }
|
||||
state.preparation = { ready: true, reason: null }
|
||||
state.storyboard = { ready: true, reason: null }
|
||||
vi.mocked(projectsApi.stageReadiness).mockImplementation(async () => structuredClone(state))
|
||||
vi.spyOn(projectsApi, 'detail').mockResolvedValue(project(id, 'completed'))
|
||||
@@ -149,11 +151,12 @@ describe('剧本完成前的下游访问限制', () => {
|
||||
expect(wrapper!.find(`.n-menu a[href="/projects/${id}/visual-style"]`).exists()).toBe(true)
|
||||
expect(wrapper!.find(`.n-menu a[href="/projects/${id}/subject-identity"]`).exists()).toBe(false)
|
||||
expect(wrapper!.find(`.n-menu a[href="/projects/${id}/production"]`).exists()).toBe(false)
|
||||
state.breakdown = { ready: false, reason: '当前分镜审核已失效,请重新核对。' }
|
||||
state.breakdown = { ready: false, reason: '当前分镜来源已变化,请重新核对。' }
|
||||
state.preparation = { ready: false, reason: '当前分镜来源已变化,请重新核对。' }
|
||||
await wrapper!.get('.probe-refresh').trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper!.find('.workspace-probe').exists()).toBe(false)
|
||||
expect(wrapper!.get('.project-access-gate').text()).toContain('当前分镜审核已失效')
|
||||
expect(wrapper!.get('.project-access-gate').text()).toContain('当前分镜来源已变化')
|
||||
})
|
||||
it('身份请求不使用全局加载消息,完成和失败使用临时消息且不遗留横幅', async () => {
|
||||
vi.useFakeTimers()
|
||||
@@ -403,6 +406,38 @@ describe('剧本完成前的下游访问限制', () => {
|
||||
expect(mounted).toHaveBeenCalledExactlyOnceWith('storyboard')
|
||||
})
|
||||
|
||||
it('自动检查已就绪但整体审核待完成时可先进入风格准备,镜头制作仍保持限制', async () => {
|
||||
const id = 'prepare-before-approval'
|
||||
const state = {
|
||||
...readiness(id),
|
||||
preparation: { ready: true, reason: null },
|
||||
breakdown: { ready: false, reason: '整体审核待完成' }
|
||||
}
|
||||
vi.mocked(projectsApi.stageReadiness).mockResolvedValue(state)
|
||||
vi.spyOn(projectsApi, 'detail').mockResolvedValue(project(id, 'completed'))
|
||||
vi.spyOn(projectsApi, 'checkpoints').mockResolvedValue([])
|
||||
const { mounted } = await openProject(`/projects/${id}/visual-style`)
|
||||
expect(mounted).toHaveBeenCalledExactlyOnceWith('visual-style')
|
||||
expect(wrapper!.find(`.n-menu a[href="/projects/${id}/visual-style"]`).exists()).toBe(true)
|
||||
expect(wrapper!.find(`.n-menu a[href="/projects/${id}/production"]`).exists()).toBe(false)
|
||||
})
|
||||
|
||||
it('部分身份未齐备时可以逐项准备形态资料,但不能提前进入镜头设计或生产', async () => {
|
||||
const id = 'partial-asset-preparation'
|
||||
const state = readiness(id)
|
||||
state.identity = { ready: false, reason: '还有角色尚未确认选角' }
|
||||
state.subjectAssets = { ready: false, reason: '素材尚未准备完整' }
|
||||
state.breakdown = { ready: false, reason: '整体审核待完成' }
|
||||
vi.mocked(projectsApi.stageReadiness).mockResolvedValue(state)
|
||||
vi.spyOn(projectsApi, 'detail').mockResolvedValue(project(id, 'completed'))
|
||||
vi.spyOn(projectsApi, 'checkpoints').mockResolvedValue([])
|
||||
const { mounted } = await openProject(`/projects/${id}/subject-images`)
|
||||
expect(mounted).toHaveBeenCalledExactlyOnceWith('subject-images')
|
||||
expect(wrapper!.find(`.n-menu a[href="/projects/${id}/subject-images"]`).exists()).toBe(true)
|
||||
expect(wrapper!.find(`.n-menu a[href="/projects/${id}/storyboard"]`).exists()).toBe(false)
|
||||
expect(wrapper!.find(`.n-menu a[href="/projects/${id}/production"]`).exists()).toBe(false)
|
||||
})
|
||||
|
||||
it('剧本完成仍按服务端前置步骤逐步解锁,不能直接进入生产', async () => {
|
||||
const state = readiness('staged', false)
|
||||
state.script = { ready: true, reason: null }
|
||||
@@ -419,6 +454,7 @@ describe('剧本完成前的下游访问限制', () => {
|
||||
await flushPromises()
|
||||
expect(router.currentRoute.value.path).toBe('/projects/staged/breakdown')
|
||||
state.breakdown = { ready: true, reason: null }
|
||||
state.preparation = { ready: true, reason: null }
|
||||
state.subjectAssets = { ready: true, reason: null }
|
||||
state.storyboard = { ready: false, reason: '请先完成分镜设计' }
|
||||
await wrapper!.get('.probe-refresh').trigger('click')
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { imagePreviewFixture } from '../../fixtures/image-preview'
|
||||
import { imageCatalog, generationProfile } from '../../fixtures/generation'
|
||||
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { NButton, NImage } from 'naive-ui'
|
||||
import { AppDialog } from '@/components/ui'
|
||||
import IdentityImageDialog from '@/features/subject-identity/components/IdentityImageDialog.vue'
|
||||
@@ -19,8 +20,21 @@ import { identityImageFixture } from '@/features/subject-identity/testing/fixtur
|
||||
import { formFixture } from '@/features/subject-images/testing/fixtures'
|
||||
import { selectControl } from '@/testing/naive'
|
||||
|
||||
/** 生成提交由测试替身接收,绝不调用真实模型。 */
|
||||
const submitGeneration = vi.fn<() => Promise<{ accepted: boolean }>>(async () => ({ accepted: true }))
|
||||
let wrapper: VueWrapper | undefined
|
||||
/** 每次生成用例只返回无副作用的预览夹具。 */
|
||||
beforeEach(() =>
|
||||
vi.stubGlobal(
|
||||
'fetch',
|
||||
vi.fn<typeof fetch>().mockImplementation(async url => {
|
||||
const formId = String(url).match(/subject-forms\/([^/]+)/)?.[1] ?? 'form-db-1'
|
||||
return new Response(JSON.stringify({ data: imagePreviewFixture(formId) }))
|
||||
})
|
||||
)
|
||||
)
|
||||
afterEach(() => {
|
||||
submitGeneration.mockClear()
|
||||
wrapper?.unmount()
|
||||
wrapper = undefined
|
||||
document.body.innerHTML = ''
|
||||
@@ -333,6 +347,7 @@ describe('身份图与母版契约', () => {
|
||||
wrapper = mount(IdentityImageDialog, {
|
||||
attachTo: document.body,
|
||||
props: {
|
||||
submitGeneration,
|
||||
open: true,
|
||||
subjectId: 's1',
|
||||
subjectName: '林夏',
|
||||
@@ -352,13 +367,16 @@ describe('身份图与母版契约', () => {
|
||||
expect(button('确认生成身份图').disabled).toBe(true)
|
||||
input('#identity-image-prompt', ' 自定义身份提示词 ')
|
||||
await flushPromises()
|
||||
button('预览实际生成输入').click()
|
||||
await flushPromises()
|
||||
document.querySelector<HTMLInputElement>('#identity-image-cost')!.click()
|
||||
await flushPromises()
|
||||
button('确认生成身份图').click()
|
||||
await flushPromises()
|
||||
expect(wrapper.emitted('generate')).toEqual([
|
||||
expect(submitGeneration.mock.calls).toEqual([
|
||||
[
|
||||
{
|
||||
expectedPreviewFingerprint: 'a'.repeat(64),
|
||||
viewType: 'three-quarter',
|
||||
referenceImageId: 'identity-image-1',
|
||||
provider: 'qwen-image',
|
||||
@@ -373,6 +391,7 @@ describe('身份图与母版契约', () => {
|
||||
wrapper = mount(IdentityImageDialog, {
|
||||
attachTo: document.body,
|
||||
props: {
|
||||
submitGeneration,
|
||||
open: true,
|
||||
subjectId: 's1',
|
||||
subjectName: '林夏',
|
||||
@@ -385,6 +404,8 @@ describe('身份图与母版契约', () => {
|
||||
})
|
||||
await flushPromises()
|
||||
input('#identity-reference', 'identity-image-1')
|
||||
button('预览实际生成输入').click()
|
||||
await flushPromises()
|
||||
document.querySelector<HTMLInputElement>('#identity-image-cost')!.click()
|
||||
await flushPromises()
|
||||
await wrapper.setProps({ images: [] })
|
||||
@@ -398,6 +419,7 @@ describe('身份图与母版契约', () => {
|
||||
wrapper = mount(IdentityImageDialog, {
|
||||
attachTo: document.body,
|
||||
props: {
|
||||
submitGeneration,
|
||||
open: true,
|
||||
subjectId: 's1',
|
||||
subjectName: '林夏',
|
||||
@@ -491,6 +513,7 @@ describe('身份图与母版契约', () => {
|
||||
wrapper = mount(CastingCandidateDialog, {
|
||||
attachTo: document.body,
|
||||
props: {
|
||||
submitGeneration,
|
||||
open: true,
|
||||
subjectId: 'subject-1',
|
||||
subjectName: '林夏',
|
||||
@@ -529,12 +552,20 @@ describe('身份图与母版契约', () => {
|
||||
})
|
||||
await flushPromises()
|
||||
expect(document.body.textContent).toContain('不会复用当前身份母版')
|
||||
button('预览实际生成输入').click()
|
||||
await flushPromises()
|
||||
document.querySelector<HTMLInputElement>('#casting-candidate-cost')!.click()
|
||||
await flushPromises()
|
||||
button('AI 生成角色候选图').click()
|
||||
await flushPromises()
|
||||
expect(wrapper.emitted('generate')).toEqual([
|
||||
[{ provider: 'qwen-image', generationOptions: { size: '1536*2688' } }]
|
||||
expect(submitGeneration.mock.calls).toEqual([
|
||||
[
|
||||
{
|
||||
expectedPreviewFingerprint: 'a'.repeat(64),
|
||||
provider: 'qwen-image',
|
||||
generationOptions: { size: '1536*2688' }
|
||||
}
|
||||
]
|
||||
])
|
||||
})
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@ describe('过期首帧到具体素材定位', () => {
|
||||
})
|
||||
const card = wrapper!.findAll('.form-image-card').find(item => item.attributes('data-form-id') === first.id)!
|
||||
expect(card.get('.asset-image').classes()).not.toContain('form-image-has-source')
|
||||
expect(card.get('.asset-image-empty').text()).toContain('确认并锁定身份母版后自动复用')
|
||||
expect(card.get('.asset-image-empty').text()).toContain('请先确认并锁定身份母版')
|
||||
expect(card.find('img').exists()).toBe(false)
|
||||
})
|
||||
|
||||
@@ -224,7 +224,7 @@ describe('过期首帧到具体素材定位', () => {
|
||||
.get('.gallery-layout-switch')
|
||||
.findAll('button')
|
||||
.map(button => button.attributes('aria-label'))
|
||||
).toEqual(['网格布局', '瀑布流布局', '批量生图'])
|
||||
).toEqual(['图片准备检查', '网格布局', '瀑布流布局', '批量生图'])
|
||||
await wrapper!.get('[aria-label="网格布局"]').trigger('click')
|
||||
expect(wrapper!.find('.form-image-masonry').exists()).toBe(false)
|
||||
expect(wrapper!.get('[aria-label="网格布局"]').attributes('aria-pressed')).toBe('true')
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
import { defineComponent, ref } from 'vue'
|
||||
import { mount, flushPromises, type VueWrapper } from '@vue/test-utils'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { ApiError } from '@/lib/http'
|
||||
import { useImageGenerationPreview, type ImageGenerationSubmission } from '@/features/subject-images/generation-preview'
|
||||
import { imagePreviewFixture } from '../../fixtures/image-preview'
|
||||
|
||||
/** 仅挂载实际状态逻辑,所有请求均为无费用替身。 */
|
||||
let wrapper: VueWrapper | undefined
|
||||
/** 每个用例释放监听与未完成预览。 */
|
||||
afterEach(() => wrapper?.unmount())
|
||||
|
||||
/**
|
||||
* 建立受控表单,测试确认、版本和异步边界。
|
||||
* @param generate 生成请求的确定性替身
|
||||
* @param load 只读预览的确定性替身
|
||||
* @returns 表单状态及真实共用逻辑
|
||||
*/
|
||||
function setup(
|
||||
generate = vi.fn<() => Promise<ImageGenerationSubmission>>(
|
||||
async (): Promise<ImageGenerationSubmission> => ({ accepted: true })
|
||||
),
|
||||
load = vi.fn<() => Promise<ReturnType<typeof imagePreviewFixture>>>(async () => imagePreviewFixture())
|
||||
) {
|
||||
const open = ref(true),
|
||||
prompt = ref('初始描述')
|
||||
let flow!: ReturnType<typeof useImageGenerationPreview<{ prompt: string }, ReturnType<typeof imagePreviewFixture>>>
|
||||
wrapper = mount(
|
||||
defineComponent({
|
||||
setup() {
|
||||
flow = useImageGenerationPreview({
|
||||
open,
|
||||
target: () => 'form-1',
|
||||
input: () => ({ prompt: prompt.value }),
|
||||
disabled: () => false,
|
||||
load,
|
||||
generate
|
||||
})
|
||||
return () => null
|
||||
}
|
||||
})
|
||||
)
|
||||
return { flow, open, prompt, generate, load }
|
||||
}
|
||||
|
||||
describe('生图预览与版本确认', () => {
|
||||
it('预览成功且确认后才携带版本提交,修改描述立即清除旧确认', async () => {
|
||||
const { flow, prompt, generate } = setup()
|
||||
flow.acknowledged.value = true
|
||||
await flow.submit()
|
||||
expect(generate).not.toHaveBeenCalled()
|
||||
await flow.loadPreview()
|
||||
flow.acknowledged.value = true
|
||||
prompt.value = '新描述'
|
||||
expect(flow.preview.value).toBeNull()
|
||||
expect(flow.acknowledged.value).toBe(false)
|
||||
await flow.loadPreview()
|
||||
flow.acknowledged.value = true
|
||||
await flow.submit()
|
||||
expect(generate).toHaveBeenCalledExactlyOnceWith({
|
||||
prompt: '新描述',
|
||||
expectedPreviewFingerprint: 'a'.repeat(64)
|
||||
})
|
||||
})
|
||||
it('明确的预览过期 409 只重新预览,不自动重复收费请求', async () => {
|
||||
const generate = vi.fn<() => Promise<ImageGenerationSubmission>>(async () => ({
|
||||
accepted: false,
|
||||
cause: new ApiError('过期', 409, undefined, 'IMAGE_PREVIEW_STALE')
|
||||
}))
|
||||
const { flow, open, load } = setup(generate)
|
||||
await flow.loadPreview()
|
||||
flow.acknowledged.value = true
|
||||
await flow.submit()
|
||||
expect(open.value).toBe(true)
|
||||
expect(load).toHaveBeenCalledTimes(2)
|
||||
expect(generate).toHaveBeenCalledOnce()
|
||||
expect(flow.acknowledged.value).toBe(false)
|
||||
expect(flow.canSubmit.value).toBe(false)
|
||||
expect(flow.staleNotice.value).toContain('重新确认')
|
||||
})
|
||||
it('普通 409 和未知网络结果均不自动预览或重新提交', async () => {
|
||||
const { flow, load, generate } = setup(
|
||||
vi.fn<() => Promise<ImageGenerationSubmission>>(async () => ({
|
||||
accepted: false,
|
||||
cause: new ApiError('活动任务冲突', 409)
|
||||
}))
|
||||
)
|
||||
await flow.loadPreview()
|
||||
flow.acknowledged.value = true
|
||||
await flow.submit()
|
||||
expect(load).toHaveBeenCalledOnce()
|
||||
expect(generate).toHaveBeenCalledOnce()
|
||||
expect(flow.error.value).toContain('活动任务')
|
||||
expect(flow.acknowledged.value).toBe(false)
|
||||
})
|
||||
it('关闭再打开相同参数后,旧预览响应不得回填', async () => {
|
||||
let resolve!: (value: ReturnType<typeof imagePreviewFixture>) => void
|
||||
const { flow, open } = setup(
|
||||
undefined,
|
||||
vi.fn<() => Promise<ReturnType<typeof imagePreviewFixture>>>(
|
||||
() =>
|
||||
new Promise(done => {
|
||||
resolve = done
|
||||
})
|
||||
)
|
||||
)
|
||||
const request = flow.loadPreview()
|
||||
open.value = false
|
||||
open.value = true
|
||||
resolve(imagePreviewFixture())
|
||||
await request
|
||||
expect(flow.preview.value).toBeNull()
|
||||
expect(flow.loading.value).toBe(false)
|
||||
})
|
||||
it('提交期间重复点击不会重复创建任务,参数变化后不关闭新表单', async () => {
|
||||
let resolve!: (value: ImageGenerationSubmission) => void
|
||||
const generate = vi.fn<() => Promise<ImageGenerationSubmission>>(
|
||||
() =>
|
||||
new Promise<ImageGenerationSubmission>(done => {
|
||||
resolve = done
|
||||
})
|
||||
)
|
||||
const { flow, prompt, open } = setup(generate)
|
||||
await flow.loadPreview()
|
||||
flow.acknowledged.value = true
|
||||
const request = flow.submit()
|
||||
await flow.submit()
|
||||
expect(generate).toHaveBeenCalledOnce()
|
||||
prompt.value = '另一个目标的草稿'
|
||||
resolve({ accepted: true })
|
||||
await request
|
||||
expect(open.value).toBe(true)
|
||||
})
|
||||
it('缺失预览版本不能被确认成有效输入', async () => {
|
||||
const { flow } = setup(
|
||||
undefined,
|
||||
vi.fn<() => Promise<ReturnType<typeof imagePreviewFixture>>>(async () => ({
|
||||
...imagePreviewFixture(),
|
||||
previewFingerprint: ''
|
||||
}))
|
||||
)
|
||||
await flow.loadPreview()
|
||||
await flushPromises()
|
||||
expect(flow.preview.value).toBeNull()
|
||||
expect(flow.error.value).toContain('不完整')
|
||||
})
|
||||
})
|
||||
@@ -1,6 +1,7 @@
|
||||
import { imagePreviewFixture } from '../../fixtures/image-preview'
|
||||
import { imageCatalog, generationProfile } from '../../fixtures/generation'
|
||||
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { AssetImage } from '@/components/ui'
|
||||
import { getOperation } from '@/features/workflows/operations'
|
||||
import GenerateImageDialog from '@/features/subject-images/components/GenerateImageDialog.vue'
|
||||
@@ -11,6 +12,8 @@ import { expandSections } from '@/testing/naive'
|
||||
|
||||
/** 当前测试使用真实目录契约构造项目模型配置。 */
|
||||
const creativeProfile = generationProfile('gallery-test')
|
||||
/** 生成提交由测试替身接收,绝不调用真实模型。 */
|
||||
const submitGeneration = vi.fn<() => Promise<{ accepted: boolean }>>(async () => ({ accepted: true }))
|
||||
let wrapper: VueWrapper | undefined
|
||||
/** Naive 将弹窗挂载到 body,需要从实际弹窗找到按钮。 */
|
||||
function button(label: string): HTMLButtonElement {
|
||||
@@ -18,7 +21,18 @@ function button(label: string): HTMLButtonElement {
|
||||
if (!element) throw new Error('找不到按钮:' + label)
|
||||
return element
|
||||
}
|
||||
/** 每次生成用例只返回无副作用的预览夹具。 */
|
||||
beforeEach(() =>
|
||||
vi.stubGlobal(
|
||||
'fetch',
|
||||
vi.fn<typeof fetch>().mockImplementation(async url => {
|
||||
const formId = String(url).match(/subject-forms\/([^/]+)/)?.[1] ?? 'form-db-1'
|
||||
return new Response(JSON.stringify({ data: imagePreviewFixture(formId) }))
|
||||
})
|
||||
)
|
||||
)
|
||||
afterEach(() => {
|
||||
submitGeneration.mockClear()
|
||||
wrapper?.unmount()
|
||||
wrapper = undefined
|
||||
document.body.innerHTML = ''
|
||||
@@ -70,10 +84,17 @@ describe('形态图片选择与操作', () => {
|
||||
form.subject.module = module
|
||||
wrapper = mount(GenerateImageDialog, {
|
||||
attachTo: document.body,
|
||||
props: { open: true, form, disabled: false, catalog: imageCatalog, profile: creativeProfile }
|
||||
props: {
|
||||
submitGeneration,
|
||||
open: true,
|
||||
form,
|
||||
disabled: false,
|
||||
catalog: imageCatalog,
|
||||
profile: creativeProfile
|
||||
}
|
||||
})
|
||||
await flushPromises()
|
||||
expect(document.body.textContent).toContain('母版')
|
||||
expect(document.body.textContent).toContain('质量审核')
|
||||
expect(document.body.textContent).not.toContain('道具形态生图暂不自动引用')
|
||||
})
|
||||
it('按需预览正式形态的实际参考图和 Provider Prompt,不触发生图事件', async () => {
|
||||
@@ -81,6 +102,7 @@ describe('形态图片选择与操作', () => {
|
||||
new Response(
|
||||
JSON.stringify({
|
||||
data: {
|
||||
...imagePreviewFixture(),
|
||||
subjectFormId: 'form-db-1',
|
||||
provider: 'seedream',
|
||||
model: 'image-model',
|
||||
@@ -101,7 +123,14 @@ describe('形态图片选择与操作', () => {
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
wrapper = mount(GenerateImageDialog, {
|
||||
attachTo: document.body,
|
||||
props: { open: true, form: formFixture(), disabled: false, catalog: imageCatalog, profile: creativeProfile }
|
||||
props: {
|
||||
submitGeneration,
|
||||
open: true,
|
||||
form: formFixture(),
|
||||
disabled: false,
|
||||
catalog: imageCatalog,
|
||||
profile: creativeProfile
|
||||
}
|
||||
})
|
||||
await flushPromises()
|
||||
button('预览实际生成输入').click()
|
||||
@@ -142,30 +171,56 @@ describe('形态图片选择与操作', () => {
|
||||
it('生图确认发送正式形态 ID 和项目模型参数,默认不替换已有主图', async () => {
|
||||
wrapper = mount(GenerateImageDialog, {
|
||||
attachTo: document.body,
|
||||
props: { open: true, form: formFixture(), disabled: false, catalog: imageCatalog, profile: creativeProfile }
|
||||
props: {
|
||||
submitGeneration,
|
||||
open: true,
|
||||
form: formFixture(),
|
||||
disabled: false,
|
||||
catalog: imageCatalog,
|
||||
profile: creativeProfile
|
||||
}
|
||||
})
|
||||
await flushPromises()
|
||||
expect(button('确认生成图片').disabled).toBe(true)
|
||||
button('预览实际生成输入').click()
|
||||
await flushPromises()
|
||||
document.querySelector<HTMLInputElement>('#confirm-image-cost')!.click()
|
||||
await flushPromises()
|
||||
button('确认生成图片').click()
|
||||
await flushPromises()
|
||||
expect(wrapper.emitted('generate')).toEqual([
|
||||
['form-db-1', { setPrimary: false, provider: 'qwen-image', generationOptions: { size: '2048*2048' } }]
|
||||
expect(submitGeneration.mock.calls).toEqual([
|
||||
[
|
||||
'form-db-1',
|
||||
{
|
||||
setPrimary: false,
|
||||
expectedPreviewFingerprint: 'a'.repeat(64),
|
||||
provider: 'qwen-image',
|
||||
generationOptions: { size: '2048*2048' }
|
||||
}
|
||||
]
|
||||
])
|
||||
})
|
||||
|
||||
it('新形态默认设主图并继承目录尺寸,切换形态清空提示词和费用确认', async () => {
|
||||
it('新形态默认保留候选并继承目录尺寸,切换形态清空提示词和确认', async () => {
|
||||
const form = formFixture()
|
||||
form.images = []
|
||||
wrapper = mount(GenerateImageDialog, {
|
||||
attachTo: document.body,
|
||||
props: { open: true, form, disabled: false, catalog: imageCatalog, profile: creativeProfile }
|
||||
props: {
|
||||
submitGeneration,
|
||||
open: true,
|
||||
form,
|
||||
disabled: false,
|
||||
catalog: imageCatalog,
|
||||
profile: creativeProfile
|
||||
}
|
||||
})
|
||||
await flushPromises()
|
||||
const prompt = document.querySelector<HTMLTextAreaElement>('#image-prompt')!
|
||||
prompt.value = '上一形态自定义提示词'
|
||||
prompt.dispatchEvent(new Event('input', { bubbles: true }))
|
||||
button('预览实际生成输入').click()
|
||||
await flushPromises()
|
||||
document.querySelector<HTMLInputElement>('#confirm-image-cost')!.click()
|
||||
await flushPromises()
|
||||
expect(button('确认生成图片').disabled).toBe(false)
|
||||
@@ -176,12 +231,22 @@ describe('形态图片选择与操作', () => {
|
||||
expect(document.querySelector('#image-width')).toBeNull()
|
||||
expect(document.querySelector('#image-height')).toBeNull()
|
||||
expect(document.querySelector('#confirm-image-cost')!.getAttribute('aria-checked')).toBe('false')
|
||||
button('预览实际生成输入').click()
|
||||
await flushPromises()
|
||||
document.querySelector<HTMLInputElement>('#confirm-image-cost')!.click()
|
||||
await flushPromises()
|
||||
button('确认生成图片').click()
|
||||
await flushPromises()
|
||||
expect(wrapper.emitted('generate')).toEqual([
|
||||
['form-db-2', { setPrimary: true, provider: 'qwen-image', generationOptions: { size: '2048*2048' } }]
|
||||
expect(submitGeneration.mock.calls).toEqual([
|
||||
[
|
||||
'form-db-2',
|
||||
{
|
||||
setPrimary: false,
|
||||
expectedPreviewFingerprint: 'a'.repeat(64),
|
||||
provider: 'qwen-image',
|
||||
generationOptions: { size: '2048*2048' }
|
||||
}
|
||||
]
|
||||
])
|
||||
})
|
||||
|
||||
@@ -223,7 +288,7 @@ describe('形态图片选择与操作', () => {
|
||||
button('设为主参考图').click()
|
||||
await flushPromises()
|
||||
expect(fetcher.mock.calls).toHaveLength(1)
|
||||
button('确认切换主图').click()
|
||||
button('确认费用并设为主图').click()
|
||||
await flushPromises()
|
||||
expect(fetcher.mock.calls.find(([, init]) => init?.method === 'PUT')?.[0]).toBe(
|
||||
'/api/subject-forms/form-db-1/images/image-db-1/primary'
|
||||
|
||||
@@ -13,6 +13,8 @@ import GenerateImageDialog from '@/features/subject-images/components/GenerateIm
|
||||
|
||||
/** 当前测试使用真实目录契约构造项目模型配置。 */
|
||||
const creativeProfile = generationProfile('gallery-test')
|
||||
/** 生成提交由测试替身接收,绝不调用真实模型。 */
|
||||
const submitGeneration = vi.fn<() => Promise<{ accepted: boolean }>>(async () => ({ accepted: true }))
|
||||
let wrapper: VueWrapper | undefined
|
||||
const projectId = 'capability-test'
|
||||
/** 从实际挂载的确认弹窗查找操作按钮。 */
|
||||
@@ -20,6 +22,7 @@ function find(label: string) {
|
||||
return [...document.querySelectorAll('button')].find(item => item.textContent?.trim() === label)!
|
||||
}
|
||||
afterEach(() => {
|
||||
submitGeneration.mockClear()
|
||||
wrapper?.unmount()
|
||||
wrapper = undefined
|
||||
document.body.innerHTML = ''
|
||||
@@ -180,13 +183,20 @@ describe('形态正式提示词与批量配置', () => {
|
||||
await flushPromises()
|
||||
expect(wrapper.emitted('generate')).toEqual([['form-db-1', false]])
|
||||
})
|
||||
it('缺少正式和原始提示词仍可确认生图,由后端补齐而非前端编造', async () => {
|
||||
it('未取得有效预览时不允许直接生图,不代为补齐资料', async () => {
|
||||
const form = formFixture()
|
||||
form.appearancePrompt = null
|
||||
form.generationPrompt = null
|
||||
wrapper = mount(GenerateImageDialog, {
|
||||
attachTo: document.body,
|
||||
props: { open: true, disabled: false, form, catalog: imageCatalog, profile: creativeProfile }
|
||||
props: {
|
||||
submitGeneration,
|
||||
open: true,
|
||||
disabled: false,
|
||||
form,
|
||||
catalog: imageCatalog,
|
||||
profile: creativeProfile
|
||||
}
|
||||
})
|
||||
await flushPromises()
|
||||
document.querySelector<HTMLElement>('#confirm-image-cost')!.click()
|
||||
@@ -194,11 +204,9 @@ describe('形态正式提示词与批量配置', () => {
|
||||
const submit = [...document.querySelectorAll('button')].find(
|
||||
item => item.textContent?.trim() === '确认生成图片'
|
||||
)!
|
||||
expect(submit.disabled).toBe(false)
|
||||
expect(submit.disabled).toBe(true)
|
||||
submit.click()
|
||||
await flushPromises()
|
||||
expect(wrapper.emitted('generate')).toEqual([
|
||||
['form-db-1', { setPrimary: false, provider: 'qwen-image', generationOptions: { size: '2048*2048' } }]
|
||||
])
|
||||
expect(submitGeneration).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,160 @@
|
||||
import { mount, flushPromises, type VueWrapper } from '@vue/test-utils'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import ImageGalleryDialog from '@/features/subject-images/components/ImageGalleryDialog.vue'
|
||||
import { getOperation } from '@/features/workflows/operations'
|
||||
import { formFixture, imageFixture } from '@/features/subject-images/testing/fixtures'
|
||||
import { subjectImagesApi } from '@/features/subject-images/api'
|
||||
|
||||
/** 当前测试挂载的图库。 */
|
||||
let wrapper: VueWrapper | undefined
|
||||
/** 清理测试请求、活动锁和弹层。 */
|
||||
afterEach(() => {
|
||||
wrapper?.unmount()
|
||||
document.body.innerHTML = ''
|
||||
vi.unstubAllGlobals()
|
||||
Object.assign(getOperation('quality-flow'), { pending: false, cause: null, error: '', notice: '' })
|
||||
})
|
||||
/**
|
||||
* 根据中文名称选择真实确认按钮。
|
||||
* @param label 完整按钮文本
|
||||
* @returns 原生按钮
|
||||
*/
|
||||
function button(label: string) {
|
||||
const value = [...document.querySelectorAll('button')].find(item => item.textContent?.trim() === label)
|
||||
if (!value) throw new Error(`缺少按钮 ${label}`)
|
||||
return value
|
||||
}
|
||||
|
||||
describe('候选质量与主图门禁', () => {
|
||||
it('completed 但质量失败的候选保留,GET 不切主图,审核不自动采纳', async () => {
|
||||
const original = imageFixture({ id: 'old' })
|
||||
const candidate = imageFixture({
|
||||
id: 'candidate',
|
||||
isPrimary: false,
|
||||
qualityPassed: false,
|
||||
qualityIssues: [{ type: 'form_mismatch', severity: 'error', description: '原始数量不一致' }]
|
||||
})
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(
|
||||
async (_url, init) =>
|
||||
new Response(
|
||||
JSON.stringify({
|
||||
data:
|
||||
init?.method === 'POST'
|
||||
? {
|
||||
subjectId: 'subject-db-1',
|
||||
subjectFormId: 'form-db-1',
|
||||
imageId: 'candidate',
|
||||
passed: false,
|
||||
sourceRequirementsPassed: false,
|
||||
sourceVisualRequirements: [],
|
||||
summary: '需核对数量',
|
||||
issues: []
|
||||
}
|
||||
: [candidate, original]
|
||||
})
|
||||
)
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
wrapper = mount(ImageGalleryDialog, {
|
||||
attachTo: document.body,
|
||||
props: { projectId: 'quality-flow', form: formFixture(), disabled: false, open: true }
|
||||
})
|
||||
await flushPromises()
|
||||
document.querySelector<HTMLButtonElement>('[aria-label="查看图片 candidate"]')!.click()
|
||||
await flushPromises()
|
||||
expect(button('设为主参考图').disabled).toBe(true)
|
||||
expect(document.body.textContent).toContain('质量未通过')
|
||||
expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
|
||||
button('审核此图片').click()
|
||||
await flushPromises()
|
||||
expect(fetcher).toHaveBeenCalledOnce()
|
||||
button('确认费用并审核').click()
|
||||
await flushPromises()
|
||||
expect(fetcher.mock.calls.filter(([, init]) => init?.method === 'POST')).toHaveLength(1)
|
||||
expect(fetcher.mock.calls.some(([, init]) => init?.method === 'PUT')).toBe(false)
|
||||
expect(original.isPrimary).toBe(true)
|
||||
expect(document.body.textContent).toContain('需核对数量')
|
||||
})
|
||||
it('主图晋升 409 保留原主图,不乐观切换或自动重试', async () => {
|
||||
const original = imageFixture({ id: 'old' })
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async (_url, init) =>
|
||||
init?.method === 'PUT'
|
||||
? new Response(JSON.stringify({ message: '审核证据已过期,请明确重新审核' }), { status: 409 })
|
||||
: new Response(
|
||||
JSON.stringify({
|
||||
data: [imageFixture({ id: 'candidate', isPrimary: false, qualityPassed: true }), original]
|
||||
})
|
||||
)
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
wrapper = mount(ImageGalleryDialog, {
|
||||
attachTo: document.body,
|
||||
props: { projectId: 'quality-flow', form: formFixture(), disabled: false, open: true }
|
||||
})
|
||||
await flushPromises()
|
||||
document.querySelector<HTMLButtonElement>('[aria-label="查看图片 candidate"]')!.click()
|
||||
await flushPromises()
|
||||
button('设为主参考图').click()
|
||||
await flushPromises()
|
||||
button('确认费用并设为主图').click()
|
||||
await flushPromises()
|
||||
expect(fetcher.mock.calls.filter(([, init]) => init?.method === 'PUT')).toHaveLength(1)
|
||||
expect(document.body.textContent).toContain('审核证据已过期')
|
||||
expect(wrapper.emitted('changed')).toBeUndefined()
|
||||
expect(original.isPrimary).toBe(true)
|
||||
})
|
||||
it('质量处理默认预算为零,只有明确确认后发出一次请求', async () => {
|
||||
const image = imageFixture({ isPrimary: false })
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(
|
||||
async (_url, init) =>
|
||||
new Response(
|
||||
JSON.stringify({
|
||||
data:
|
||||
init?.method === 'POST'
|
||||
? {
|
||||
subjectFormId: 'form-db-1',
|
||||
initialImageId: image.id,
|
||||
finalImageId: image.id,
|
||||
passed: false,
|
||||
repaired: false,
|
||||
repairAttempts: 0,
|
||||
maxRepairAttempts: 0,
|
||||
primaryChanged: false,
|
||||
attempts: []
|
||||
}
|
||||
: [image]
|
||||
})
|
||||
)
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
wrapper = mount(ImageGalleryDialog, {
|
||||
attachTo: document.body,
|
||||
props: { projectId: 'quality-flow', form: formFixture(), disabled: false, open: true }
|
||||
})
|
||||
await flushPromises()
|
||||
button('审核与修复').click()
|
||||
await flushPromises()
|
||||
expect(fetcher.mock.calls.some(([, init]) => init?.method === 'POST')).toBe(false)
|
||||
expect(document.querySelector<HTMLInputElement>('#quality-repair-budget')?.value).toBe('0')
|
||||
button('确认费用并执行').click()
|
||||
await flushPromises()
|
||||
const calls = fetcher.mock.calls.filter(([, init]) => init?.method === 'POST')
|
||||
expect(calls).toHaveLength(1)
|
||||
expect(JSON.parse(calls[0]![1]!.body as string)).toEqual({
|
||||
imageId: image.id,
|
||||
provider: image.provider,
|
||||
maxRepairAttempts: 0
|
||||
})
|
||||
expect(document.body.textContent).toContain('主图未切换')
|
||||
})
|
||||
it('预览携带尺寸与负面描述,结构准备只调用正式文字入口', async () => {
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async () => new Response(JSON.stringify({ data: {} })))
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const input = { width: 1024, height: 1024, negativePrompt: '不要额外配件', prompt: '原始要求' }
|
||||
await subjectImagesApi.preview('form/1', input)
|
||||
await subjectImagesApi.prepareStructure('form/1')
|
||||
expect(JSON.parse(fetcher.mock.calls[0]![1]!.body as string)).toEqual(input)
|
||||
expect(fetcher.mock.calls[1]![0]).toBe('/api/subject-forms/form%2F1/prop-structure-spec/generate')
|
||||
expect(fetcher).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,70 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
imageValidationPassed,
|
||||
sourceRequirementRows,
|
||||
type ImageValidationResult
|
||||
} from '@/features/subject-images/validation'
|
||||
|
||||
/**
|
||||
* 原始定义与实际计数使用不同题材的确定性样例。
|
||||
* @returns 当前主体审核记录
|
||||
*/
|
||||
function result(): ImageValidationResult {
|
||||
return {
|
||||
subjectId: 'subject',
|
||||
imageId: 'image',
|
||||
passed: true,
|
||||
summary: '审核结束',
|
||||
issues: [],
|
||||
sourceRequirementsPassed: true,
|
||||
sourceVisualRequirements: [
|
||||
{
|
||||
id: 'requirement',
|
||||
subjectId: 'subject',
|
||||
subjectName: '控制台',
|
||||
sourceQuote: '控制台上有三个圆形按键',
|
||||
quantities: [{ id: 'quantity', sourcePhrase: '三个圆形按键', expectedCount: 3 }]
|
||||
}
|
||||
],
|
||||
sourceVisualRequirementResults: [
|
||||
{
|
||||
requirementId: 'requirement',
|
||||
status: 'passed',
|
||||
evidence: '图中可辨认三个按键',
|
||||
quantities: [{ quantityId: 'quantity', observedCount: 3 }]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
describe('原始定义与数量审核', () => {
|
||||
it('只有原文、唯一审核结果与数量全部一致才显示通过', () => {
|
||||
expect(imageValidationPassed(result())).toBe(true)
|
||||
expect(sourceRequirementRows(result())[0]).toMatchObject({
|
||||
sourceQuote: '控制台上有三个圆形按键',
|
||||
label: '通过'
|
||||
})
|
||||
})
|
||||
it.each(['missing', 'duplicate', 'unobservable', 'count', 'missing_quantity', 'duplicate_quantity'] as const)(
|
||||
'%s 证据不完整时不信任顶层 passed',
|
||||
kind => {
|
||||
const value = result()
|
||||
const item = value.sourceVisualRequirementResults![0]!
|
||||
if (kind === 'missing') value.sourceVisualRequirementResults = []
|
||||
if (kind === 'duplicate') value.sourceVisualRequirementResults!.push({ ...item })
|
||||
if (kind === 'unobservable') item.status = 'unobservable'
|
||||
if (kind === 'count') item.quantities![0]!.observedCount = 2
|
||||
if (kind === 'missing_quantity') item.quantities = []
|
||||
if (kind === 'duplicate_quantity') item.quantities!.push({ ...item.quantities![0]! })
|
||||
expect(imageValidationPassed(value)).toBe(false)
|
||||
}
|
||||
)
|
||||
it('无原始数量要求时不编造数量;旧审核缺少证据不标通过', () => {
|
||||
const value = result()
|
||||
value.sourceVisualRequirements = []
|
||||
value.sourceVisualRequirementResults = []
|
||||
expect(imageValidationPassed(value)).toBe(true)
|
||||
delete value.sourceRequirementsPassed
|
||||
expect(imageValidationPassed(value)).toBe(false)
|
||||
})
|
||||
})
|
||||
@@ -32,6 +32,37 @@ afterEach(() => {
|
||||
})
|
||||
|
||||
describe('WorkflowExecution 前端契约', () => {
|
||||
it.each(['failed', 'completed'] as const)('派生任务 %s 保留部分结果,不用绿色表示全部完成', status => {
|
||||
const wrapper = mount(WorkflowExecutionPanel, {
|
||||
props: {
|
||||
loading: false,
|
||||
error: '',
|
||||
execution: execution({
|
||||
workflowName: 'storyboard-visual-state',
|
||||
status,
|
||||
current: 2,
|
||||
total: 2,
|
||||
result: {
|
||||
episodeCount: 2,
|
||||
completedEpisodes: 1,
|
||||
skippedEpisodes: 0,
|
||||
failedEpisodes: 1,
|
||||
manualReviewRequired: true,
|
||||
episodes: [
|
||||
{ episodeNo: 1, status: 'completed' },
|
||||
{ episodeNo: 2, status: 'failed', error: '来源发生变化' }
|
||||
]
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
expect(wrapper.text()).toContain('已保存 1 集')
|
||||
expect(wrapper.text()).toContain('第 2 集 · 失败')
|
||||
expect(wrapper.text()).toContain('来源发生变化')
|
||||
expect(wrapper.findAllComponents(NTag).some(tag => tag.props('type') === 'success')).toBe(false)
|
||||
expect(wrapper.findAllComponents(ContextNotice).some(notice => notice.props('type') === 'success')).toBe(false)
|
||||
wrapper.unmount()
|
||||
})
|
||||
it.each([
|
||||
{ projectStatus: 'need_review', type: 'warning', role: 'alert' },
|
||||
{ projectStatus: 'completed', type: 'success', role: undefined },
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { imagePreviewFixture } from '../../fixtures/image-preview'
|
||||
import { preparationFixture } from '../storyboard-preparation/fixtures'
|
||||
import { generationProfile, imageCatalog } from '../../fixtures/generation'
|
||||
import { routerLinkStubs } from '../../fixtures/router'
|
||||
@@ -228,6 +229,7 @@ function context(): ReturnType<typeof useProjectData> {
|
||||
projectId: fixture.id,
|
||||
script: { ready: true, reason: null },
|
||||
breakdown: { ready: true, reason: null },
|
||||
preparation: { ready: true, reason: null },
|
||||
visualStyle: { ready: true, reason: null },
|
||||
identity: { ready: true, reason: null },
|
||||
subjectAssets: { ready: true, reason: null },
|
||||
@@ -452,8 +454,8 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
expect(openSettings).toHaveBeenCalledExactlyOnceWith('generation')
|
||||
}
|
||||
)
|
||||
it('当前主体已确认但其它角色未完成时,隐藏形态入口;保存后按新阶段状态开放', async () => {
|
||||
/** 当前主体已锁定,其它角色仍未确认,用真实项目准入规则约束页面入口。 */
|
||||
it('其它角色未完成不阻断当前主体形态准备,刷新后来源失效仍锁定入口', async () => {
|
||||
/** 已锁定主体可先准备自身素材;整体身份不齐不代替正式来源门禁。 */
|
||||
const saved = identityFixture({ isLocked: true })
|
||||
vi.spyOn(subjectIdentityApi, 'get').mockResolvedValue(saved)
|
||||
vi.spyOn(subjectIdentityApi, 'save').mockImplementation(async (_id, input) => ({ ...saved, ...input }))
|
||||
@@ -478,21 +480,21 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
const provided = await mountAssets('identity')
|
||||
provided.data.value!.stageReadiness.identity = { ready: false, reason: '还有角色身份需要确认' }
|
||||
await flushPromises()
|
||||
expect(wrapper!.get('.identity-next-action').text()).toContain('还有角色身份需要确认')
|
||||
expect(wrapper!.get('.identity-next-action').find('button').exists()).toBe(false)
|
||||
expect(wrapper!.get('.identity-subject-forms').text()).not.toContain('查看此主体形态图片')
|
||||
expect(wrapper!.find('a[href*="/subject-images"]').exists()).toBe(false)
|
||||
expect(wrapper!.get('.identity-next-action').text()).toContain('可以继续生成此主体的形态图片')
|
||||
expect(button('查看形态图片').disabled).toBe(false)
|
||||
expect(wrapper!.get('.identity-subject-forms').text()).toContain('查看此主体形态图片')
|
||||
expect(wrapper!.find('a[href*="/subject-images"]').exists()).toBe(true)
|
||||
vi.mocked(provided.refreshStageReadiness).mockImplementation(async () => {
|
||||
provided.data.value!.stageReadiness.identity = { ready: true, reason: null }
|
||||
provided.data.value!.stageReadiness.preparation = { ready: false, reason: '正式分镜来源已变化' }
|
||||
})
|
||||
await wrapper!.get('#identity-description').setValue('保存后仍保留已确认母版')
|
||||
button('保存主体身份').click()
|
||||
await flushPromises()
|
||||
expect(provided.refreshStageReadiness).toHaveBeenCalledOnce()
|
||||
expect(button('查看形态图片').disabled).toBe(false)
|
||||
expect(wrapper!.get('.identity-detail a[href*="/subject-images"]').attributes('href')).toContain(
|
||||
'subjectRef=@CH0001'
|
||||
)
|
||||
expect(wrapper!.get('.identity-next-action').text()).toContain('正式分镜来源已变化')
|
||||
expect(wrapper!.get('.identity-next-action').find('button').exists()).toBe(false)
|
||||
expect(wrapper!.find('.identity-detail a[href*="/subject-images"]').exists()).toBe(false)
|
||||
})
|
||||
|
||||
it('生成进度只在图库显示,失败详情按需查看,切换后不串主体状态', async () => {
|
||||
@@ -690,7 +692,7 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
button('重试读取').click()
|
||||
await flushPromises()
|
||||
expect(wrapper!.find('#style-prompt').exists()).toBe(true)
|
||||
expect(wrapper!.get('.visual-style-rules').text()).toContain('中国人物选角基线')
|
||||
expect(wrapper!.get('.visual-style-rules').text()).toContain('未明确时保持地域与族裔中性')
|
||||
expect(wrapper!.find('.n-collapse').exists()).toBe(false)
|
||||
expect(wrapper!.findAll('.style-category-fields textarea')).toHaveLength(3)
|
||||
})
|
||||
@@ -973,7 +975,7 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
await mountAssets('style')
|
||||
expect(wrapper!.text()).toContain('尚未创建')
|
||||
await expandSections()
|
||||
expect(wrapper!.text()).toContain('默认采用中国人物选角基线')
|
||||
expect(wrapper!.text()).toContain('未明确时保持地域与族裔中性')
|
||||
expect(wrapper!.text()).toContain('人物风格与选角背景')
|
||||
await wrapper!.get('#style-constraints').setValue('真人写实')
|
||||
await wrapper!.get('#style-lock').trigger('click')
|
||||
@@ -1149,7 +1151,7 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
})
|
||||
|
||||
it.each([true, false])(
|
||||
'身份图片校验按真实 passed=%s 反馈,等待时显示目标按钮加载,结果不驻留页面',
|
||||
'身份图片校验按真实 passed=%s 反馈,等待时显示目标按钮加载,结果按图片展示',
|
||||
async passed => {
|
||||
/** 延迟校验回执以覆盖请求期间的真实按钮状态。 */
|
||||
let finish!: (response: Response) => void
|
||||
@@ -1177,6 +1179,8 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
subjectId: 'subject-db-1',
|
||||
imageId: 'identity-image-1',
|
||||
passed,
|
||||
sourceRequirementsPassed: true,
|
||||
sourceVisualRequirements: [],
|
||||
summary: '本次视觉检查结果',
|
||||
issues: []
|
||||
})
|
||||
@@ -1185,10 +1189,10 @@ describe('视觉风格与主体身份工作区', () => {
|
||||
expect(getOperation(fixture.id)).toMatchObject({
|
||||
pending: false,
|
||||
noticeType: passed ? 'success' : 'warning',
|
||||
notice: `林知夏 的身份图片校验${passed ? '通过' : '未通过'}:本次视觉检查结果`
|
||||
notice: `林知夏 的身份图片校验${passed ? '通过' : '未通过或待复核'}:本次视觉检查结果`
|
||||
})
|
||||
expect(gallery.props('pendingOperation')).toBeNull()
|
||||
expect(wrapper!.text()).not.toContain('本次视觉检查结果')
|
||||
expect(wrapper!.text()).toContain('本次视觉检查结果')
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1531,6 +1535,7 @@ describe('工作台页面交互', () => {
|
||||
it('形态单图确认后发送正式 ID 并刷新候选图,不会调用 production/start', async () => {
|
||||
const form = formFixture()
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async (_url, init) => {
|
||||
if (String(_url).endsWith('/preview')) return jsonResponse(imagePreviewFixture())
|
||||
if (init?.method === 'POST') {
|
||||
const candidate = imageFixture({
|
||||
id: 'new-candidate',
|
||||
@@ -1547,14 +1552,19 @@ describe('工作台页面交互', () => {
|
||||
await mountSubjectImages()
|
||||
button('再生成一张').click()
|
||||
await flushPromises()
|
||||
button('预览实际生成输入').click()
|
||||
await flushPromises()
|
||||
document.querySelector<HTMLInputElement>('#confirm-image-cost')!.click()
|
||||
await flushPromises()
|
||||
button('确认生成图片').click()
|
||||
await flushPromises()
|
||||
const post = fetcher.mock.calls.find(([, init]) => init?.method === 'POST')!
|
||||
const post = fetcher.mock.calls.find(
|
||||
([url, init]) => init?.method === 'POST' && String(url).endsWith('/images')
|
||||
)!
|
||||
expect(post[0]).toBe('/api/subject-forms/form-db-1/images')
|
||||
expect(JSON.parse(post[1]!.body as string)).toEqual({
|
||||
setPrimary: false,
|
||||
expectedPreviewFingerprint: 'a'.repeat(64),
|
||||
provider: 'qwen-image',
|
||||
generationOptions: { size: '2048*2048' }
|
||||
})
|
||||
@@ -1619,7 +1629,7 @@ describe('工作台页面交互', () => {
|
||||
await flushPromises()
|
||||
expect(document.body.textContent).toContain('数据库异常')
|
||||
expect(wrapper!.find('.form-image-card img').exists()).toBe(true)
|
||||
await new DOMWrapper(button('刷新图片').closest('.app-dialog')!).get('.n-card-header__close').trigger('click')
|
||||
await new DOMWrapper(button('刷新图片').closest('.app-drawer')!).get('.n-drawer-header__close').trigger('click')
|
||||
await flushPromises()
|
||||
expect(button('补齐项目主参考图').disabled).toBe(true)
|
||||
})
|
||||
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
import type { SubjectImageGenerationPreview } from '@/features/subject-images/types'
|
||||
|
||||
/**
|
||||
* 构造完整的只读预览契约,仅供测试使用。
|
||||
* @param subjectFormId 测试形态编号
|
||||
* @returns 带来源版本的输入预览
|
||||
*/
|
||||
export function imagePreviewFixture(subjectFormId = 'form-db-1'): SubjectImageGenerationPreview {
|
||||
return {
|
||||
subjectFormId,
|
||||
provider: 'qwen-image',
|
||||
model: 'qwen-image-3.0-pro',
|
||||
providerPrompt: '当前完整画面描述',
|
||||
generationConfig: { options: { size: '2048*2048' } },
|
||||
previewFingerprint: 'a'.repeat(64),
|
||||
referenceImages: [],
|
||||
references: []
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user