a603f5548c
- 新增 HomePage 项目画廊页,支持新建/删除工程 - 新增 ProjectDetailPage 三栏工作台(配置+生成+任务列表) - 新增 CustomTagsEditor 支持自定义风格标签(custom: 前缀存入 kvPairs) - 重构 project store 为 draft/commit 模式,支持手动保存/取消 - 新增 projectList store 管理工程列表 - 扩展 mock.ts 为多工程数据结构 - 扩展 api/project.ts 新增项目 CRUD API(mock-gated) - 简化 ResultPage,仅展示素材预览 - 删除 GeneratePage、ProjectPage 及未使用的 hooks - 更新 docs/ 文档(frontend.md、api.md、style-keys.md、_index.md)
116 lines
2.9 KiB
TypeScript
Executable File
116 lines
2.9 KiB
TypeScript
Executable File
/**
|
|
* 合并工程风格与任务风格覆盖(任务覆盖优先,与后端 PromptBuilder 逻辑一致)
|
|
*/
|
|
export function mergeStyles(
|
|
projectStyle: Record<string, string>,
|
|
taskOverrides: Record<string, string>
|
|
): Record<string, string> {
|
|
return { ...projectStyle, ...taskOverrides }
|
|
}
|
|
|
|
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 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: '平静' },
|
|
],
|
|
},
|
|
]
|