@@ -1,38 +0,0 @@
|
||||
import type { ConfigDisplayFields } from "../types/templateLibrary"
|
||||
import {
|
||||
TEMPLATE_TYPES,
|
||||
CATEGORY_GRADIENT_MAP,
|
||||
DEFAULT_GRADIENT,
|
||||
MATERIAL_TYPE_LABELS,
|
||||
} from "../constants/templateLibrary"
|
||||
|
||||
/** 获取类型对应颜色 */
|
||||
export const getTypeColor = (type: string): string => {
|
||||
const found = TEMPLATE_TYPES.find((t) => t.type === type)
|
||||
return found?.color ?? "#6366f1"
|
||||
}
|
||||
|
||||
/** 根据 category 生成占位渐变色 */
|
||||
export const gradientForCategory = (category: string): string => {
|
||||
return CATEGORY_GRADIENT_MAP[category] ?? DEFAULT_GRADIENT
|
||||
}
|
||||
|
||||
/** 格式化配置对象为可读文本 */
|
||||
export const formatConfig = (config?: object): string => {
|
||||
if (!config || Object.keys(config).length === 0) return "默认"
|
||||
const c = config as ConfigDisplayFields
|
||||
const parts: string[] = []
|
||||
if (c.font_size) parts.push(`字号: ${c.font_size}`)
|
||||
if (c.font_family) parts.push(`字体: ${c.font_family}`)
|
||||
if (c.color) parts.push(`颜色: ${c.color}`)
|
||||
if (c.position) parts.push(`位置: ${c.position}`)
|
||||
if (c.volume !== undefined) parts.push(`音量: ${c.volume}%`)
|
||||
if (c.name) parts.push(String(c.name))
|
||||
return parts.length > 0 ? parts.join(" / ") : JSON.stringify(config)
|
||||
}
|
||||
|
||||
/** 获取素材类型标签文本 */
|
||||
export const getMaterialTypeLabel = (materialType: string | null | undefined): string => {
|
||||
if (!materialType) return "不限"
|
||||
return MATERIAL_TYPE_LABELS[materialType] ?? materialType
|
||||
}
|
||||
Reference in New Issue
Block a user