f0b99ea9da
批量删除用户 模板上传图片数量限制改成30 小飞侠接口配置
65 lines
1.9 KiB
TypeScript
65 lines
1.9 KiB
TypeScript
/** 商品详情页文案模板(Admin 一键套用) */
|
|
export const TEMPLATE_MAX_DETAIL_IMAGES = 30;
|
|
|
|
export type ProductDetailTemplateContent = {
|
|
storyTitle?: string;
|
|
storyText?: string;
|
|
features?: Array<{ icon: string; title: string; desc: string }>;
|
|
/** 模板内置详情长图 URL 列表 */
|
|
detailImageUrls?: string[];
|
|
/** 建议详情长图张数(与 detailImageUrls 数量同步,供展示) */
|
|
suggestedDetailImageCount?: number;
|
|
};
|
|
|
|
export type ProductDetailTemplate = {
|
|
id: string;
|
|
code: string;
|
|
label: string;
|
|
description: string;
|
|
aromaType?: string;
|
|
content: ProductDetailTemplateContent;
|
|
};
|
|
|
|
/** API 返回的详情模板 DTO(与 shared-types ProductDetailTemplateDto 对齐) */
|
|
export type ProductDetailTemplateDto = {
|
|
id: string;
|
|
code: string;
|
|
name: string;
|
|
description?: string | null;
|
|
aromaType?: string | null;
|
|
storyTitle?: string | null;
|
|
storyText?: string | null;
|
|
features?: Array<{ icon: string; title: string; desc: string }>;
|
|
detailImageUrls?: string[];
|
|
suggestedDetailImageCount: number;
|
|
sortOrder: number;
|
|
status: 'ACTIVE' | 'DISABLED';
|
|
createdAt: string;
|
|
updatedAt: string;
|
|
};
|
|
|
|
export function mapDtoToProductDetailTemplate(dto: ProductDetailTemplateDto): ProductDetailTemplate {
|
|
const detailImageUrls = (dto.detailImageUrls ?? []).filter(Boolean);
|
|
return {
|
|
id: dto.code,
|
|
code: dto.code,
|
|
label: dto.name,
|
|
description: dto.description ?? '',
|
|
aromaType: dto.aromaType ?? undefined,
|
|
content: {
|
|
storyTitle: dto.storyTitle ?? undefined,
|
|
storyText: dto.storyText ?? undefined,
|
|
features: dto.features ?? [],
|
|
detailImageUrls,
|
|
suggestedDetailImageCount: detailImageUrls.length || dto.suggestedDetailImageCount,
|
|
},
|
|
};
|
|
}
|
|
|
|
export function getProductDetailTemplate(
|
|
templates: ProductDetailTemplate[],
|
|
code: string,
|
|
) {
|
|
return templates.find((t) => t.code === code || t.id === code);
|
|
}
|