feat: 同步角色选角与首帧身份约束

This commit is contained in:
GouJ committed 2026-08-31 19:14:58 +08:00
1 parent aeb3ce2986
commit 53917268d3
20 files changed
+940 -112

No files matched your search

+43 -3
View File
@@ -1,6 +1,12 @@
import { reactive } from 'vue'
import type { SubjectFormAsset } from '../subject-images/types'
import type { IdentityBatchResult, IdentityImage, IdentitySubject } from './types'
import type {
CharacterCastingItem,
CharacterCastingStatus,
IdentityImage,
IdentityReceipt,
IdentitySubject
} from './types'
/** 视角名称保持与后端四种固定值对应。 */
export const identityViewLabels = {
@@ -22,6 +28,40 @@ export function groupIdentitySubjects(forms: SubjectFormAsset[]): IdentitySubjec
return [...subjects.values()]
}
/** 将选角就绪接口中的无形态 Character 补入主体目录,确保选角早于 Form 生图也可操作。 */
export function mergeCastingSubjects(
subjects: IdentitySubject[],
casting: CharacterCastingItem[],
projectId: string
): IdentitySubject[] {
const rows = new Map(subjects.map(subject => [subject.id, subject]))
for (const item of casting) {
if (!rows.has(item.subjectId)) {
rows.set(item.subjectId, {
id: item.subjectId,
projectId,
ref: item.subjectRef,
name: item.subjectName,
module: 'character',
forms: []
})
}
}
return [...rows.values()].toSorted((a, b) => a.ref.localeCompare(b.ref))
}
/** 角色选角状态中文标签。 */
export function castingStatusLabel(status: CharacterCastingStatus): string {
const labels: Record<CharacterCastingStatus, string> = {
missing_identity: '缺少身份文本',
missing_anchor: '缺少候选图',
candidate_pending: '等待确认演员',
unlocked: '演员尚未锁定',
ready: '选角已完成'
}
return labels[status]
}
/** 只有成功且有图片的 primary 候选可成为母版;停用候选也允许重新启用。 */
export function canBeAnchor(image: IdentityImage): boolean {
return image.viewType === 'primary' && image.status === 'completed' && !!image.imageUrl
@@ -52,9 +92,9 @@ export function readImageProvenance(rawJson?: string | null): {
}
/** 批量回执按项目保存在当前会话,切页不丢失,刷新浏览器后不伪造恢复。 */
const sessions = reactive<Record<string, { receipt: IdentityBatchResult | null }>>({})
const sessions = reactive<Record<string, { receipt: IdentityReceipt | null }>>({})
/** 取得指定项目的身份文本批量回执。 */
/** 取得指定项目的身份文本或选角候选批量回执。 */
export function getIdentitySession(projectId: string) {
return (sessions[projectId] ??= { receipt: null })
}