refactor: 前端重构为项目+任务双核心模型
- 新增 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)
This commit is contained in:
@@ -8,6 +8,33 @@ export function mergeStyles(
|
||||
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
|
||||
}
|
||||
|
||||
/**
|
||||
* 风格键分类定义
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user