From ffbd32b11322e1b023d8a69c61d0f2ae75741b29 Mon Sep 17 00:00:00 2001 From: vito Date: Tue, 22 Nov 2016 17:21:42 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=97=A0jira=E4=BB=BB=E5=8A=A1=20bugfix?= =?UTF-8?q?=EF=BC=9A=E8=84=9A=E6=9C=AC=E9=A1=B5=E9=9D=A2=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E4=B8=A4=E9=81=8D=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/extra/ShopPaneConfig.java | 24 ++++++++++++++----- .../design/extra/WebManagerPaneFactory.java | 16 ++++++------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/ShopPaneConfig.java b/designer_base/src/com/fr/design/extra/ShopPaneConfig.java index 87bc719ee..9d265168d 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 75a79dedd..faf67d177 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()); } }); } From 221e2fa8604b24aa66eb50c237917be207b4188e Mon Sep 17 00:00:00 2001 From: vito Date: Wed, 23 Nov 2016 01:08:07 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E8=BD=AC=E4=B9=89json=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E5=8D=95=E5=BC=95=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/extra/PluginTask.java | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/PluginTask.java b/designer_base/src/com/fr/design/extra/PluginTask.java index eb4a99729..7c624612f 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,28 @@ 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方法的参数,现在规范和拼接的json都能通过了, + * 但是强烈建议不要使用拼接json + *

+ * 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)) { + String a = old.replaceAll("\n", "").replaceAll("\"", "\\\\\"").replaceAll("\'", "\\\\\'"); + System.out.println(a); + return a; } return StringUtils.EMPTY; } From a964740d3146d50c590b040ce8157a408f05faa1 Mon Sep 17 00:00:00 2001 From: vito Date: Wed, 23 Nov 2016 10:19:43 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer_base/src/com/fr/design/extra/PluginTask.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/PluginTask.java b/designer_base/src/com/fr/design/extra/PluginTask.java index 7c624612f..0e77ae823 100644 --- a/designer_base/src/com/fr/design/extra/PluginTask.java +++ b/designer_base/src/com/fr/design/extra/PluginTask.java @@ -65,9 +65,8 @@ public class PluginTask extends Task { /** * vito:由于使用webEngine.executeScript("(" + callback + ")(\"" + newValue + "\")") * 执行脚本,所以原来规范的json格式也会在拼接字符串后可能抛出参数异常,需要转换掉一些会造成错误的特殊字符, - * 选择在java端替换的原因是异常抛出自executeScript方法的参数,现在规范和拼接的json都能通过了, - * 但是强烈建议不要使用拼接json - *

+ * 选择在java端替换的原因是异常抛出自executeScript方法的参数. + * * 1.""中的""必须转义 * 2.js字符串中的\n会导致js字符串变成多行,而js字符串不支持多行拼接 * 3.由JSONObject.toString()得到的字符串中html标签的属性会自动加上\造成替换难度加大, From 538753ab2b6e3d17d478cd3d3ac61f9b4c780f26 Mon Sep 17 00:00:00 2001 From: vito Date: Wed, 23 Nov 2016 10:20:55 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=BC=8F=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer_base/src/com/fr/design/extra/PluginTask.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/PluginTask.java b/designer_base/src/com/fr/design/extra/PluginTask.java index 0e77ae823..e2c87a46e 100644 --- a/designer_base/src/com/fr/design/extra/PluginTask.java +++ b/designer_base/src/com/fr/design/extra/PluginTask.java @@ -77,9 +77,7 @@ public class PluginTask extends Task { */ private String trimText(String old) { if (StringUtils.isNotBlank(old)) { - String a = old.replaceAll("\n", "").replaceAll("\"", "\\\\\"").replaceAll("\'", "\\\\\'"); - System.out.println(a); - return a; + return old.replaceAll("\n", "").replaceAll("\"", "\\\\\"").replaceAll("\'", "\\\\\'"); } return StringUtils.EMPTY; }