feat: 同步视觉风格与主体身份母版工作区
对齐后端 dev 059e597,新增项目风格编辑锁定、身份文本生成、身份参考图与母版切换。 整理六个工作区入口,接通人物及场景母版继承说明、形态图片来源追溯。 补充草稿保护、正式 ID 校验、费用确认及部分失败回执,67 项测试和静态检查、构建通过。 未修改后端,未调用真实模型;本环境未完成浏览器视觉验收。
This commit is contained in:
1 parent
47443c0efe
commit
669f4d9df0
34 files changed
+2273
-22
No files matched your search
@@ -0,0 +1,60 @@
|
||||
import { reactive } from 'vue'
|
||||
import type { SubjectFormAsset } from '../subject-images/types'
|
||||
import type { IdentityBatchResult, IdentityImage, IdentitySubject } from './types'
|
||||
|
||||
/** 视角名称保持与后端四种固定值对应。 */
|
||||
export const identityViewLabels = {
|
||||
primary: '身份母版',
|
||||
front: '正面',
|
||||
'three-quarter': '三分之四侧面',
|
||||
'full-body': '全身'
|
||||
} as const
|
||||
|
||||
/** 将同一主体的多个形态归并成一条,避免为每个形态重复创建 Identity。 */
|
||||
export function groupIdentitySubjects(forms: SubjectFormAsset[]): IdentitySubject[] {
|
||||
const subjects = new Map<string, IdentitySubject>()
|
||||
for (const form of forms) {
|
||||
if (form.subjectId !== form.subject.id) throw new Error('形态与主体 ID 不匹配,请刷新后重试。')
|
||||
const subject = subjects.get(form.subjectId) ?? { ...form.subject, forms: [] }
|
||||
subject.forms.push(form)
|
||||
subjects.set(form.subjectId, subject)
|
||||
}
|
||||
return [...subjects.values()]
|
||||
}
|
||||
|
||||
/** 只有成功且有图片的 primary 候选可成为母版;停用候选也允许重新启用。 */
|
||||
export function canBeAnchor(image: IdentityImage): boolean {
|
||||
return image.viewType === 'primary' && image.status === 'completed' && !!image.imageUrl
|
||||
}
|
||||
|
||||
/** 使用后端 isAnchor,不把 front/full-body 的 enabled 错当成母版。 */
|
||||
export function currentAnchor(images: IdentityImage[]): IdentityImage | undefined {
|
||||
return images.find(image => image.isAnchor && image.enabled && canBeAnchor(image))
|
||||
}
|
||||
|
||||
/** 仅读取追溯所需 ID,不把原始 Provider 数据渲染为 HTML。 */
|
||||
export function readImageProvenance(rawJson?: string | null): {
|
||||
referenceImageId?: string
|
||||
identityAnchorImageId?: string
|
||||
} {
|
||||
try {
|
||||
const parsed: unknown = JSON.parse(rawJson || '{}')
|
||||
if (!parsed || typeof parsed !== 'object') return {}
|
||||
const value = parsed as Record<string, unknown>
|
||||
return {
|
||||
referenceImageId: typeof value.referenceImageId === 'string' ? value.referenceImageId : undefined,
|
||||
identityAnchorImageId:
|
||||
typeof value.identityAnchorImageId === 'string' ? value.identityAnchorImageId : undefined
|
||||
}
|
||||
} catch {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
/** 批量回执按项目保存在当前会话,切页不丢失,刷新浏览器后不伪造恢复。 */
|
||||
const sessions = reactive<Record<string, { receipt: IdentityBatchResult | null }>>({})
|
||||
|
||||
/** 取得指定项目的身份文本批量回执。 */
|
||||
export function getIdentitySession(projectId: string) {
|
||||
return (sessions[projectId] ??= { receipt: null })
|
||||
}
|
||||
Reference in new issue
Block a user