diff --git a/packages/core/src/components/codeRun/index.tsx b/packages/core/src/components/codeRun/index.tsx index 4aa66fb..3801308 100644 --- a/packages/core/src/components/codeRun/index.tsx +++ b/packages/core/src/components/codeRun/index.tsx @@ -41,6 +41,11 @@ interface ICodeRunProps { flowChart: Graph; } +function isJson(obj: any) { + var t = typeof obj; + return ['boolean', 'number', 'string', 'symbol', 'function'].indexOf(t) == -1; +} + const CodeRun: React.FC = (props) => { const { flowChart } = props; const [isRunning, setIsRunning] = useState(false); @@ -51,7 +56,12 @@ const CodeRun: React.FC = (props) => { // NOTE: listen the event that iMove online exec ends const handler = (data: any) => { setIsRunning(false); - setOutput(data.detail || {}); + // console.dir(data) + + if (isJson(data.detail) == true) { + setOutput(data.detail || {}); + // console.dir( data.detail) + } }; window.addEventListener('iMoveOnlineExecEnds', handler); return () => { diff --git a/packages/core/src/mods/flowChart/createFlowChart.ts b/packages/core/src/mods/flowChart/createFlowChart.ts index fa78646..5ed92de 100644 --- a/packages/core/src/mods/flowChart/createFlowChart.ts +++ b/packages/core/src/mods/flowChart/createFlowChart.ts @@ -53,7 +53,11 @@ const registerEvents = (flowChart: Graph): void => { } }); flowChart.on('node:dblclick', () => { - flowChart.trigger('graph:editCode'); + if (flowChart.getSelectedCells()[0]['shape'] === "imove-start") { + alert('起始节点,不允许编写代码') + } else { + flowChart.trigger('graph:editCode'); + } }); flowChart.on('blank:contextmenu', (args) => { const {