fix(tinyflow-ui): resolve typescript compilation errors in useRefOptions
This commit is contained in:
@@ -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<Parameter>;
|
||||
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)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user