diff --git a/designer_base/src/com/fr/design/extra/PluginTask.java b/designer_base/src/com/fr/design/extra/PluginTask.java index eb4a997291..e2c87a46e1 100644 --- a/designer_base/src/com/fr/design/extra/PluginTask.java +++ b/designer_base/src/com/fr/design/extra/PluginTask.java @@ -49,7 +49,7 @@ public class PluginTask extends Task { @Override public void process(String s) { if (StringUtils.isNotBlank(s)) { - updateMessage(changText(s)); + updateMessage(trimText(s)); } } }); @@ -59,20 +59,25 @@ public class PluginTask extends Task { @Override protected void done() { - updateMessage(changText(executor.getTaskFinishMessage())); + updateMessage(trimText(executor.getTaskFinishMessage())); } /** - * 转换掉一些会造成错误的特殊字符 - * 1 ""中的""必须转义 - * 2 js字符串中的\n会导致js字符串变成多行,而js字符创不支持多行拼接 + * vito:由于使用webEngine.executeScript("(" + callback + ")(\"" + newValue + "\")") + * 执行脚本,所以原来规范的json格式也会在拼接字符串后可能抛出参数异常,需要转换掉一些会造成错误的特殊字符, + * 选择在java端替换的原因是异常抛出自executeScript方法的参数. + * + * 1.""中的""必须转义 + * 2.js字符串中的\n会导致js字符串变成多行,而js字符串不支持多行拼接 + * 3.由JSONObject.toString()得到的字符串中html标签的属性会自动加上\造成替换难度加大, + * 这边建议去除所有的html标签 * * @param old 原始字符串 * @return 处理之后的字符串 */ - private String changText(String old) { - if(StringUtils.isNotBlank(old)){ - return old.replaceAll("\"", "\\\\\"").replaceAll("\n", ""); + private String trimText(String old) { + if (StringUtils.isNotBlank(old)) { + return old.replaceAll("\n", "").replaceAll("\"", "\\\\\"").replaceAll("\'", "\\\\\'"); } return StringUtils.EMPTY; } diff --git a/designer_base/src/com/fr/design/extra/ShopPaneConfig.java b/designer_base/src/com/fr/design/extra/ShopPaneConfig.java index 87bc719ee1..9d265168db 100644 --- a/designer_base/src/com/fr/design/extra/ShopPaneConfig.java +++ b/designer_base/src/com/fr/design/extra/ShopPaneConfig.java @@ -11,14 +11,26 @@ public abstract class ShopPaneConfig { private JFXPanel webPane; public ShopPaneConfig() { - this.mainJS = getMainJS(); - this.scriptsId = getScriptsId(); - this.webPane = getWebPane(); + this.mainJS = setMainJS(); + this.scriptsId = setScriptsId(); + this.webPane = setWebPane(); } - abstract String getMainJS(); + abstract String setMainJS(); - abstract String getScriptsId(); + abstract String setScriptsId(); - abstract JFXPanel getWebPane(); + abstract JFXPanel setWebPane(); + + public String getMainJS() { + return mainJS; + } + + public String getScriptsId() { + return scriptsId; + } + + public JFXPanel getWebPane() { + return webPane; + } } diff --git a/designer_base/src/com/fr/design/extra/WebManagerPaneFactory.java b/designer_base/src/com/fr/design/extra/WebManagerPaneFactory.java index 75a79deddd..faf67d1778 100644 --- a/designer_base/src/com/fr/design/extra/WebManagerPaneFactory.java +++ b/designer_base/src/com/fr/design/extra/WebManagerPaneFactory.java @@ -29,19 +29,19 @@ public class WebManagerPaneFactory { if (StableUtils.getMajorJavaVersion() == 8) { return new ShopManagerPane(new ShopPaneConfig() { @Override - String getMainJS() { + String setMainJS() { String relativePath = "/scripts/store/web/index.html"; return StableUtils.pathJoin(new File(installHome).getAbsolutePath(), relativePath); } @Override - String getScriptsId() { + String setScriptsId() { return "shop_scripts"; } @Override - JFXPanel getWebPane() { - return new PluginWebPane(getMainJS()); + JFXPanel setWebPane() { + return new PluginWebPane(setMainJS()); } }); @@ -61,19 +61,19 @@ public class WebManagerPaneFactory { public BasicPane createReusePane() { return new ShopManagerPane(new ShopPaneConfig() { @Override - String getMainJS() { + String setMainJS() { String relativePath = "/scripts/store/reuse/index.html"; return StableUtils.pathJoin(new File(installHome).getAbsolutePath(), relativePath); } @Override - String getScriptsId() { + String setScriptsId() { return "reuse_scripts"; } @Override - JFXPanel getWebPane() { - return new ReuseWebPane(getMainJS()); + JFXPanel setWebPane() { + return new ReuseWebPane(setMainJS()); } }); }