选择性整合 #547,保留主分支节点与工具条设计。新增默认折叠的节点、资产、任务和历史面板,风格与预设保留在节点内,移除重复入口。 补齐工具权限、提示词解析、资源引用保护及数据库迁移,修复提示词清空和连续编辑后的生成配置同步。 验证:前端全量 1925 项测试、构建、类型检查及 lint 通过;后端 go test ./... 通过。真实模型、PostgreSQL 实库与登录态页面验收仍待进行。 Refs #547 Co-authored-by: bensharp <bensharp@qq.com>
46 lines
1.9 KiB
TypeScript
46 lines
1.9 KiB
TypeScript
import { CanvasNodeType, type CanvasNodeData } from "@/types/canvas";
|
|
|
|
/** 已有媒体但没有生成配置的图片是输入素材,不提供原地生成入口。 */
|
|
export function isCanvasImageSourceNode(node: CanvasNodeData | null | undefined): boolean {
|
|
if (node?.type === CanvasNodeType.Image && node.metadata?.fileUpload) return true;
|
|
return node?.type === CanvasNodeType.Image
|
|
&& Boolean(node.metadata?.content)
|
|
&& !node.metadata?.generationType
|
|
&& !node.metadata?.taskId
|
|
&& !node.metadata?.generationResultPlacement
|
|
&& !node.metadata?.copiedFromNodeId
|
|
&& !node.metadata?.versionOfNodeId;
|
|
}
|
|
|
|
export function createPortraitTextureNode(source: CanvasNodeData, id: string): CanvasNodeData {
|
|
return {
|
|
id,
|
|
type: CanvasNodeType.Image,
|
|
title: `${source.title || "图片"} · 人物质感`,
|
|
position: { x: source.position.x + source.width + 96, y: source.position.y },
|
|
width: source.width,
|
|
height: source.height,
|
|
metadata: {
|
|
prompt: "@图片1",
|
|
composerContent: "@图片1",
|
|
generationType: "edit",
|
|
portraitTexture: source.metadata?.portraitTexture,
|
|
},
|
|
};
|
|
}
|
|
export function createNineGridNode(source: CanvasNodeData, id: string, toolId: number, label: string, type: string, icon: string): CanvasNodeData {
|
|
return {
|
|
id,
|
|
type: CanvasNodeType.Image,
|
|
title: `${source.title || "图片"} · ${label}`,
|
|
position: { x: source.position.x + source.width + 96, y: source.position.y },
|
|
width: source.width,
|
|
height: source.height,
|
|
metadata: {
|
|
prompt: `@[node:${source.id}] @[tool:${type}:${toolId}:${encodeURIComponent(label)}:${icon}]`,
|
|
composerContent: `@[node:${source.id}] @[tool:${type}:${toolId}:${encodeURIComponent(label)}:${icon}]`,
|
|
generationType: "edit",
|
|
},
|
|
};
|
|
}
|