Browse Source

Merge pull request #543 in BA/design from ~VITO/design:master to master

* commit '538753ab2b6e3d17d478cd3d3ac61f9b4c780f26':
  漏传
  修改说明
  转义json中的单引号
  无jira任务 bugfix:脚本页面加载两遍的bug
master
superman 8 years ago
parent
commit
c7abfbc1bd
  1. 21
      designer_base/src/com/fr/design/extra/PluginTask.java
  2. 24
      designer_base/src/com/fr/design/extra/ShopPaneConfig.java
  3. 16
      designer_base/src/com/fr/design/extra/WebManagerPaneFactory.java

21
designer_base/src/com/fr/design/extra/PluginTask.java

@ -49,7 +49,7 @@ public class PluginTask<T> extends Task<T> {
@Override
public void process(String s) {
if (StringUtils.isNotBlank(s)) {
updateMessage(changText(s));
updateMessage(trimText(s));
}
}
});
@ -59,20 +59,25 @@ public class PluginTask<T> extends Task<T> {
@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;
}

24
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;
}
}

16
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());
}
});
}

Loading…
Cancel
Save