feat: 对齐后端能力并补齐形态提示词与生产诊断
This commit is contained in:
1 parent
7d8074f90e
commit
f71d2bf0a4
30 files changed
+1707
-66
No files matched your search
@@ -14,6 +14,9 @@ export function useSubjectImages() {
|
||||
const id = computed(() => context.project.value?.id ?? '')
|
||||
const concurrency = ref(2)
|
||||
const force = ref(false)
|
||||
const limit = ref<number | ''>('')
|
||||
const promptConcurrency = ref(3)
|
||||
const promptForce = ref(false)
|
||||
const query = usePolling(id, async (projectId, signal) => {
|
||||
if (!projectId) return []
|
||||
try {
|
||||
@@ -54,9 +57,48 @@ export function useSubjectImages() {
|
||||
query.data.value === null ||
|
||||
running.value ||
|
||||
breakdownRunning.value ||
|
||||
context.project.value?.status === 'generating'
|
||||
context.project.value?.status !== 'completed'
|
||||
)
|
||||
const batchValid = computed(() => Number.isSafeInteger(concurrency.value) && concurrency.value > 0)
|
||||
const concurrencyValid = computed(() => Number.isSafeInteger(concurrency.value) && concurrency.value > 0)
|
||||
const batchValid = computed(
|
||||
() => concurrencyValid.value && (limit.value === '' || (Number.isSafeInteger(limit.value) && limit.value > 0))
|
||||
)
|
||||
const promptValid = computed(() => Number.isSafeInteger(promptConcurrency.value) && promptConcurrency.value > 0)
|
||||
|
||||
/** 单个提示词保存后重读正式形态,不把详情响应误用作图库列表。 */
|
||||
async function generatePrompt(formId: string, overwrite: boolean) {
|
||||
if (blocked.value) return
|
||||
const form = forms.value.find(item => item.id === formId)
|
||||
if (!form) return
|
||||
const projectId = id.value
|
||||
await runOperation(projectId, `生成 ${form.subject.name} · ${form.name} 正式提示词`, async () => {
|
||||
const result = await subjectImagesApi.generatePrompt(formId, overwrite)
|
||||
if (
|
||||
!result ||
|
||||
result.id !== formId ||
|
||||
result.subjectId !== form.subjectId ||
|
||||
!result.generationPrompt?.trim()
|
||||
)
|
||||
throw new Error('接口未确认正式提示词已保存,请先刷新形态记录核对。')
|
||||
})
|
||||
await query.refresh()
|
||||
}
|
||||
|
||||
/** 批量只生成提示词,完整保留部分失败诊断;不自动进入生图。 */
|
||||
async function generatePrompts() {
|
||||
if (blocked.value || !promptValid.value || !forms.value.length) return
|
||||
const projectId = id.value
|
||||
const input = { concurrency: promptConcurrency.value, force: promptForce.value }
|
||||
const target = getImageSession(projectId)
|
||||
target.promptReceipt = null
|
||||
await runOperation(projectId, '批量生成形态正式提示词', async () => {
|
||||
target.promptReceipt = {
|
||||
title: input.force ? '重生成全部形态提示词' : '补齐形态提示词',
|
||||
result: await subjectImagesApi.generatePrompts(projectId, input)
|
||||
}
|
||||
})
|
||||
await query.refresh()
|
||||
}
|
||||
|
||||
/** 捕获正式 Form ID,生成后重新读取图片;刷新失败也不自动重发有费用的请求。 */
|
||||
async function generate(formId: string, input: GenerateFormImageInput) {
|
||||
@@ -76,7 +118,12 @@ export function useSubjectImages() {
|
||||
async function generateProject() {
|
||||
if (blocked.value || !batchValid.value || !forms.value.length) return
|
||||
const projectId = id.value
|
||||
const input = { provider: 'seedream' as const, concurrency: concurrency.value, force: force.value }
|
||||
const input = {
|
||||
provider: 'seedream' as const,
|
||||
concurrency: concurrency.value,
|
||||
force: force.value,
|
||||
...(limit.value === '' ? {} : { limit: limit.value })
|
||||
}
|
||||
const target = getImageSession(projectId)
|
||||
target.receipt = null
|
||||
await runOperation(projectId, '批量生成项目形态图片', async () => {
|
||||
@@ -89,25 +136,26 @@ export function useSubjectImages() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 只刷新 Identity Anchor 已变化的 Character Form。
|
||||
* 用户已经明确确认“刷新过期形态”,因此成功的新图直接切换为当前 Primary;旧图仍保留为历史记录。
|
||||
* 只刷新 Identity Anchor 已变化的形态,覆盖人物、场景与道具。
|
||||
* 与确认文案一致:仅生成候选,用户验图后再显式切换主图。
|
||||
*/
|
||||
async function generateStale() {
|
||||
if (blocked.value || !batchValid.value || !staleForms.value.length) return
|
||||
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 () => {
|
||||
await runOperation(projectId, '刷新过期形态图', async () => {
|
||||
const results = await runWithConcurrency(targets, concurrency.value, async form => {
|
||||
try {
|
||||
const image = await subjectImagesApi.generate(form.id, {
|
||||
provider: 'seedream',
|
||||
setPrimary: true
|
||||
setPrimary: false
|
||||
})
|
||||
if (!image || image.subjectFormId !== form.id || image.status !== 'completed' || !image.imageUrl) {
|
||||
throw new Error(image?.error || '接口未返回已完成的主参考图')
|
||||
throw new Error(image?.error || '接口未返回已完成的候选图')
|
||||
}
|
||||
return { subjectFormId: form.id, success: true as const }
|
||||
} catch (error) {
|
||||
@@ -123,12 +171,12 @@ export function useSubjectImages() {
|
||||
.map(item => ({ subjectFormId: item.subjectFormId, error: item.error }))
|
||||
|
||||
receipt.receipt = {
|
||||
title: '刷新过期人物形态图',
|
||||
title: '刷新过期形态图',
|
||||
result: {
|
||||
total: forms.value.length,
|
||||
total,
|
||||
targetCount: targets.length,
|
||||
generated: results.filter(item => item.success).length,
|
||||
skipped: forms.value.length - targets.length,
|
||||
skipped: total - targets.length,
|
||||
failed: failures.length,
|
||||
failures
|
||||
}
|
||||
@@ -146,6 +194,13 @@ export function useSubjectImages() {
|
||||
session,
|
||||
concurrency,
|
||||
force,
|
||||
limit,
|
||||
promptConcurrency,
|
||||
promptForce,
|
||||
promptValid,
|
||||
concurrencyValid,
|
||||
generatePrompt,
|
||||
generatePrompts,
|
||||
blocked,
|
||||
running,
|
||||
batchValid,
|
||||
|
||||
Reference in new issue
Block a user