f44fd56e22
- StyleSelector 新增 customTags 属性,自定义标签作为「自定义标签」行展示在原生标签栏中 - 自定义标签点击切换 true/false,不再移除 key,解决点击消失问题 - CustomTagsEditor 简化为仅输入框+添加按钮 - extractTags 仅提取激活态自定义标签(value=true) - 导出 CUSTOM_PREFIX 供组件使用
131 lines
3.5 KiB
TypeScript
Executable File
131 lines
3.5 KiB
TypeScript
Executable File
/**
|
|
* 合并工程风格与任务风格覆盖(任务覆盖优先,与后端 PromptBuilder 逻辑一致)
|
|
*/
|
|
export function mergeStyles(
|
|
projectStyle: Record<string, string>,
|
|
taskOverrides: Record<string, string>
|
|
): Record<string, string> {
|
|
return { ...projectStyle, ...taskOverrides }
|
|
}
|
|
|
|
export const CUSTOM_PREFIX = 'custom:'
|
|
|
|
export function isCustomKey(key: string): boolean {
|
|
return key.startsWith(CUSTOM_PREFIX)
|
|
}
|
|
|
|
export function getCustomTags(style: Record<string, string>): string[] {
|
|
return Object.keys(style)
|
|
.filter(isCustomKey)
|
|
.map(key => key.slice(CUSTOM_PREFIX.length))
|
|
}
|
|
|
|
export function addCustomTag(
|
|
style: Record<string, string>,
|
|
tag: string
|
|
): Record<string, string> {
|
|
return { ...style, [`${CUSTOM_PREFIX}${tag}`]: 'true' }
|
|
}
|
|
|
|
export function removeCustomTag(
|
|
style: Record<string, string>,
|
|
tag: string
|
|
): Record<string, string> {
|
|
const { [`${CUSTOM_PREFIX}${tag}`]: _, ...rest } = style
|
|
return rest
|
|
}
|
|
|
|
/**
|
|
* 风格键分类定义
|
|
*/
|
|
export interface StyleCategory {
|
|
key: string
|
|
label: string
|
|
options: { value: string; label: string }[]
|
|
}
|
|
|
|
/** 工程类型键名 */
|
|
export const PROJECT_TYPE_KEY = 'projectType'
|
|
|
|
/** 工程类型选项(决定项目整体类型,区别于素材生成的风格标签) */
|
|
export const PROJECT_TYPES: { value: string; label: string }[] = [
|
|
{ value: '2d-platformer', label: '2D 平台跳跃' },
|
|
{ value: 'rpg', label: '角色扮演' },
|
|
{ value: 'top-down', label: '俯视视角' },
|
|
{ value: 'visual-novel', label: '视觉小说' },
|
|
{ value: 'tower-defense', label: '塔防' },
|
|
{ value: 'puzzle', label: '益智解谜' },
|
|
{ value: 'shooter', label: '射击' },
|
|
{ value: 'roguelike', label: '肉鸽' },
|
|
]
|
|
|
|
export const STYLE_CATEGORIES: StyleCategory[] = [
|
|
{
|
|
key: 'artStyle',
|
|
label: '美术风格',
|
|
options: [
|
|
{ value: 'pixel', label: '像素' },
|
|
{ value: 'cartoon', label: '卡通' },
|
|
{ value: 'hand-drawn', label: '手绘' },
|
|
{ value: 'vector', label: '矢量' },
|
|
{ value: 'flat', label: '扁平' },
|
|
],
|
|
},
|
|
{
|
|
key: 'palette',
|
|
label: '色调',
|
|
options: [
|
|
{ value: 'warm', label: '暖色' },
|
|
{ value: 'cool', label: '冷色' },
|
|
{ value: 'neutral', label: '中性' },
|
|
{ value: 'vibrant', label: '鲜艳' },
|
|
{ value: 'muted', label: '柔和' },
|
|
{ value: 'monochrome', label: '单色' },
|
|
],
|
|
},
|
|
{
|
|
key: 'lineWeight',
|
|
label: '线条',
|
|
options: [
|
|
{ value: 'none', label: '无' },
|
|
{ value: 'thin', label: '细线' },
|
|
{ value: 'medium', label: '中等' },
|
|
{ value: 'thick', label: '粗线' },
|
|
],
|
|
},
|
|
{
|
|
key: 'scene',
|
|
label: '场景',
|
|
options: [
|
|
{ value: 'forest', label: '森林' },
|
|
{ value: 'dungeon', label: '地牢' },
|
|
{ value: 'city', label: '城市' },
|
|
{ value: 'space', label: '太空' },
|
|
{ value: 'underwater', label: '水下' },
|
|
{ value: 'desert', label: '沙漠' },
|
|
],
|
|
},
|
|
{
|
|
key: 'lighting',
|
|
label: '光照',
|
|
options: [
|
|
{ value: 'bright', label: '明亮' },
|
|
{ value: 'dim', label: '昏暗' },
|
|
{ value: 'dramatic', label: '戏剧' },
|
|
{ value: 'ambient', label: '环境光' },
|
|
{ value: 'neon', label: '霓虹' },
|
|
],
|
|
},
|
|
{
|
|
key: 'mood',
|
|
label: '情绪',
|
|
options: [
|
|
{ value: 'cheerful', label: '欢快' },
|
|
{ value: 'dark', label: '黑暗' },
|
|
{ value: 'mysterious', label: '神秘' },
|
|
{ value: 'epic', label: '史诗' },
|
|
{ value: 'calm', label: '平静' },
|
|
],
|
|
},
|
|
]
|