feat: 同步视觉风格与主体身份母版工作区

对齐后端 dev 059e597,新增项目风格编辑锁定、身份文本生成、身份参考图与母版切换。
整理六个工作区入口,接通人物及场景母版继承说明、形态图片来源追溯。
补充草稿保护、正式 ID 校验、费用确认及部分失败回执,67 项测试和静态检查、构建通过。
未修改后端,未调用真实模型;本环境未完成浏览器视觉验收。
This commit is contained in:
GouJ committed 2026-08-28 19:28:27 +08:00
1 parent 47443c0efe
commit 669f4d9df0
34 files changed
+2273 -22

No files matched your search

@@ -0,0 +1,124 @@
<script setup lang="ts">
import { computed, reactive, ref, watch } from 'vue'
import type { SaveVisualStyleInput, VisualStyle } from '../types'
/** 编辑草稿独立于轮询结果,刷新不会覆盖尚未保存的输入。 */
const props = defineProps<{ style: VisualStyle | null; disabled: boolean }>()
const emit = defineEmits<{ save: [input: SaveVisualStyleInput]; dirty: [value: boolean] }>()
const form = reactive({
name: '',
prompt: '',
characterPrompt: '',
scenePrompt: '',
propPrompt: '',
constraints: '[]',
isLocked: false
})
const baseline = ref('')
const dirty = computed(() => JSON.stringify(form) !== baseline.value)
const constraintsError = computed(() => {
try {
const value: unknown = JSON.parse(form.constraints)
return Array.isArray(value) && value.every(item => typeof item === 'string')
? ''
: '硬约束须为字符串数组,例如 ["真人写实", "禁止二次元"]。'
} catch {
return '硬约束 JSON 格式不正确,请修正后保存。'
}
})
watch(
() => props.style,
value => {
if (baseline.value && dirty.value) return
Object.assign(form, {
name: value?.name ?? '默认视觉风格',
prompt: value?.prompt ?? '',
characterPrompt: value?.characterPrompt ?? '',
scenePrompt: value?.scenePrompt ?? '',
propPrompt: value?.propPrompt ?? '',
constraints: JSON.stringify(value?.hardConstraints ?? [], null, 2),
isLocked: value?.isLocked ?? false
})
baseline.value = JSON.stringify(form)
},
{ immediate: true }
)
watch(dirty, value => emit('dirty', value), { immediate: true })
/** 显式校验 JSON 后保存结构化约束;不对错误结构做静默转换。 */
function save() {
if (props.disabled || constraintsError.value) return
emit('save', {
name: form.name.trim(),
prompt: form.prompt,
characterPrompt: form.characterPrompt,
scenePrompt: form.scenePrompt,
propPrompt: form.propPrompt,
hardConstraints: JSON.parse(form.constraints) as string[],
isLocked: form.isLocked
})
}
</script>
<template>
<form class="panel p-5 sm:p-6" @submit.prevent="save">
<fieldset :disabled="disabled" class="space-y-5">
<div class="flex flex-wrap items-center justify-between gap-3">
<h3 class="font-medium">风格说明</h3>
<span v-if="dirty" class="tag">有未保存修改</span>
</div>
<label class="block"
><span class="field-label">风格名称</span><input id="style-name" v-model="form.name" class="input"
/></label>
<label class="block"
><span class="field-label">整体视觉语言</span
><textarea
id="style-prompt"
v-model="form.prompt"
class="input min-h-32"
placeholder="媒介、真实感、色彩和整体美术方向"
/>
</label>
<div class="grid gap-5 lg:grid-cols-3">
<label
><span class="field-label">人物风格补充</span
><textarea v-model="form.characterPrompt" class="input min-h-32" />
</label>
<label
><span class="field-label">场景风格补充</span
><textarea v-model="form.scenePrompt" class="input min-h-32" />
</label>
<label
><span class="field-label">道具风格补充</span
><textarea v-model="form.propPrompt" class="input min-h-32" />
</label>
</div>
<label class="block"
><span class="field-label">硬约束 · JSON 字符串数组</span
><textarea
id="style-constraints"
v-model="form.constraints"
class="input min-h-24 font-mono text-xs"
spellcheck="false"
/>
</label>
<p v-if="constraintsError" class="text-xs text-danger" role="alert">{{ constraintsError }}</p>
<label class="flex items-start gap-2 text-sm"
><input
id="style-lock"
v-model="form.isLocked"
type="checkbox"
class="mt-1 accent-accent"
/>确认并锁定风格,阻止后续 AI 自动覆盖</label
>
<p class="text-xs leading-6 text-muted">
锁定后仍可人工编辑并保存。取消勾选并保存后,才能再次使用 AI 重生成。
</p>
<div class="flex justify-end">
<button class="button button-primary" type="submit" :disabled="disabled || !!constraintsError">
保存视觉风格
</button>
</div>
</fieldset>
</form>
</template>