Skip to content

Commit f7ce291

Browse files
committed
fix:update layout
1 parent e57abf2 commit f7ce291

File tree

3 files changed

+39
-34
lines changed

3 files changed

+39
-34
lines changed

web/src/components/WorkFlow/nodes/Plugin/PluginNode.tsx

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,28 @@ import { useSkillsQuery } from "@/hooks/useSkillsQuery"; // 新增导入
66
import ToolsIcon from "@/components/Icons/Tools";
77
import { Box } from "@chakra-ui/react";
88

9-
const { colorScheme } = nodeConfig.plugin;
10-
119
const PluginNode: React.FC<NodeProps> = (props) => {
1210
const { data: skills } = useSkillsQuery(); // 获取工具信息
1311
// 获取工具名称
14-
// const toolName = skills?.data.find(skill => skill.name === props.data.toolName)?.display_name || props.data.toolName;
15-
const { icon: Icon, colorScheme } = nodeConfig.plugin;
12+
const toolName =
13+
skills?.data.find((skill) => skill.name === props.data.toolName)
14+
?.display_name || props.data.toolName;
15+
const { colorScheme } = nodeConfig.plugin;
16+
1617
return (
17-
<BaseNode {...props} icon={<Icon />} colorScheme={colorScheme}>
18-
<Handle type="target" position={Position.Left} id="left" />
19-
<Handle type="target" position={Position.Right} id="right" />
20-
<Handle type="source" position={Position.Left} id="left" />
21-
<Handle type="source" position={Position.Right} id="right" />
22-
<Box style={{ padding: '10px', border: '1px solid #ddd', borderRadius: '4px', backgroundColor: '#fff' }}>
23-
{/* <ToolsIcon tools_name={toolName.replace(/ /g, "_")} /> */}
24-
{/* <Box>{toolName}</Box> */}
25-
</Box>
18+
<BaseNode
19+
{...props}
20+
icon={<ToolsIcon tools_name={toolName.replace(/ /g, "_")} w={6} h={6} />}
21+
colorScheme={colorScheme}
22+
>
23+
<>
24+
<Handle type="target" position={Position.Left} id="left" />
25+
<Handle type="target" position={Position.Right} id="right" />
26+
<Handle type="source" position={Position.Left} id="left" />
27+
<Handle type="source" position={Position.Right} id="right" />
28+
</>
2629
</BaseNode>
2730
);
2831
};
2932

30-
export default React.memo(PluginNode);
33+
export default React.memo(PluginNode);

web/src/components/WorkFlow/nodes/Plugin/PluginNodeProperties.tsx

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ const PluginNodeProperties: React.FC<PluginNodePropertiesProps> = ({
1515
}) => {
1616
const { data: skills } = useSkillsQuery(); // 获取工具信息
1717
// 根据 node.data.toolName 匹配工具
18-
const tool = skills?.data.find(skill => skill.display_name === node.data.toolName); // 获取当前工具
18+
const tool = skills?.data.find(
19+
(skill) => skill.display_name === node.data.toolName
20+
); // 获取当前工具
1921
const [loading, setLoading] = useState(false); // 加载状态
2022

2123
const handleInvoke = async () => {
@@ -36,29 +38,29 @@ const PluginNodeProperties: React.FC<PluginNodePropertiesProps> = ({
3638
return (
3739
<VStack align="stretch" spacing={4}>
3840
<Box>
39-
<Text fontWeight="bold">Tool Name:</Text>
40-
<Text>{tool?.display_name || node.data.toolName}</Text> {/* 显示工具名称 */}
41+
<Text fontWeight="bold">Input param:</Text>
4142
</Box>
42-
{tool?.input_parameters && Object.entries(tool.input_parameters).map(([key, value]) => (
43-
<Box key={key}>
44-
<Text fontWeight="bold">{key}:</Text>
45-
<Input
46-
value={node.data.args[key] || ""}
47-
onChange={(e) =>
48-
onNodeDataChange(node.id, "args", {
49-
...node.data.args,
50-
[key]: e.target.value,
51-
})
52-
}
53-
placeholder={`Enter ${key}`}
54-
/>
55-
</Box>
56-
))}
43+
{tool?.input_parameters &&
44+
Object.entries(tool.input_parameters).map(([key, value]) => (
45+
<Box key={key}>
46+
<Text fontWeight="bold">{key}:</Text>
47+
<Input
48+
value={node.data.args[key] || ""}
49+
onChange={(e) =>
50+
onNodeDataChange(node.id, "args", {
51+
...node.data.args,
52+
[key]: e.target.value,
53+
})
54+
}
55+
placeholder={`Enter ${key}`}
56+
/>
57+
</Box>
58+
))}
5759
<Button onClick={handleInvoke} isLoading={loading}>
5860
Run Tool
5961
</Button>
6062
</VStack>
6163
);
6264
};
6365

64-
export default PluginNodeProperties;
66+
export default PluginNodeProperties;

web/src/components/WorkFlow/nodes/nodeConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export const nodeConfig: Record<string, NodeConfigItem> = {
8181
plugin: {
8282
display: "Plugin",
8383
icon: TfiGithub, // 你需要定义一个图标
84-
colorScheme: "blue",
84+
colorScheme: "gray",
8585
properties: PluginNodeProperties, // 如果有特定的属性面板
8686
initialData: {
8787
toolName: "", // 工具名称

0 commit comments

Comments
 (0)