Register 直播切片 as a video-only material type. Upload and edit flows collect required title, live date (defaults to today), optional host with user link, and live platform presets. Persist the fields on Material and skip SPU formatting for free-text titles.
71 lines
2.1 KiB
TypeScript
71 lines
2.1 KiB
TypeScript
/**
|
||
* 素材字段验证和处理的统一逻辑
|
||
*/
|
||
|
||
// 这些类型不需要店铺和场景,系统会自动填充为“通用”
|
||
export const AUTO_GENERAL_TYPES: string[] = ['材质', '音乐', '品牌VI灵感', '任务-其他', '证书-检测报告', '直播切片'];
|
||
|
||
/**
|
||
* 根据素材类型判断是否需要renderer字段
|
||
*/
|
||
export function requiresRenderer(materialType: string): boolean {
|
||
return materialType === '3D场景';
|
||
}
|
||
|
||
/**
|
||
* 根据素材类型判断是否需要categoryName和sceneName字段
|
||
*/
|
||
export function requiresCategoryAndScene(materialType: string): boolean {
|
||
return !AUTO_GENERAL_TYPES.includes(materialType) && materialType !== '标准模型';
|
||
}
|
||
|
||
/**
|
||
* 根据素材类型判断是否需要productCategoryName字段
|
||
*/
|
||
export function requiresProductCategoryName(materialType: string): boolean {
|
||
// 标准模型和证书-检测报告需要品类
|
||
return materialType === '标准模型' || materialType === '证书-检测报告';
|
||
}
|
||
|
||
/**
|
||
* 判断是否需要自动填充"通用"作为categoryName和sceneName
|
||
* 返回true表示应该自动填充为"通用"
|
||
*/
|
||
export function shouldAutoFillGeneral(materialType: string): boolean {
|
||
return AUTO_GENERAL_TYPES.includes(materialType) || materialType === '标准模型';
|
||
}
|
||
|
||
/**
|
||
* 根据素材类型获取renderer的默认值
|
||
*/
|
||
export function getDefaultRenderer(materialType: string): string {
|
||
return 'CR';
|
||
}
|
||
|
||
/**
|
||
* 根据素材类型判断renderer字段是否应该传递
|
||
* @returns { shouldPass: boolean, value: string | null } 是否应该传递renderer及其值
|
||
*/
|
||
export function shouldPassRenderer(materialType: string, renderer?: string | null): { shouldPass: boolean; value: string } {
|
||
if (requiresRenderer(materialType)) {
|
||
// 3D场景类型:必须传递,如果没有提供则使用默认值
|
||
return {
|
||
shouldPass: true,
|
||
value: renderer || getDefaultRenderer(materialType)
|
||
};
|
||
} else if (renderer) {
|
||
// 其他类型:如果有renderer值,则传递
|
||
return {
|
||
shouldPass: true,
|
||
value: renderer
|
||
};
|
||
} else {
|
||
// 其他类型:如果没有renderer值,则不传递
|
||
return {
|
||
shouldPass: false,
|
||
value: ''
|
||
};
|
||
}
|
||
}
|
||
|