网关跟定时器无错。
This commit is contained in:
parent
fedcec4da3
commit
d6f3648229
@ -112,23 +112,27 @@ const NodeConfig: React.FC<NodeConfigProps> = ({ nodeType, form, onValuesChange
|
|||||||
const renderTimerConfig = () => {
|
const renderTimerConfig = () => {
|
||||||
if (!nodeType.code?.includes('TIMER')) return null;
|
if (!nodeType.code?.includes('TIMER')) return null;
|
||||||
|
|
||||||
|
// 从schema中获取cron字段的配置
|
||||||
|
const cronField = nodeSchema?.properties?.cron;
|
||||||
|
if (!cronField) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label="CRON表达式"
|
label={cronField.title || "CRON表达式"}
|
||||||
name="cron"
|
name="cron"
|
||||||
tooltip="定时触发的CRON表达式"
|
tooltip={cronField.description}
|
||||||
rules={[
|
rules={[
|
||||||
{
|
{
|
||||||
required: true,
|
required: nodeSchema?.required?.includes('cron'),
|
||||||
message: '请输入CRON表达式'
|
message: '请输入CRON表达式'
|
||||||
},
|
},
|
||||||
{
|
...(cronField.pattern ? [{
|
||||||
pattern: /^(\d+|\*|\*\/\d+|\d+\-\d+|\d+(,\d+)*) (\d+|\*|\*\/\d+|\d+\-\d+|\d+(,\d+)*) (\d+|\*|\*\/\d+|\d+\-\d+|\d+(,\d+)*) (\d+|\*|\*\/\d+|\d+\-\d+|\d+(,\d+)*) (\d+|\*|\*\/\d+|\d+\-\d+|\d+(,\d+)*) (\d+|\*|\*\/\d+|\d+\-\d+|\d+(,\d+)*)$/,
|
pattern: new RegExp(cronField.pattern),
|
||||||
message: '请输入有效的CRON表达式'
|
message: '请输入有效的CRON表达式'
|
||||||
}
|
}] : [])
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Input placeholder="例如: 0 0 * * * *" />
|
<Input placeholder={`例如: ${cronField.examples?.[0] || ''}`} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -6,17 +6,17 @@ import {getDefinition, updateDefinition} from '../../service';
|
|||||||
import {WorkflowDefinition, WorkflowStatus} from '../../../Workflow/types';
|
import {WorkflowDefinition, WorkflowStatus} from '../../../Workflow/types';
|
||||||
import {Graph, Node, Cell} from '@antv/x6';
|
import {Graph, Node, Cell} from '@antv/x6';
|
||||||
import '@antv/x6-react-shape';
|
import '@antv/x6-react-shape';
|
||||||
import { Selection } from '@antv/x6-plugin-selection';
|
import {Selection} from '@antv/x6-plugin-selection';
|
||||||
import { History } from '@antv/x6-plugin-history';
|
import {History} from '@antv/x6-plugin-history';
|
||||||
import { Clipboard } from '@antv/x6-plugin-clipboard';
|
import {Clipboard} from '@antv/x6-plugin-clipboard';
|
||||||
import { Transform } from '@antv/x6-plugin-transform';
|
import {Transform} from '@antv/x6-plugin-transform';
|
||||||
import { Keyboard } from '@antv/x6-plugin-keyboard';
|
import {Keyboard} from '@antv/x6-plugin-keyboard';
|
||||||
import { Snapline } from '@antv/x6-plugin-snapline';
|
import {Snapline} from '@antv/x6-plugin-snapline';
|
||||||
import './index.module.less';
|
import './index.module.less';
|
||||||
import NodePanel from './components/NodePanel';
|
import NodePanel from './components/NodePanel';
|
||||||
import NodeConfig from './components/NodeConfig';
|
import NodeConfig from './components/NodeConfig';
|
||||||
import Toolbar from './components/Toolbar';
|
import Toolbar from './components/Toolbar';
|
||||||
import { NodeType, getNodeTypes } from './service';
|
import {NodeType, getNodeTypes} from './service';
|
||||||
|
|
||||||
const {Sider, Content} = Layout;
|
const {Sider, Content} = Layout;
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ const FlowDesigner: React.FC = () => {
|
|||||||
// 获取所有节点类型
|
// 获取所有节点类型
|
||||||
const fetchNodeTypes = async () => {
|
const fetchNodeTypes = async () => {
|
||||||
try {
|
try {
|
||||||
const types = await getNodeTypes({ enabled: true });
|
const types = await getNodeTypes({enabled: true});
|
||||||
setNodeTypes(types);
|
setNodeTypes(types);
|
||||||
return types;
|
return types;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -258,7 +258,7 @@ const FlowDesigner: React.FC = () => {
|
|||||||
containerRef.current.addEventListener('drop', handleDrop);
|
containerRef.current.addEventListener('drop', handleDrop);
|
||||||
|
|
||||||
// 监听节点点击事件
|
// 监听节点点击事件
|
||||||
graph.on('node:click', ({node}: {node: Node}) => {
|
graph.on('node:click', ({node}: { node: Node }) => {
|
||||||
setCurrentNode(node);
|
setCurrentNode(node);
|
||||||
const data = node.getData() as NodeData;
|
const data = node.getData() as NodeData;
|
||||||
console.log('Node clicked, data:', data);
|
console.log('Node clicked, data:', data);
|
||||||
@ -273,23 +273,9 @@ const FlowDesigner: React.FC = () => {
|
|||||||
const formValues = {
|
const formValues = {
|
||||||
name: data.name || nodeType.name,
|
name: data.name || nodeType.name,
|
||||||
description: data.description,
|
description: data.description,
|
||||||
executor: data.config?.executor,
|
...data.config // 直接展开所有配置
|
||||||
};
|
};
|
||||||
|
|
||||||
// 如果是Shell节点,添加执行器特定配置
|
|
||||||
if (data.type === 'SHELL' && data.config?.executor === 'SHELL') {
|
|
||||||
console.log('Shell node config:', data.config);
|
|
||||||
Object.assign(formValues, {
|
|
||||||
script: data.config.script,
|
|
||||||
timeout: data.config.timeout,
|
|
||||||
workingDirectory: data.config.workingDirectory,
|
|
||||||
environment: data.config.environment,
|
|
||||||
successExitCode: data.config.successExitCode,
|
|
||||||
retryTimes: data.config.retryTimes,
|
|
||||||
retryInterval: data.config.retryInterval,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('Setting form values:', formValues);
|
console.log('Setting form values:', formValues);
|
||||||
form.setFieldsValue(formValues);
|
form.setFieldsValue(formValues);
|
||||||
setConfigVisible(true);
|
setConfigVisible(true);
|
||||||
@ -445,7 +431,7 @@ const FlowDesigner: React.FC = () => {
|
|||||||
const values = await form.validateFields();
|
const values = await form.validateFields();
|
||||||
if (currentNode) {
|
if (currentNode) {
|
||||||
const data = currentNode.getData() as NodeData;
|
const data = currentNode.getData() as NodeData;
|
||||||
const { name, description, ...config } = values;
|
const {name, description, ...config} = values;
|
||||||
|
|
||||||
// 如果是Shell节点,验证配置
|
// 如果是Shell节点,验证配置
|
||||||
if (data.type === 'SHELL' && config.executor === 'SHELL') {
|
if (data.type === 'SHELL' && config.executor === 'SHELL') {
|
||||||
@ -510,7 +496,7 @@ const FlowDesigner: React.FC = () => {
|
|||||||
const data = {
|
const data = {
|
||||||
...detail,
|
...detail,
|
||||||
graphDefinition: JSON.stringify(graphData),
|
graphDefinition: JSON.stringify(graphData),
|
||||||
nodeConfig: JSON.stringify({ nodes })
|
nodeConfig: JSON.stringify({nodes})
|
||||||
};
|
};
|
||||||
|
|
||||||
// 调用更新接口
|
// 调用更新接口
|
||||||
@ -563,15 +549,12 @@ const FlowDesigner: React.FC = () => {
|
|||||||
|
|
||||||
// 加载节点配置数据
|
// 加载节点配置数据
|
||||||
if (detail.nodeConfig) {
|
if (detail.nodeConfig) {
|
||||||
console.log('Loading node config:', detail.nodeConfig);
|
|
||||||
const nodeConfigData = JSON.parse(detail.nodeConfig);
|
const nodeConfigData = JSON.parse(detail.nodeConfig);
|
||||||
console.log('Parsed node config:', nodeConfigData);
|
|
||||||
|
|
||||||
// 更新节点数据和显示
|
// 更新节点数据和显示
|
||||||
graph.getNodes().forEach(node => {
|
graph.getNodes().forEach(node => {
|
||||||
const nodeConfig = nodeConfigData.nodes.find((n: any) => n.id === node.id);
|
const nodeConfig = nodeConfigData.nodes.find((n: any) => n.id === node.id);
|
||||||
if (nodeConfig) {
|
if (nodeConfig) {
|
||||||
console.log('Node config found:', nodeConfig);
|
console.log('Node config found:', nodeConfig.config);
|
||||||
const nodeData = {
|
const nodeData = {
|
||||||
type: nodeConfig.type,
|
type: nodeConfig.type,
|
||||||
name: nodeConfig.name,
|
name: nodeConfig.name,
|
||||||
@ -622,7 +605,7 @@ const FlowDesigner: React.FC = () => {
|
|||||||
<NodePanel onNodeDragStart={handleNodeDragStart}/>
|
<NodePanel onNodeDragStart={handleNodeDragStart}/>
|
||||||
</Sider>
|
</Sider>
|
||||||
<Layout>
|
<Layout>
|
||||||
<Toolbar graph={graph} />
|
<Toolbar graph={graph}/>
|
||||||
<Content className="workflow-designer-content">
|
<Content className="workflow-designer-content">
|
||||||
<div ref={containerRef} className="workflow-designer-graph"/>
|
<div ref={containerRef} className="workflow-designer-graph"/>
|
||||||
</Content>
|
</Content>
|
||||||
@ -644,7 +627,7 @@ const FlowDesigner: React.FC = () => {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
{currentNodeType && (
|
{currentNodeType && (
|
||||||
<NodeConfig nodeType={currentNodeType} form={form} />
|
<NodeConfig nodeType={currentNodeType} form={form}/>
|
||||||
)}
|
)}
|
||||||
</Drawer>
|
</Drawer>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user