gongxiangp2/lib/material-type-options.ts
WuYongJie d8d843e6ad feat: add live clip material type with date host and platform
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.
2026-09-22 18:59:05 +08:00

75 lines
2.0 KiB
TypeScript

import { isProductPackageType, mapMaterialType } from './material-type-mapper'
import {
DOUYIN_ACCOUNT_MAINTENANCE_VIDEO_TYPE,
DOUYIN_QIANCHUAN_VIDEO_TYPE,
TAOXI_GUANGGUANG_VIDEO_TYPE,
TAOXI_MAIN_VIDEO_TYPE,
} from './video-material-types'
export const MATERIAL_TYPE_OPTIONS = [
'3D场景',
'详情模板',
'材质',
'模特',
'实拍图片',
'买家秀图片',
'小红书种草',
'主图模版',
'SKU模版',
TAOXI_MAIN_VIDEO_TYPE,
'安装视频',
TAOXI_GUANGGUANG_VIDEO_TYPE,
DOUYIN_QIANCHUAN_VIDEO_TYPE,
DOUYIN_ACCOUNT_MAINTENANCE_VIDEO_TYPE,
'直播切片',
'音乐',
'标准模型',
'品牌VI灵感',
'证书-检测报告',
'任务-详情',
'任务-页面',
'任务-其他',
'任务-3D原图',
'任务-AI原图',
'任务-实拍原图',
'任务-视频截图',
] as const
export type MaterialTypeOption = typeof MATERIAL_TYPE_OPTIONS[number]
export function isSelectableMaterialType(type: string): type is MaterialTypeOption {
return MATERIAL_TYPE_OPTIONS.includes(type as MaterialTypeOption)
}
export function filterSelectableMaterialTypes(types: string[]): string[] {
const uniqueTypes = new Set(types.filter(isSelectableMaterialType))
return MATERIAL_TYPE_OPTIONS.filter((type) => uniqueTypes.has(type))
}
export function getSelectableMaterialTypeOptions(currentType?: string | null): string[] {
const options = [...MATERIAL_TYPE_OPTIONS]
if (!currentType || options.includes(currentType as MaterialTypeOption)) {
return options
}
return [currentType, ...options]
}
export function isTaskMaterialType(materialType: string): boolean {
return mapMaterialType(materialType).startsWith('任务-')
}
export function supportsTaskNo(_materialType: string): boolean {
return true
}
export function supportsIsFullSet(materialType: string): boolean {
return isProductPackageType(materialType)
}
export function canManuallyReplacePreview(materialType: string): boolean {
return !isTaskMaterialType(materialType)
}