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 { 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">
|
||||
|
||||
Reference in new issue
Block a user