init
This commit is contained in:
197
frontend/src/data/nodeCatalog.ts
Normal file
197
frontend/src/data/nodeCatalog.ts
Normal file
@ -0,0 +1,197 @@
|
||||
export interface NodeSize {
|
||||
width: number
|
||||
height: number
|
||||
}
|
||||
|
||||
export interface NodeDescriptor {
|
||||
type: string
|
||||
label: string
|
||||
icon: string
|
||||
color: string
|
||||
subtitle?: string
|
||||
size?: NodeSize
|
||||
defaults?: Record<string, any>
|
||||
}
|
||||
|
||||
export interface NodeCategory {
|
||||
key: string
|
||||
label: string
|
||||
icon: string
|
||||
nodes: NodeDescriptor[]
|
||||
}
|
||||
|
||||
const dataNodes: NodeDescriptor[] = [
|
||||
{
|
||||
type: 'dataInputNode',
|
||||
label: '数据输入',
|
||||
icon: 'mdi:database-import',
|
||||
color: '#52c41a',
|
||||
subtitle: 'Input Stream',
|
||||
size: { width: 200, height: 120 },
|
||||
defaults: { sourceType: '文件', format: '自动检测' }
|
||||
},
|
||||
{
|
||||
type: 'dataTransferNode',
|
||||
label: '数据转接',
|
||||
icon: 'mdi:swap-horizontal',
|
||||
color: '#1890ff',
|
||||
subtitle: 'Transfer Hub',
|
||||
size: { width: 230, height: 120 },
|
||||
defaults: { protocol: '自动' }
|
||||
},
|
||||
{
|
||||
type: 'dataOutputNode',
|
||||
label: '数据输出',
|
||||
icon: 'mdi:database-export',
|
||||
color: '#f5222d',
|
||||
subtitle: 'Output Sink',
|
||||
size: { width: 220, height: 120 },
|
||||
defaults: { strategy: '即时', format: 'JSON' }
|
||||
},
|
||||
{
|
||||
type: 'aggregationNode',
|
||||
label: '聚合节点',
|
||||
icon: 'mdi:sigma-lower',
|
||||
color: '#08979c',
|
||||
subtitle: 'Metrics',
|
||||
size: { width: 230, height: 130 },
|
||||
defaults: { metric: 'count', dimension: 'global' }
|
||||
}
|
||||
]
|
||||
|
||||
const aiNodes: NodeDescriptor[] = [
|
||||
{
|
||||
type: 'llmNode',
|
||||
label: '大模型',
|
||||
icon: 'mdi:robot',
|
||||
color: '#722ed1',
|
||||
subtitle: 'LLM Inference',
|
||||
size: { width: 220, height: 130 },
|
||||
defaults: { model: 'gpt-4o-mini', temperature: 0.7 }
|
||||
},
|
||||
{
|
||||
type: 'intentNode',
|
||||
label: '意图识别',
|
||||
icon: 'mdi:target',
|
||||
color: '#13c2c2',
|
||||
subtitle: 'Intent Parser',
|
||||
size: { width: 210, height: 120 },
|
||||
defaults: { domain: '通用', confidence: 80 }
|
||||
},
|
||||
{
|
||||
type: 'imageNode',
|
||||
label: '图像处理',
|
||||
icon: 'mdi:image-filter-center-focus',
|
||||
color: '#d4380d',
|
||||
subtitle: 'Vision Ops',
|
||||
size: { width: 220, height: 130 },
|
||||
defaults: { operation: '增强', resolution: 'Auto' }
|
||||
},
|
||||
{
|
||||
type: 'scriptNode',
|
||||
label: '脚本节点',
|
||||
icon: 'mdi:code-tags',
|
||||
color: '#177ddc',
|
||||
subtitle: 'Custom Logic',
|
||||
size: { width: 220, height: 120 },
|
||||
defaults: { language: 'TypeScript', entry: 'main' }
|
||||
}
|
||||
]
|
||||
|
||||
const integrationNodes: NodeDescriptor[] = [
|
||||
{
|
||||
type: 'httpNode',
|
||||
label: 'HTTP 请求',
|
||||
icon: 'mdi:web',
|
||||
color: '#fa8c16',
|
||||
subtitle: 'REST Hook',
|
||||
size: { width: 260, height: 130 },
|
||||
defaults: { method: 'GET', url: '' }
|
||||
},
|
||||
{
|
||||
type: 'webhookNode',
|
||||
label: 'Webhook',
|
||||
icon: 'mdi:webhook',
|
||||
color: '#52c41a',
|
||||
subtitle: 'Outbound Hook',
|
||||
size: { width: 240, height: 130 },
|
||||
defaults: { method: 'POST', endpoint: '' }
|
||||
},
|
||||
{
|
||||
type: 'mcpNode',
|
||||
label: 'MCP 调用',
|
||||
icon: 'mdi:power-plug',
|
||||
color: '#eb2f96',
|
||||
subtitle: 'Service Bridge',
|
||||
size: { width: 210, height: 120 },
|
||||
defaults: { service: '默认服务', action: 'invoke' }
|
||||
},
|
||||
{
|
||||
type: 'udpNode',
|
||||
label: 'UDP 发送',
|
||||
icon: 'mdi:broadcast',
|
||||
color: '#2f54eb',
|
||||
subtitle: 'Realtime Push',
|
||||
size: { width: 210, height: 120 },
|
||||
defaults: { host: '127.0.0.1', port: 9000 }
|
||||
}
|
||||
]
|
||||
|
||||
const controlNodes: NodeDescriptor[] = [
|
||||
{
|
||||
type: 'conditionalNode',
|
||||
label: '条件判断',
|
||||
icon: 'mdi:help-rhombus',
|
||||
color: '#faad14',
|
||||
subtitle: 'Flow Control',
|
||||
size: { width: 240, height: 130 },
|
||||
defaults: { expression: 'score > 0.8', trueLabel: '通过', falseLabel: '拦截' }
|
||||
},
|
||||
{
|
||||
type: 'delayNode',
|
||||
label: '延迟节点',
|
||||
icon: 'mdi:timer-sand',
|
||||
color: '#722ed1',
|
||||
subtitle: 'Wait / Backoff',
|
||||
size: { width: 190, height: 110 },
|
||||
defaults: { duration: 5, mode: '固定' }
|
||||
},
|
||||
{
|
||||
type: 'loopNode',
|
||||
label: '循环节点',
|
||||
icon: 'mdi:repeat-variant',
|
||||
color: '#fa541c',
|
||||
subtitle: 'Iteration',
|
||||
size: { width: 210, height: 130 },
|
||||
defaults: { iterations: 3, iterator: 'item', mode: '次数' }
|
||||
}
|
||||
]
|
||||
|
||||
const layoutNodes: NodeDescriptor[] = [
|
||||
{
|
||||
type: 'containerNode',
|
||||
label: '容器节点',
|
||||
icon: 'mdi:shape-outline',
|
||||
color: '#5b8ff9',
|
||||
subtitle: 'Grouping',
|
||||
size: { width: 360, height: 240 },
|
||||
defaults: { title: '容器', autoSize: true, size: { width: 360, height: 240 } }
|
||||
}
|
||||
]
|
||||
|
||||
export const nodeCategories: NodeCategory[] = [
|
||||
{ key: 'data', label: '数据层', icon: 'mdi:database', nodes: dataNodes },
|
||||
{ key: 'ai', label: '智能层', icon: 'mdi:robot-happy-outline', nodes: aiNodes },
|
||||
{ key: 'integrations', label: '集成层', icon: 'mdi:link-variant', nodes: integrationNodes },
|
||||
{ key: 'control', label: '控制层', icon: 'mdi:axis-arrow', nodes: controlNodes },
|
||||
{ key: 'structure', label: '结构节点', icon: 'mdi:arrange-bring-forward', nodes: layoutNodes }
|
||||
]
|
||||
|
||||
export const nodePalette = nodeCategories.flatMap(category => category.nodes)
|
||||
|
||||
export const nodePaletteMap = nodePalette.reduce<Record<string, NodeDescriptor>>((acc, node) => {
|
||||
acc[node.type] = node
|
||||
return acc
|
||||
}, {})
|
||||
|
||||
export const getNodeDescriptor = (type: string) => nodePaletteMap[type]
|
||||
Reference in New Issue
Block a user