From c337f4e8cce3bb8a56995fbe6de7ca5851cd63fd Mon Sep 17 00:00:00 2001 From: i5ting Date: Sat, 30 Oct 2021 14:50:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B5=B7=E5=A7=8B=E8=8A=82=E7=82=B9?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E5=85=81=E8=AE=B8=E7=BC=96=E5=86=99=E4=BB=A3?= =?UTF-8?q?=E7=A0=81,=20=E4=BF=AE=E6=AD=A3JSONEditor=E8=B5=8B=E5=80=BC?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/src/components/codeRun/index.tsx | 12 +++++++++++- packages/core/src/mods/flowChart/createFlowChart.ts | 6 +++++- 2 files changed, 16 insertions(+), 2 deletions(-) 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 {