diff --git a/easyflow-ui-admin/packages/tinyflow-ui/src/components/utils/useRefOptions.svelte.ts b/easyflow-ui-admin/packages/tinyflow-ui/src/components/utils/useRefOptions.svelte.ts index 2f9986e..45d5f63 100644 --- a/easyflow-ui-admin/packages/tinyflow-ui/src/components/utils/useRefOptions.svelte.ts +++ b/easyflow-ui-admin/packages/tinyflow-ui/src/components/utils/useRefOptions.svelte.ts @@ -31,9 +31,11 @@ const getChildren = (params: any, parentId: string, nodeIsChildren: boolean, nod const nodeToOptions = (node: Node, nodeIsChildren: boolean, currentNode: Node) => { const options = getOptions(); - let icon = nodeIcons[node.type]; - if (!icon && options?.customNodes && options.customNodes[node.type]) { - icon = options.customNodes[node.type].icon; + const nodeType = node.type || ''; + + let icon: string | undefined = nodeIcons[nodeType]; + if (!icon && options?.customNodes && options.customNodes[nodeType]) { + icon = options.customNodes[nodeType].icon; } // 如果仍然获取不到,尝试使用 data.icon (作为回退) @@ -43,7 +45,7 @@ const nodeToOptions = (node: Node, nodeIsChildren: boolean, currentNode: Node) = const title = node.data.title; - if (node.type === 'startNode') { + if (nodeType === 'startNode') { const parameters = node.data.parameters as Array; const children = []; if (parameters) @@ -56,7 +58,7 @@ const nodeToOptions = (node: Node, nodeIsChildren: boolean, currentNode: Node) = dataType: dataType, value: node.id + '.' + parameter.name, selectable: true, - nodeType: node.type + nodeType: nodeType }); } return { @@ -64,30 +66,30 @@ const nodeToOptions = (node: Node, nodeIsChildren: boolean, currentNode: Node) = icon: icon, value: node.id, selectable: false, - nodeType: node.type, + nodeType: nodeType, children }; - } else if (node.type === 'loopNode' && currentNode.parentId) { + } else if (nodeType === 'loopNode' && currentNode.parentId) { return { label: title, icon: icon, value: node.id, selectable: false, - nodeType: node.type, + nodeType: nodeType, children: [ { label: 'loopItem', dataType: 'Any', value: node.id + '.loopItem', selectable: true, - nodeType: node.type + nodeType: nodeType }, { label: 'index', dataType: 'Number', value: node.id + '.index', selectable: true, - nodeType: node.type + nodeType: nodeType } ] }; @@ -99,8 +101,8 @@ const nodeToOptions = (node: Node, nodeIsChildren: boolean, currentNode: Node) = icon: icon, value: node.id, selectable: false, - nodeType: node.type, - children: getChildren(outputDefs, node.id, nodeIsChildren, node.type) + nodeType: nodeType, + children: getChildren(outputDefs, node.id, nodeIsChildren, nodeType) }; } }