feat: 同步精简接口并统一表单校验
This commit is contained in:
1 parent
82d7bde631
commit
2eea0ea72e
66 files changed
+1611
-1100
No files matched your search
@@ -1,4 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import AppForm from '../../components/ui/AppForm.vue'
|
||||
import { NFormItem } from 'naive-ui'
|
||||
import { integerRule } from '../../lib/form-rules'
|
||||
import WorkspacePage from '../../components/ui/WorkspacePage.vue'
|
||||
import ActionMenu from '../../components/ui/ActionMenu.vue'
|
||||
import DetailDisclosure from '../../components/ui/DetailDisclosure.vue'
|
||||
@@ -27,14 +30,13 @@ import {
|
||||
ArrowRight,
|
||||
LayoutGrid,
|
||||
Columns3,
|
||||
Settings2,
|
||||
AlertTriangle
|
||||
Settings2
|
||||
} 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 { coverImage, hasRunningImages, isPrimaryIdentityStale, primaryImage } from './model'
|
||||
import { coverImage, hasRunningImages, primaryImage } from './model'
|
||||
import type { GenerateFormImageInput, SubjectFormAsset } from './types'
|
||||
import GenerateImageDialog from './components/GenerateImageDialog.vue'
|
||||
import ImageGalleryDialog from './components/ImageGalleryDialog.vue'
|
||||
@@ -50,7 +52,6 @@ const router = useRouter()
|
||||
const {
|
||||
id,
|
||||
forms,
|
||||
staleForms,
|
||||
query,
|
||||
refreshProject,
|
||||
operation,
|
||||
@@ -60,15 +61,13 @@ const {
|
||||
limit,
|
||||
promptConcurrency,
|
||||
promptForce,
|
||||
concurrencyValid,
|
||||
generatePrompt,
|
||||
generatePrompts,
|
||||
blocked,
|
||||
running,
|
||||
batchValid,
|
||||
generate,
|
||||
generateProject,
|
||||
generateStale
|
||||
generateProject
|
||||
} = useSubjectImages()
|
||||
const sourceShotId = computed(() => queryText(route.query.sourceShotId))
|
||||
const targetFormId = computed(() => queryText(route.query.subjectFormId))
|
||||
@@ -149,12 +148,11 @@ const search = ref('')
|
||||
const layout = ref<GalleryLayout>('grid')
|
||||
const module = ref('all')
|
||||
/** 形态图片状态筛选;单选下拉避免移动端复选项占据两行。 */
|
||||
type ImageStatusFilter = 'all' | 'missing' | 'stale'
|
||||
type ImageStatusFilter = 'all' | 'missing'
|
||||
const statusFilter = ref<ImageStatusFilter>('all')
|
||||
const statusFilterOptions: Array<{ label: string; value: ImageStatusFilter }> = [
|
||||
{ label: '全部状态', value: 'all' },
|
||||
{ label: '缺少主图', value: 'missing' },
|
||||
{ label: '身份过期', value: 'stale' }
|
||||
{ label: '缺少主图', value: 'missing' }
|
||||
]
|
||||
/** 保存每张卡片的尺寸观察器,切换回网格时及时释放。 */
|
||||
const masonryCardObservers = new WeakMap<HTMLElement, ResizeObserver>()
|
||||
@@ -241,7 +239,6 @@ const filtered = computed(() =>
|
||||
(!targetFormId.value || form.id === targetFormId.value) &&
|
||||
(module.value === 'all' || form.subject.module === module.value) &&
|
||||
(statusFilter.value !== 'missing' || !primaryImage(form.images)) &&
|
||||
(statusFilter.value !== 'stale' || isPrimaryIdentityStale(form)) &&
|
||||
`${form.subject.name} ${form.subject.ref} ${form.name}`
|
||||
.toLowerCase()
|
||||
.includes(search.value.trim().toLowerCase())
|
||||
@@ -305,16 +302,8 @@ function selectImpactShot(shotId: string | null) {
|
||||
async function refreshAssets() {
|
||||
await Promise.all([refreshProject(), query.refresh(), impact.query.refresh(), impact.references.refresh()])
|
||||
}
|
||||
|
||||
/** 全局过期筛选不沿用深链接的单个素材限制。 */
|
||||
async function showStaleForms() {
|
||||
await router.replace({
|
||||
query: { ...route.query, subjectFormId: undefined, subjectRef: undefined, sourceShotId: undefined }
|
||||
})
|
||||
search.value = ''
|
||||
module.value = 'all'
|
||||
statusFilter.value = 'stale'
|
||||
}
|
||||
const formModel = computed(() => ({ concurrency: concurrency.value, limit: limit.value }))
|
||||
const rules = { concurrency: integerRule('批量并发'), limit: integerRule('本批上限', 1, true) }
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -340,7 +329,7 @@ async function showStaleForms() {
|
||||
</div>
|
||||
<DetailDisclosure title="母版继承与过期处理" class="mt-4">
|
||||
人物、场景、道具形态图均可继承已锁定 Identity
|
||||
的母版,并记录本次引用来源。母版变化后可筛选过期图,重新生成候选并人工确认新的主参考图;不要直接沿用旧资产进入下游。
|
||||
的母版。母版变化后请核对形态图,按需生成候选并确认主图。当前图库不提供历史母版引用,无法自动判断形态图是否过期;下游状态以镜头就绪检查为准。
|
||||
<RouterLink :to="`/projects/${id}/subject-identity`" class="text-button ml-2"
|
||||
>管理主体身份 →</RouterLink
|
||||
></DetailDisclosure
|
||||
@@ -358,76 +347,61 @@ async function showStaleForms() {
|
||||
<div class="flex flex-wrap items-center justify-between gap-4">
|
||||
<p class="text-sm">
|
||||
<strong>{{ completeCount }}</strong> / {{ forms.length }} 个形态已有主图
|
||||
<span v-if="staleForms.length" class="ml-3 text-xs text-danger">
|
||||
{{ staleForms.length }} 个形态主图已过期
|
||||
</span>
|
||||
<span class="ml-3 text-xs text-muted">图片模型 · 后端配置</span>
|
||||
</p>
|
||||
</div>
|
||||
<p class="mt-2 text-[11px] leading-6 text-muted">
|
||||
图库不自动刷新,可点击“刷新图库”读取最新记录。主图供分镜引用,候选图和历史失败记录均保留;过期主图不会自动删除或替换。
|
||||
</p>
|
||||
<NAlert v-if="staleForms.length" type="error" :show-icon="false" class="mt-4"
|
||||
><div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<span class="flex items-center gap-2 text-xs">
|
||||
<AlertTriangle :size="14" />检测到 {{ staleForms.length }} 个形态 仍在使用旧 Identity
|
||||
Anchor。
|
||||
</span>
|
||||
<ConfirmAction
|
||||
label="重新生成过期形态"
|
||||
:disabled="blocked || !concurrencyValid || !staleForms.length"
|
||||
acknowledgement
|
||||
description="只为身份母版已经变化的形态调用 图片模型,各新增一张基于当前已锁定母版的候选图;不会自动替换旧主图,生成后请人工确认并设置新的主参考图。"
|
||||
@confirm="generateStale"
|
||||
/></div
|
||||
></NAlert>
|
||||
<NCollapse class="mt-4 pt-4"
|
||||
><NCollapseItem name="details"
|
||||
><template #header>项目批量生图</template>
|
||||
<div class="mt-4 flex flex-wrap items-end gap-4">
|
||||
<label class="w-28">
|
||||
<span class="field-label">批量并发</span>
|
||||
<NInputNumber
|
||||
<AppForm :model="formModel" :rules="rules" :disabled="operation.pending" validate-on-change>
|
||||
<div class="form-controls mt-4 flex flex-wrap gap-4">
|
||||
<NFormItem
|
||||
class="w-28"
|
||||
path="concurrency"
|
||||
label="批量并发"
|
||||
:label-props="{ for: 'image-concurrency' }"
|
||||
>
|
||||
<NInputNumber
|
||||
:disabled="operation.pending"
|
||||
:input-props="{ id: 'image-concurrency' }"
|
||||
:value="typeof concurrency === 'number' ? concurrency : null"
|
||||
@update:value="concurrency = $event ?? 0"
|
||||
:min="1"
|
||||
:step="1"
|
||||
></NInputNumber>
|
||||
</NFormItem>
|
||||
<NFormItem class="w-36" path="limit" label="本批上限(可选)"
|
||||
><NInputNumber
|
||||
:disabled="operation.pending"
|
||||
:value="typeof limit === 'number' ? limit : null"
|
||||
@update:value="limit = $event ?? ''"
|
||||
:min="1"
|
||||
:step="1"
|
||||
placeholder="不限制"
|
||||
:input-props="{ 'aria-label': '生图本批上限' }"
|
||||
/></NFormItem>
|
||||
<NCheckbox
|
||||
v-model:checked="force"
|
||||
:disabled="operation.pending"
|
||||
:input-props="{ id: 'image-concurrency' }"
|
||||
:value="typeof concurrency === 'number' ? concurrency : null"
|
||||
@update:value="concurrency = $event ?? 0"
|
||||
:min="1"
|
||||
:step="1"
|
||||
></NInputNumber>
|
||||
</label>
|
||||
<label class="w-36"
|
||||
><span class="field-label">本批上限(可选)</span
|
||||
><NInputNumber
|
||||
:disabled="operation.pending"
|
||||
:value="typeof limit === 'number' ? limit : null"
|
||||
@update:value="limit = $event ?? ''"
|
||||
:min="1"
|
||||
:step="1"
|
||||
placeholder="不限制"
|
||||
:input-props="{ 'aria-label': '生图本批上限' }"
|
||||
/></label>
|
||||
<NCheckbox
|
||||
v-model:checked="force"
|
||||
:disabled="operation.pending"
|
||||
class="control-row-checkbox text-xs"
|
||||
>已有主图也新增候选图
|
||||
</NCheckbox>
|
||||
<ConfirmAction
|
||||
:label="force ? '为全项目新增候选图' : '补齐项目主参考图'"
|
||||
:disabled="blocked || !batchValid || !forms.length"
|
||||
acknowledgement
|
||||
:description="
|
||||
force
|
||||
? '对项目全部形态调用图片模型新增一张图片。已有主图不会被替换,生成后可在图片记录中手动选择主图。'
|
||||
: '仅对没有主图的形态调用图片模型生图,已有主图的形态跳过。操作面向整个项目,不受列表筛选影响。'
|
||||
"
|
||||
@confirm="generateProject"
|
||||
/>
|
||||
</div>
|
||||
<p v-if="!batchValid" class="mt-2 text-xs text-danger">
|
||||
并发和填写的数量上限必须是正整数。
|
||||
</p>
|
||||
class="control-row-checkbox text-xs"
|
||||
>已有主图也新增候选图
|
||||
</NCheckbox>
|
||||
<ConfirmAction
|
||||
:label="force ? '为全项目新增候选图' : '补齐项目主参考图'"
|
||||
:disabled="blocked || !batchValid || !forms.length"
|
||||
acknowledgement
|
||||
:description="
|
||||
force
|
||||
? '对项目全部形态调用图片模型新增一张图片。已有主图不会被替换,生成后可在图片记录中手动选择主图。'
|
||||
: '仅对没有主图的形态调用图片模型生图,已有主图的形态跳过。操作面向整个项目,不受列表筛选影响。'
|
||||
"
|
||||
@confirm="generateProject"
|
||||
/>
|
||||
</div>
|
||||
</AppForm>
|
||||
<p class="mt-3 text-xs leading-6 text-muted">
|
||||
作用于整个项目,不受下方筛选影响。上限只限制本次真正生图数量,其余显示为“待后续处理”,不计入跳过。默认使用后端尺寸与正式提示词,不会启动视频生成。
|
||||
</p></NCollapseItem
|
||||
@@ -457,14 +431,6 @@ async function showStaleForms() {
|
||||
>
|
||||
部分形态生图失败。已生成的图片保留;先查看失败原因,再按形态重新生图。
|
||||
</NAlert>
|
||||
<NAlert
|
||||
v-else-if="session.receipt.title === '刷新过期形态图'"
|
||||
type="info"
|
||||
:show-icon="false"
|
||||
class="mt-3 text-xs"
|
||||
>
|
||||
新图当前仍是候选图。请进入对应形态的“查看图片与记录”,确认人物身份和造型后再设为主参考图;旧主图在此之前仍保持过期状态。
|
||||
</NAlert>
|
||||
<ul class="mt-3 space-y-2 text-xs text-danger">
|
||||
<li v-for="failure in session.receipt.result.failures" :key="failure.subjectFormId">
|
||||
<code>{{ failure.subjectFormId }}</code
|
||||
@@ -477,11 +443,6 @@ async function showStaleForms() {
|
||||
</section>
|
||||
</WorkspaceTools>
|
||||
<!-- 关联说明、筛选和图片共用正文滚动区,避免镜头切换时两块滚动区域高度不同步。 -->
|
||||
<NAlert v-if="staleForms.length" type="error" :show-icon="false" class="mt-3" title="形态主图需要更新">
|
||||
{{ staleForms.length }}
|
||||
个形态主图与当前已锁定身份母版不一致。请生成候选、验图并切换主图,再重建相关首帧。
|
||||
<NButton text size="small" @click="showStaleForms">筛选身份过期形态</NButton>
|
||||
</NAlert>
|
||||
<NAlert
|
||||
v-if="impact.stale.value.length"
|
||||
type="warning"
|
||||
@@ -730,7 +691,6 @@ async function showStaleForms() {
|
||||
:key="form.id"
|
||||
class="panel form-image-card"
|
||||
:class="{
|
||||
'ring-1 ring-danger': isPrimaryIdentityStale(form),
|
||||
'form-image-card-focused': targetFormId === form.id
|
||||
}"
|
||||
:data-form-id="form.id"
|
||||
@@ -755,9 +715,6 @@ async function showStaleForms() {
|
||||
</p>
|
||||
<div class="mt-3 flex flex-wrap items-center gap-2">
|
||||
<StatusBadge v-if="hasRunningImages(form.images)" status="generating" />
|
||||
<NTag v-if="isPrimaryIdentityStale(form)" size="small" :bordered="false"
|
||||
>身份母版已变更</NTag
|
||||
>
|
||||
<NTag v-else-if="primaryImage(form.images)" size="small" :bordered="false">主参考图</NTag>
|
||||
<NTag v-else-if="coverImage(form)" size="small" :bordered="false">候选图 · 尚未设主图</NTag>
|
||||
<span v-else-if="form.images[0]?.status === 'failed'" class="text-xs text-danger"
|
||||
@@ -765,15 +722,6 @@ async function showStaleForms() {
|
||||
>
|
||||
<span class="text-[10px] text-muted">{{ form.images.length }} 条记录</span>
|
||||
</div>
|
||||
<NAlert
|
||||
v-if="isPrimaryIdentityStale(form)"
|
||||
type="error"
|
||||
:show-icon="false"
|
||||
class="mt-3 text-xs leading-6"
|
||||
>
|
||||
当前主图未能匹配最新已锁定母版。请基于当前 Identity Anchor
|
||||
重新生成候选图,并在确认后设置为新的主参考图。
|
||||
</NAlert>
|
||||
<NAlert
|
||||
v-if="
|
||||
sourceShot?.primaryKeyframeStale &&
|
||||
@@ -789,9 +737,7 @@ async function showStaleForms() {
|
||||
{{
|
||||
sourceShot.inconsistent
|
||||
? '后端首帧与视频检查结果不一致,请先核对,不要据此重复生图。'
|
||||
: isPrimaryIdentityStale(form)
|
||||
? '请先更新该形态主图,再重建首帧。'
|
||||
: '关联不等于本素材失效;核对形态主图与身份母版,确认无误后只需重建首帧。'
|
||||
: '关联不等于本素材失效;核对形态主图与身份母版,确认无误后只需重建首帧。'
|
||||
}}
|
||||
<RouterLink v-if="sourceLocation" :to="sourceLocation" class="text-button mt-2"
|
||||
>返回该镜头处理 →</RouterLink
|
||||
@@ -818,14 +764,7 @@ async function showStaleForms() {
|
||||
"
|
||||
/>
|
||||
<NButton :disabled="blocked" @click="openGenerate(form)"
|
||||
><ImagePlus :size="14" />
|
||||
{{
|
||||
isPrimaryIdentityStale(form)
|
||||
? '基于当前母版重新生成'
|
||||
: coverImage(form)
|
||||
? '再生成一张'
|
||||
: '生成图片'
|
||||
}}</NButton
|
||||
><ImagePlus :size="14" /> {{ coverImage(form) ? '再生成一张' : '生成图片' }}</NButton
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import AppForm from '../../../components/ui/AppForm.vue'
|
||||
import { NFormItem } from 'naive-ui'
|
||||
import { integerRule } from '../../../lib/form-rules'
|
||||
import { computed } from 'vue'
|
||||
import { NAlert, NButton, NCheckbox, NInputNumber } from 'naive-ui'
|
||||
import { downloadText } from '../../../lib/format'
|
||||
@@ -22,6 +25,8 @@ const valid = computed(() => Number.isSafeInteger(concurrency.value) && concurre
|
||||
function exportReceipt() {
|
||||
downloadText('form-prompts-receipt.json', JSON.stringify(props.receipt, null, 2), 'application/json')
|
||||
}
|
||||
const formModel = computed(() => ({ concurrency: concurrency.value }))
|
||||
const rules = { concurrency: integerRule('提示词并发') }
|
||||
</script>
|
||||
<template>
|
||||
<section class="panel mt-5 p-5" aria-label="形态提示词批量管理">
|
||||
@@ -30,34 +35,34 @@ function exportReceipt() {
|
||||
正式提示词 {{ complete }} /
|
||||
{{ forms.length }}。结合项目视觉风格生成,只保存文本,不自动生图。批量面向全项目,不受搜索筛选影响。
|
||||
</p>
|
||||
<div class="mt-4 flex flex-wrap items-end gap-4">
|
||||
<label class="w-28"
|
||||
><span class="field-label">提示词并发</span>
|
||||
<NInputNumber
|
||||
:disabled="pending"
|
||||
:value="concurrency"
|
||||
@update:value="concurrency = $event ?? 0"
|
||||
:min="1"
|
||||
:step="1"
|
||||
:input-props="{ 'aria-label': '提示词并发' }"
|
||||
<AppForm :model="formModel" :rules="rules" :disabled="pending" validate-on-change v-slot="{ validate }">
|
||||
<div class="form-controls mt-4 flex flex-wrap gap-4">
|
||||
<NFormItem class="w-28" path="concurrency" label="提示词并发">
|
||||
<NInputNumber
|
||||
:disabled="pending"
|
||||
:value="concurrency"
|
||||
@update:value="concurrency = $event ?? 0"
|
||||
:min="1"
|
||||
:step="1"
|
||||
:input-props="{ 'aria-label': '提示词并发' }"
|
||||
/>
|
||||
</NFormItem>
|
||||
<NCheckbox v-model:checked="force" :disabled="pending" class="control-row-checkbox text-xs"
|
||||
>覆盖已有正式提示词</NCheckbox
|
||||
>
|
||||
<ConfirmAction
|
||||
:label="force ? '重生成全部形态提示词' : '补齐形态提示词'"
|
||||
:disabled="disabled || !valid || !forms.length || (!force && complete === forms.length)"
|
||||
acknowledgement
|
||||
:description="
|
||||
force
|
||||
? '调用文本模型重新生成全项目形态的正式提示词,覆盖原有文本;已有图片和主图不变。'
|
||||
: '调用文本模型补齐缺少正式提示词的形态,已有正式提示词跳过;不会自动生成图片。'
|
||||
"
|
||||
@confirm="validate(() => emit('generate'))"
|
||||
/>
|
||||
</label>
|
||||
<NCheckbox v-model:checked="force" :disabled="pending" class="control-row-checkbox text-xs"
|
||||
>覆盖已有正式提示词</NCheckbox
|
||||
>
|
||||
<ConfirmAction
|
||||
:label="force ? '重生成全部形态提示词' : '补齐形态提示词'"
|
||||
:disabled="disabled || !valid || !forms.length || (!force && complete === forms.length)"
|
||||
acknowledgement
|
||||
:description="
|
||||
force
|
||||
? '调用文本模型重新生成全项目形态的正式提示词,覆盖原有文本;已有图片和主图不变。'
|
||||
: '调用文本模型补齐缺少正式提示词的形态,已有正式提示词跳过;不会自动生成图片。'
|
||||
"
|
||||
@confirm="emit('generate')"
|
||||
/>
|
||||
</div>
|
||||
<p v-if="!valid" class="mt-2 text-xs text-danger">提示词并发必须是正整数。</p>
|
||||
</div>
|
||||
</AppForm>
|
||||
<section v-if="receipt" class="surface-inset mt-4 p-4" aria-label="提示词批量回执">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<h4>{{ receipt.title }}</h4>
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import AppForm from '../../../components/ui/AppForm.vue'
|
||||
import { NFormItem } from 'naive-ui'
|
||||
import { sizeRules } from '../../../lib/form-rules'
|
||||
import { NAlert, NButton, NCheckbox, NCollapse, NCollapseItem, NInput, NInputNumber } from 'naive-ui'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { AppDialog } from '../../../components/ui'
|
||||
@@ -39,6 +42,8 @@ function submit() {
|
||||
})
|
||||
open.value = false
|
||||
}
|
||||
const formModel = computed(() => ({ width: width.value, height: height.value, prompt: prompt.value }))
|
||||
const rules = { ...sizeRules(() => formModel.value) }
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -47,7 +52,15 @@ function submit() {
|
||||
title="生成形态图片"
|
||||
:description="`${form?.subject.name || ''} · ${form?.name || ''}`"
|
||||
>
|
||||
<form class="mt-6 space-y-5" @submit.prevent="submit">
|
||||
<AppForm
|
||||
:model="formModel"
|
||||
:rules="rules"
|
||||
:disabled="disabled"
|
||||
:reset-key="`${open}:${form?.id}`"
|
||||
validate-on-change
|
||||
class="mt-6 space-y-5"
|
||||
@submit="submit"
|
||||
>
|
||||
<NAlert type="info" :show-icon="false" class="text-xs"
|
||||
>使用后端配置的图片模型,可能产生费用。每次新增一张图片,不删除历史结果。</NAlert
|
||||
>
|
||||
@@ -55,8 +68,11 @@ function submit() {
|
||||
人物、场景、道具均会引用已锁定身份的当前母版,保持身份、空间骨架或物件结构;身份未锁定或没有母版时不会继承该图片。更换母版不会自动更新已有形态图。
|
||||
身份母版与此处的“形态主参考图”是两种不同用途的图片。
|
||||
</p>
|
||||
<label class="block"
|
||||
><span class="field-label">自定义提示词(可选,仅用于本次)</span
|
||||
<NFormItem
|
||||
class="block"
|
||||
path="prompt"
|
||||
label="自定义提示词(可选,仅用于本次)"
|
||||
:label-props="{ for: 'image-prompt' }"
|
||||
><NInput
|
||||
placeholder="留空使用正式 generationPrompt;缺失时后端先自动生成正式提示词"
|
||||
:input-props="{ id: 'image-prompt' }"
|
||||
@@ -65,7 +81,7 @@ function submit() {
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 3, maxRows: 12 }"
|
||||
></NInput>
|
||||
</label>
|
||||
</NFormItem>
|
||||
<NCollapse v-if="form?.generationPrompt || form?.appearancePrompt" class="text-xs"
|
||||
><NCollapseItem name="details"
|
||||
><template #header>{{
|
||||
@@ -77,8 +93,7 @@ function submit() {
|
||||
></NCollapse
|
||||
>
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<label
|
||||
><span class="field-label">宽度(px)</span
|
||||
<NFormItem path="width" label="宽度(px)" :label-props="{ for: 'image-width' }"
|
||||
><NInputNumber
|
||||
placeholder="后端默认"
|
||||
:input-props="{ id: 'image-width' }"
|
||||
@@ -86,9 +101,8 @@ function submit() {
|
||||
@update:value="width = $event ?? ''"
|
||||
:min="1"
|
||||
:step="1"
|
||||
></NInputNumber></label
|
||||
><label
|
||||
><span class="field-label">高度(px)</span
|
||||
></NInputNumber></NFormItem
|
||||
><NFormItem path="height" label="高度(px)" :label-props="{ for: 'image-height' }"
|
||||
><NInputNumber
|
||||
placeholder="后端默认"
|
||||
:input-props="{ id: 'image-height' }"
|
||||
@@ -97,10 +111,9 @@ function submit() {
|
||||
:min="1"
|
||||
:step="1"
|
||||
></NInputNumber
|
||||
></label>
|
||||
></NFormItem>
|
||||
</div>
|
||||
<p class="text-xs text-muted">宽高同时留空时使用后端默认 2K;自定义尺寸须满足模型限制。</p>
|
||||
<p v-if="!dimensionsValid" class="text-xs text-danger" role="alert">宽高需要同时填写正整数,或同时留空。</p>
|
||||
<p v-if="!form?.generationPrompt" class="text-xs leading-6 text-muted">
|
||||
未填写自定义提示词时,后端先调用文本模型补齐正式提示词,再生图;可能产生两类模型费用。原始外观素材不会直接作为最终生图提示词。
|
||||
</p>
|
||||
@@ -124,6 +137,6 @@ function submit() {
|
||||
确认生成图片
|
||||
</NButton>
|
||||
</div>
|
||||
</form>
|
||||
</AppForm>
|
||||
</AppDialog>
|
||||
</template>
|
||||
@@ -1,15 +1,14 @@
|
||||
<script setup lang="ts">
|
||||
import { NScrollbar, NAlert, NButton, NCollapse, NCollapseItem, NTag } from 'naive-ui'
|
||||
import { NScrollbar, NAlert, NButton, NTag } from 'naive-ui'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { ExternalLink, RefreshCw } from '@lucide/vue'
|
||||
import { AppDialog, AssetImage, StatusBadge } from '../../../components/ui'
|
||||
import { usePolling } from '../../../composables/usePolling'
|
||||
import { referenceImageUrl } from '../../../lib/assets'
|
||||
import { formatDate } from '../../../lib/format'
|
||||
import { readImageProvenance } from '../../subject-identity'
|
||||
import { getOperation, runOperation } from '../../workflows/operations'
|
||||
import { subjectImagesApi } from '../api'
|
||||
import { hasRunningImages, primaryImage } from '../model'
|
||||
import { hasRunningImages, primaryImage, currentIdentityAnchorId } from '../model'
|
||||
import type { SubjectFormAsset } from '../types'
|
||||
|
||||
/** 形态图片历史与主图选择;历史查询只在弹窗打开时进行。 */
|
||||
@@ -186,22 +185,9 @@ async function choosePrimary() {
|
||||
><NButton @click="confirming = false" text size="small">取消</NButton>
|
||||
</div></NAlert
|
||||
>
|
||||
<NCollapse v-if="selected.prompt" class="mt-4 text-xs"
|
||||
><NCollapseItem name="details"
|
||||
><template #header>查看本次实际提示词</template>
|
||||
<p class="mt-3 whitespace-pre-wrap leading-6">{{ selected.prompt }}</p>
|
||||
<p v-if="selected.negativePrompt" class="mt-3 whitespace-pre-wrap leading-6">
|
||||
Negative prompt: {{ selected.negativePrompt }}
|
||||
</p></NCollapseItem
|
||||
></NCollapse
|
||||
>
|
||||
<p class="mt-3 break-all font-mono text-[10px] text-muted">Image ID · {{ selected.id }}</p>
|
||||
<p class="mt-2 break-all text-[11px] text-muted">
|
||||
{{
|
||||
readImageProvenance(selected.rawJson).identityAnchorImageId
|
||||
? `本次引用身份母版 ID:${readImageProvenance(selected.rawJson).identityAnchorImageId}`
|
||||
: '此记录未提供身份母版来源,不能据此判断是否使用了当前母版。'
|
||||
}}
|
||||
<p v-if="form && currentIdentityAnchorId(form)" class="mt-2 break-all text-[11px] text-muted">
|
||||
当前已锁定身份母版 ID:{{ currentIdentityAnchorId(form) }}
|
||||
</p>
|
||||
</div>
|
||||
<p v-else class="py-10 text-center text-sm text-muted">
|
||||
|
||||
@@ -21,29 +21,7 @@ export function coverImage(form: SubjectFormAsset): SubjectImage | undefined {
|
||||
|
||||
/** 当前主体正在使用的 Identity Anchor ID。 */
|
||||
export function currentIdentityAnchorId(form: SubjectFormAsset): string | undefined {
|
||||
return form.subject.identity?.isLocked ? form.subject.identity.images[0]?.id : undefined
|
||||
}
|
||||
|
||||
/** 读取形态图生成时实际使用的 Identity Anchor ID。 */
|
||||
export function imageIdentityAnchorId(image: SubjectImage | undefined): string | undefined {
|
||||
if (!image?.rawJson) return undefined
|
||||
try {
|
||||
const raw = JSON.parse(image.rawJson) as { identityAnchorImageId?: unknown }
|
||||
return typeof raw.identityAnchorImageId === 'string' ? raw.identityAnchorImageId : undefined
|
||||
} catch {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前主形态图是否由旧 Identity Anchor 生成。
|
||||
* 有当前 Anchor 但旧图没有追溯 ID,也按过期处理,避免历史图片继续进入后续 Keyframe。
|
||||
*/
|
||||
export function isPrimaryIdentityStale(form: SubjectFormAsset): boolean {
|
||||
const anchorId = currentIdentityAnchorId(form)
|
||||
const primary = primaryImage(form.images)
|
||||
if (!anchorId || !primary) return false
|
||||
return imageIdentityAnchorId(primary) !== anchorId
|
||||
return form.subject.identity?.isLocked ? (form.subject.identity.anchorImageId ?? undefined) : undefined
|
||||
}
|
||||
|
||||
/** 查询发现后台仍在运行时也阻止重复提交,不只依赖本地 loading。 */
|
||||
|
||||
@@ -15,7 +15,6 @@ export function imageFixture(overrides: Partial<SubjectImage> = {}): SubjectImag
|
||||
error: null,
|
||||
createdAt: '2026-08-28T08:00:00Z',
|
||||
updatedAt: '2026-08-28T08:00:00Z',
|
||||
prompt: '<script>模型提示词</script>',
|
||||
...overrides
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,18 +15,13 @@ export interface SubjectImage {
|
||||
error: string | null
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
/** 详情查询才返回实际使用的 Prompt;列表不包含长文本。 */
|
||||
prompt?: string
|
||||
negativePrompt?: string | null
|
||||
/** 形态图生成追溯信息,包含当时使用的 Identity Anchor ID。 */
|
||||
rawJson?: string | null
|
||||
}
|
||||
|
||||
/** 当前主体 Identity 只暴露形态图库判断新旧母版所需的轻量信息。 */
|
||||
/** 当前主体 Identity 的公开摘要;只说明当前母版,不包含图片的历史引用。 */
|
||||
export interface SubjectFormIdentitySummary {
|
||||
id: string
|
||||
isLocked: boolean
|
||||
images: { id: string }[]
|
||||
anchorImageId: string | null
|
||||
}
|
||||
|
||||
/** 正式 SubjectForm 及其所属主体、图片,不使用 checkpoint 的领域 formId。 */
|
||||
@@ -79,7 +74,10 @@ export interface ImageBatchResult {
|
||||
}
|
||||
|
||||
/** 正式提示词生成只返回形态字段,不包含图库列表的 images 关联。 */
|
||||
export type FormPromptResult = Pick<SubjectFormAsset, 'id' | 'subjectId' | 'generationPrompt'>
|
||||
export type FormPromptResult = Omit<SubjectFormAsset, 'subject' | 'images'> & {
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
/** 项目提示词增强的批量参数,与图片生成的 force、limit 独立。 */
|
||||
export interface GenerateFormPromptsInput {
|
||||
|
||||
@@ -5,8 +5,8 @@ import { useProjectContext } from '../projects/context'
|
||||
import { getOperation, runOperation } from '../workflows/operations'
|
||||
import { workflowCheckpoints } from '../workflows/selectors'
|
||||
import { subjectImagesApi } from './api'
|
||||
import { getImageSession, hasRunningImages, isPrimaryIdentityStale } from './model'
|
||||
import type { GenerateFormImageInput, SubjectFormAsset } from './types'
|
||||
import { getImageSession, hasRunningImages } from './model'
|
||||
import type { GenerateFormImageInput } from './types'
|
||||
|
||||
/** 形态图库统一读取数据库记录并管理单图/批量长请求,不调用生产流程。 */
|
||||
export function useSubjectImages() {
|
||||
@@ -44,7 +44,6 @@ export function useSubjectImages() {
|
||||
false
|
||||
)
|
||||
const forms = computed(() => query.data.value ?? [])
|
||||
const staleForms = computed(() => forms.value.filter(form => isPrimaryIdentityStale(form)))
|
||||
const operation = computed(() => getOperation(id.value))
|
||||
const session = computed(() => getImageSession(id.value))
|
||||
const running = computed(() => forms.value.some(form => hasRunningImages(form.images)))
|
||||
@@ -138,59 +137,9 @@ export function useSubjectImages() {
|
||||
await query.refresh()
|
||||
}
|
||||
|
||||
/**
|
||||
* 只刷新 Identity Anchor 已变化的形态,覆盖人物、场景与道具。
|
||||
* 与确认文案一致:仅生成候选,用户验图后再显式切换主图。
|
||||
*/
|
||||
async function generateStale() {
|
||||
if (blocked.value || !concurrencyValid.value || !staleForms.value.length) return
|
||||
const projectId = id.value
|
||||
const targets = [...staleForms.value]
|
||||
const total = forms.value.length
|
||||
const receipt = getImageSession(projectId)
|
||||
receipt.receipt = null
|
||||
|
||||
await runOperation(projectId, '刷新过期形态图', async () => {
|
||||
const results = await runWithConcurrency(targets, concurrency.value, async form => {
|
||||
try {
|
||||
const image = await subjectImagesApi.generate(form.id, {
|
||||
setPrimary: false
|
||||
})
|
||||
if (!image || image.subjectFormId !== form.id || image.status !== 'completed' || !image.imageUrl) {
|
||||
throw new Error(image?.error || '接口未返回已完成的候选图')
|
||||
}
|
||||
return { subjectFormId: form.id, success: true as const }
|
||||
} catch (error) {
|
||||
return {
|
||||
subjectFormId: form.id,
|
||||
success: false as const,
|
||||
error: error instanceof Error ? error.message : String(error)
|
||||
}
|
||||
}
|
||||
})
|
||||
const failures = results
|
||||
.filter(item => !item.success)
|
||||
.map(item => ({ subjectFormId: item.subjectFormId, error: item.error }))
|
||||
|
||||
receipt.receipt = {
|
||||
title: '刷新过期形态图',
|
||||
result: {
|
||||
total,
|
||||
targetCount: targets.length,
|
||||
generated: results.filter(item => item.success).length,
|
||||
skipped: total - targets.length,
|
||||
failed: failures.length,
|
||||
failures
|
||||
}
|
||||
}
|
||||
})
|
||||
await query.refresh()
|
||||
}
|
||||
|
||||
return {
|
||||
id,
|
||||
forms,
|
||||
staleForms,
|
||||
query,
|
||||
refreshProject: context.refresh,
|
||||
operation,
|
||||
@@ -208,31 +157,6 @@ export function useSubjectImages() {
|
||||
running,
|
||||
batchValid,
|
||||
generate,
|
||||
generateProject,
|
||||
generateStale
|
||||
generateProject
|
||||
}
|
||||
}
|
||||
|
||||
/** 使用固定并发数执行需要付费的单形态生图请求。 */
|
||||
async function runWithConcurrency<TResult>(
|
||||
items: SubjectFormAsset[],
|
||||
concurrency: number,
|
||||
handler: (item: SubjectFormAsset) => Promise<TResult>
|
||||
): Promise<TResult[]> {
|
||||
const results: TResult[] = []
|
||||
let currentIndex = 0
|
||||
|
||||
async function worker() {
|
||||
while (currentIndex < items.length) {
|
||||
const index = currentIndex
|
||||
currentIndex += 1
|
||||
const item = items[index]
|
||||
if (!item) continue
|
||||
results[index] = await handler(item)
|
||||
}
|
||||
}
|
||||
|
||||
const workers = Array.from({ length: Math.min(concurrency, items.length) }, () => worker())
|
||||
await Promise.all(workers)
|
||||
return results
|
||||
}
|
||||
Reference in new issue
Block a user