Browse Source

fix: 起始节点,不允许编写代码, 修正JSONEditor赋值异常处理

master
i5ting 3 years ago
parent
commit
c337f4e8cc
  1. 12
      packages/core/src/components/codeRun/index.tsx
  2. 6
      packages/core/src/mods/flowChart/createFlowChart.ts

12
packages/core/src/components/codeRun/index.tsx

@ -41,6 +41,11 @@ interface ICodeRunProps {
flowChart: Graph; flowChart: Graph;
} }
function isJson(obj: any) {
var t = typeof obj;
return ['boolean', 'number', 'string', 'symbol', 'function'].indexOf(t) == -1;
}
const CodeRun: React.FC<ICodeRunProps> = (props) => { const CodeRun: React.FC<ICodeRunProps> = (props) => {
const { flowChart } = props; const { flowChart } = props;
const [isRunning, setIsRunning] = useState(false); const [isRunning, setIsRunning] = useState(false);
@ -51,7 +56,12 @@ const CodeRun: React.FC<ICodeRunProps> = (props) => {
// NOTE: listen the event that iMove online exec ends // NOTE: listen the event that iMove online exec ends
const handler = (data: any) => { const handler = (data: any) => {
setIsRunning(false); setIsRunning(false);
setOutput(data.detail || {}); // console.dir(data)
if (isJson(data.detail) == true) {
setOutput(data.detail || {});
// console.dir( data.detail)
}
}; };
window.addEventListener('iMoveOnlineExecEnds', handler); window.addEventListener('iMoveOnlineExecEnds', handler);
return () => { return () => {

6
packages/core/src/mods/flowChart/createFlowChart.ts

@ -53,7 +53,11 @@ const registerEvents = (flowChart: Graph): void => {
} }
}); });
flowChart.on('node:dblclick', () => { 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) => { flowChart.on('blank:contextmenu', (args) => {
const { const {

Loading…
Cancel
Save