import { Group, SelectionSelect } from "@logicflow/extension"; import { registerCommon } from "./nodes/common/index"; import { registerFunction } from './nodes/function' import cameraSvg from './icon/camera.svg' import videoSvg from './icon/video.svg' import loopSvg from './icon/loop.svg' import stopLoopSvg from './icon/stopLoop.svg' import switchSvg from './icon/switch.svg' import startSvg from './icon/start.svg' import endSvg from './icon/end.svg' import microphoneSvg from './icon/microphone.svg' import sleepSvg from './icon/sleep.svg' import { v4 as randomUUID } from 'uuid' import { useFlowStore } from "@/store/modules/flow"; const flowStore = useFlowStore(); export const lfConfig = { idGenerator: () => { // 生成标准UUID并移除连字符 // return crypto.randomUUID().replace(/-/g, ''); return randomUUID().replace(/-/g, '') }, background: { backgroundColor: "#f6f8fa", }, grid: false, plugins: [Group, SelectionSelect], animation: true, adjustEdgeStartAndEnd: false, // multipleSelectKey: "ctrl", // disabledTools: ["multipleSelect"], partial: true, // group: { // foldable: true, // 启用折叠功能 // foldSize: 30, // 折叠后显示的图标尺寸 // }, edgeType: "bezier", style: { anchor: { show: true, // 强制全局锚点显示 hoverOn: false, visibility: "visible", fill: "#FF5722", // 实心绿色 stroke: "#FF5722", // 边框同色 strokeWidth: 0, // 消除边框 r: 7, // 锚点半径 hover: { fill: "#FF5722" }, // 禁用悬停变色 }, anchorLine: { stroke: "#FF5722", strokeWidth: 2, strokeDasharray: "3,2", }, bezier: { stroke: "#FF5722", strokeWidth: 2, arrow: false, // 关闭箭头显示 animation: true, // 开启动画效果 animationSpeed: 3, }, }, }; // 注册自定义节点 export const registerCustomizeNode = (lf) => { registerCommon(lf) registerFunction(lf) }; const deviceOptions = () => { return ['cam1', 'cam2', 'cam3', 'cam4'] } const audioOptions = () => { return ['spk1'] } export const collapseList = [ { collapseTitle: "相机", nodeList: [ { icon: cameraSvg, name: "开启相机", type: "serviceNode", desc: "在获取相机照片时,需要先启动相机", action: 'CAMERA_START', nodeParams: [ { name: "deviceId", type: "input", input: "", componentType: 'select', selectOptions: deviceOptions(), disabled: true } ], outputType: 'json' }, { icon: cameraSvg, name: "获取图片", type: "serviceNode", desc: "获取相机拍摄的照片", action: 'CAMERA_GETRGBIMAGE', nodeParams: [ { name: "deviceId", type: "input", input: "", componentType: 'select', selectOptions: deviceOptions(), disabled: true } ], outputType: 'img', outputParams: [{ name: 'imageUrl', type: 'array', desc: '图片地址数组', disabled: true}] }, { icon: cameraSvg, name: "关闭相机", type: "serviceNode", desc: "获取相机照片后,关闭该相机", action: 'CAMERA_STOP', nodeParams: [ { name: "deviceId", type: "input", input: "", componentType: 'select', selectOptions: deviceOptions(), disabled: true } ], outputType: 'json' }, ], }, { collapseTitle: "录像", nodeList: [ { icon: videoSvg, name: "开启录像", type: "serviceNode", desc: "开启摄像头,并开始录像", action: 'CAMERA_RECORDING_START', nodeParams: [ { name: "deviceId", type: "input", input: "", componentType: 'select', selectOptions: deviceOptions(), disabled: true } ], outputType: 'json' }, { icon: videoSvg, name: "结束录像", type: "serviceNode", desc: "停止录像,并关闭摄像头", action: 'CAMERA_RECORDING_STOP', nodeParams: [ { name: "deviceId", type: "input", input: "", componentType: 'select', selectOptions: deviceOptions(), disabled: true } ], outputType: 'video', outputParams: [{ name: 'videoUrl', type: 'array', desc: '视频播放地址数组'}] } ], }, { collapseTitle: "功能", nodeList: [ { icon: loopSvg, name: "循环", type: "loop", action: 'START_LOOP', desc: "实现对列表对象循环执行一系列任务", }, { icon: stopLoopSvg, name: "结束循环", type: "stopLoop", action: 'STOP_LOOP', desc: "用于立即终止当前所在的循环,跳出循环体", }, { icon: startSvg, name: "单次循环开始", type: "subStart", action: 'SUB_START', desc: "循环体内部工作流的开始节点,开始循环体内部的单次流程", }, { icon: endSvg, name: "单次循环结束", type: "subEnd", action: 'SUB_END', desc: "循环体内部工作流的终止节点,结束循环体内部的单次流程", }, { icon: switchSvg, name: "分支", type: "branch", action: 'BRANCH', desc: "连接多个下游分支,根据设定的条件按照顺序查找的方式来匹配运行的分支,如果匹配到某条件则只运行该条件对应的分支,否则继续匹配下一条件直至结束", }, { icon: sleepSvg, name: "睡眠", type: "sleep", desc: "用于睡眠整个流程,表示延迟多少毫秒", action: 'sleep', nodeParams: [ { name: "delayMs", type: "input", componentType: 'number', input: "", disabled: true } ], outputType: 'json' }, ], }, { collapseTitle: "机器人", nodeList: [ { icon: videoSvg, name: "机械臂", type: "serviceNode", desc: "控制机器人的手臂", action: 'ALM', nodeParams: [ { name: "deviceId", type: "input", input: "", disabled: true } ], outputType: 'json' }, ], }, { collapseTitle: "音频", nodeList: [ { icon: microphoneSvg, name: "启动麦克风", type: "serviceNode", desc: "用于启动麦克风的节点", action: 'MICROPHONE_START', nodeParams: [ { name: "deviceId", type: "input", input: "", componentType: 'select', selectOptions: deviceOptions(), disabled: true } ], outputType: 'json' }, { icon: microphoneSvg, name: "停止麦克风", type: "serviceNode", desc: "用于停止麦克风的节点", action: 'MICROPHONE_START', nodeParams: [ { name: "deviceId", type: "input", input: "", componentType: 'select', selectOptions: deviceOptions(), disabled: true } ], outputType: 'json' }, { icon: microphoneSvg, name: "播放音频", type: "serviceNode", desc: "用于播放音频的节点", action: 'SPEAKER_PLAYAUDIO', nodeParams: [ { name: "deviceId", type: "input", input: "", componentType: 'select', selectOptions: audioOptions(), disabled: true } ], outputType: 'json' }, ], }, { collapseTitle: "大模型", nodeList: [ { icon: microphoneSvg, name: "获取触控坐标", type: "serviceNode", desc: "用于获取触控坐标的节点", action: 'TOUCH_COORDINATES', nodeParams: [ { name: "targetFeature", type: "input", input: "运动模式", disabled: true }, { name: "manufacturer", type: "input", input: "xiaomi", disabled: true }, { name: "vehType", type: "input", input: "su7", disabled: true }, ], outputType: 'json', outputParams: [{ name: 'coordinates', type: 'Object', desc: '坐标对象'}] }, ], }, { collapseTitle: "语音交互", nodeList: [ { icon: microphoneSvg, name: "唤醒语料", type: "serviceNode", desc: "唤醒语料处理", action: 'VI_WAKE_CORPUS', nodeParams: [ { name: "", type: "input", input: ""} ], outputType: 'json', outputParams: [{ name: 'coordinates', type: 'Object', desc: '坐标对象'}] }, ], }, ]