From 85f196c8673e9eeafa7fb2ac522dea82d3326ace Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Sun, 10 Jul 2022 17:38:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E7=9A=84parse=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/MotaActionParser.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/_server/MotaActionParser.js b/_server/MotaActionParser.js index caa2cff1..9d7b6774 100644 --- a/_server/MotaActionParser.js +++ b/_server/MotaActionParser.js @@ -1421,11 +1421,14 @@ MotaActionFunctions.workspace = function(){return workspace} MotaActionFunctions.parse = function(obj,type) { try { - obj = JSON.parse(MotaActionFunctions.replaceToName(JSON.stringify(obj))); - } catch (e) {} + obj = obj.map(function (e) { + if (e.type == "function") return e; + else return JSON.parse(MotaActionFunctions.replaceToName(JSON.stringify(e))); + }); + } catch (e) { } MotaActionFunctions.workspace().clear(); - xml_text = MotaActionFunctions.actionParser.parse(obj,type||'event'); - xml = Blockly.Xml.textToDom(''+xml_text+''); + xml_text = MotaActionFunctions.actionParser.parse(obj, type || 'event'); + xml = Blockly.Xml.textToDom('' + xml_text + ''); Blockly.Xml.domToWorkspace(xml, MotaActionFunctions.workspace()); }