72 lines
2.1 KiB
TypeScript
72 lines
2.1 KiB
TypeScript
import { normalizeVideoMaterialType } from './video-material-types'
|
||
|
||
/**
|
||
* 素材类型映射工具
|
||
* 用于将老类型映射到新类型,确保代码兼容性
|
||
*/
|
||
|
||
/**
|
||
* 将老类型映射到新类型
|
||
*/
|
||
export function mapMaterialType(type: string): string {
|
||
const typeMap: Record<string, string> = {
|
||
'3DMAX': '3D场景',
|
||
'产品全案': '任务-详情',
|
||
'详情页': '详情模板',
|
||
};
|
||
|
||
return normalizeVideoMaterialType(typeMap[type] || type);
|
||
}
|
||
|
||
/**
|
||
* 检查素材类型是否匹配(支持老类型和新类型)
|
||
* @param actualType 实际的素材类型(可能是老类型或新类型)
|
||
* @param expectedType 期望的类型(新类型)
|
||
*/
|
||
export function isMaterialType(actualType: string, expectedType: string): boolean {
|
||
const mappedActualType = mapMaterialType(actualType);
|
||
return mappedActualType === expectedType;
|
||
}
|
||
|
||
/**
|
||
* 检查素材类型是否为任务-详情
|
||
*/
|
||
export function isProductPackageType(materialType: string): boolean {
|
||
return isMaterialType(materialType, '任务-详情');
|
||
}
|
||
|
||
/**
|
||
* 检查素材类型是否为详情模板
|
||
*/
|
||
export function isDetailTemplateType(materialType: string): boolean {
|
||
return isMaterialType(materialType, '详情模板');
|
||
}
|
||
|
||
/**
|
||
* 检查素材类型是否为3D场景
|
||
*/
|
||
export function is3DSceneType(materialType: string): boolean {
|
||
return isMaterialType(materialType, '3D场景');
|
||
}
|
||
|
||
/**
|
||
* 检查素材类型是否为任务类轻量素材
|
||
*/
|
||
export function is3DOriginalType(materialType: string): boolean {
|
||
return ['任务-3D原图', '任务-AI原图', '任务-实拍原图', '任务-视频截图', '任务-页面', '任务-其他'].includes(materialType);
|
||
}
|
||
|
||
/**
|
||
* 检查素材类型是否为证书-检测报告
|
||
*/
|
||
export function isCertificateReportType(materialType: string): boolean {
|
||
return materialType === '证书-检测报告';
|
||
}
|
||
|
||
/**
|
||
* 检查素材类型是否需要查询资产列表(任务-详情 或 任务-3D原图等)
|
||
*/
|
||
export function needsAssetsList(materialType: string): boolean {
|
||
return isProductPackageType(materialType) || is3DOriginalType(materialType) || isCertificateReportType(materialType);
|
||
}
|