31 lines
981 B
TypeScript
31 lines
981 B
TypeScript
// 穿搭封面组装:把 outfit.items 转成无缝拼图封面所需的渲染数据。
|
|
// 穿搭页与 AI 穿搭页共用,避免复制一份后视觉与角标口径分叉。
|
|
|
|
export interface CoverCell {
|
|
k: string
|
|
img: string
|
|
}
|
|
|
|
export interface OutfitCover {
|
|
// 前 4 件(不足补线稿占位格),无图时 img 为空串由模板渲染线稿
|
|
_covers: CoverCell[]
|
|
// 分格类名:collage--1 / 2 / 3 / 4
|
|
_collageCls: string
|
|
// 超出 4 件的剩余数量,>0 时渲染 +N 角标
|
|
_moreCount: number
|
|
}
|
|
|
|
export function outfitCover(items?: Array<{ clothes_uuid: string; processed_image?: string }>): OutfitCover {
|
|
const list = items || []
|
|
const covers: CoverCell[] = list.slice(0, 4).map((c) => ({
|
|
k: c.clothes_uuid,
|
|
img: c.processed_image || '',
|
|
}))
|
|
if (!covers.length) covers.push({ k: 'empty', img: '' })
|
|
return {
|
|
_covers: covers,
|
|
_collageCls: `collage--${covers.length}`,
|
|
_moreCount: Math.max(list.length - 4, 0),
|
|
}
|
|
}
|