feat: 同步精简接口并统一表单校验

This commit is contained in:
GJ committed 2026-09-10 22:34:47 +08:00
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 { sizeRules } from '../../../lib/form-rules'
import { NAlert, NButton, NCheckbox, NInput, NInputNumber } from 'naive-ui'
import { computed, ref, watch } from 'vue'
import { AppDialog } from '../../../components/ui'
@@ -33,17 +36,31 @@ function submit() {
})
open.value = false
}
const formModel = computed(() => ({ width: width.value, height: height.value, prompt: prompt.value }))
const rules = { ...sizeRules(() => formModel.value) }
</script>
<template>
<AppDialog v-model:open="open" title="生成角色选角候选" :description="`${subjectName} · 候选不会自动成为身份母版`">
<form class="mt-5 space-y-4" @submit.prevent="submit">
<AppForm
:model="formModel"
:rules="rules"
:disabled="disabled"
:reset-key="`${open}:${subjectId}`"
validate-on-change
class="mt-5 space-y-4"
@submit="submit"
>
<NAlert type="info" :show-icon="false" class="text-xs">
后端会依据角色 Identity、项目视觉风格和默认选角约束独立生成一张 primary
候选,不会复用当前身份母版。生成完成后仍需人工点击“确认选角”。
</NAlert>
<label class="block">
<span class="field-label">覆盖本次完整提示词(可选)</span>
<NFormItem
class="block"
path="prompt"
label="覆盖本次完整提示词(可选)"
:label-props="{ for: 'casting-candidate-prompt' }"
>
<NInput
placeholder="建议留空,使用后端编译的稳定身份和选角约束;未明确人物背景时默认中国人物"
:input-props="{ id: 'casting-candidate-prompt' }"
@@ -52,31 +69,30 @@ function submit() {
type="textarea"
:autosize="{ minRows: 3, maxRows: 12 }"
></NInput>
</label>
</NFormItem>
<p v-if="prompt.trim()" class="text-xs text-danger">
自定义文本会替换后端完整提示词,请自行包含人物身份、基础服装和中性参考图要求。
</p>
<div class="grid grid-cols-2 gap-4">
<label
><span class="field-label">宽度(px)</span
<NFormItem path="width" label="宽度(px)"
><NInputNumber
:input-props="{ 'aria-label': '宽度(px)' }"
placeholder="后端默认"
:value="typeof width === 'number' ? width : null"
@update:value="width = $event ?? ''"
:min="1"
></NInputNumber
></label>
<label
><span class="field-label">高度(px)</span
></NFormItem>
<NFormItem path="height" label="高度(px)"
><NInputNumber
:input-props="{ 'aria-label': '高度(px)' }"
placeholder="后端默认"
:value="typeof height === 'number' ? height : null"
@update:value="height = $event ?? ''"
:min="1"
></NInputNumber
></label>
></NFormItem>
</div>
<p v-if="!valid" class="text-xs text-danger">宽高需要同时留空,或同时填写正整数。</p>
<NCheckbox
id="casting-candidate-cost"
v-model:checked="acknowledged"
@@ -89,6 +105,6 @@ function submit() {
确认生成候选
</NButton>
</div>
</form>
</AppForm>
</AppDialog>
</template>