|
|
|
@ -8,6 +8,7 @@ import com.fr.design.ui.ModernUIConstants;
|
|
|
|
|
import com.fr.design.ui.ModernUIPane; |
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
import com.fr.stable.collections.combination.Pair; |
|
|
|
|
import com.fr.stable.os.OperatingSystem; |
|
|
|
|
import com.fr.web.struct.AssembleComponent; |
|
|
|
|
import com.teamdev.jxbrowser.browser.Browser; |
|
|
|
|
import com.teamdev.jxbrowser.browser.callback.InjectJsCallback; |
|
|
|
@ -47,6 +48,12 @@ import static com.fr.design.ui.ModernUIConstants.WINDOW;
|
|
|
|
|
*/ |
|
|
|
|
public class JxUIPane<T> extends ModernUIPane<T> { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 冒号 |
|
|
|
|
*/ |
|
|
|
|
public static final String COLON = ":"; |
|
|
|
|
private static final String COLON_ESCAPE = "\\:"; |
|
|
|
|
|
|
|
|
|
private Browser browser; |
|
|
|
|
private String namespace = "Pool"; |
|
|
|
|
private String variable = "data"; |
|
|
|
@ -126,7 +133,7 @@ public class JxUIPane<T> extends ModernUIPane<T> {
|
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void redirect(String url) { |
|
|
|
|
browser.navigation().loadUrl(url); |
|
|
|
|
browser.navigation().loadUrl(encodeWindowsPath(url)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -138,7 +145,7 @@ public class JxUIPane<T> extends ModernUIPane<T> {
|
|
|
|
|
@Override |
|
|
|
|
public void redirect(String url, Map<String, String> map) { |
|
|
|
|
setMap(map); |
|
|
|
|
browser.navigation().loadUrl(url); |
|
|
|
|
browser.navigation().loadUrl(encodeWindowsPath(url)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void setMap(Map<String, String> map) { |
|
|
|
@ -220,6 +227,18 @@ public class JxUIPane<T> extends ModernUIPane<T> {
|
|
|
|
|
return Optional.ofNullable(frame.executeJavaScript(name)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 由于自定义scheme目前走的是url,因此路径会被自动转化,比如windows路径下对冒号问题 |
|
|
|
|
* C:\\abc 变成 /C/abc,这里对冒号进行编码转义 |
|
|
|
|
*/ |
|
|
|
|
private static String encodeWindowsPath(String path) { |
|
|
|
|
if (OperatingSystem.isWindows() && path.startsWith(EMB_TAG + SCHEME_HEADER)) { |
|
|
|
|
String s = path.split(EMB_TAG + SCHEME_HEADER)[1]; |
|
|
|
|
return EMB_TAG + SCHEME_HEADER + s.replace(COLON, COLON_ESCAPE); |
|
|
|
|
} |
|
|
|
|
return path; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* JxUIPane 的建造者 |
|
|
|
|
* |
|
|
|
@ -492,7 +511,7 @@ public class JxUIPane<T> extends ModernUIPane<T> {
|
|
|
|
|
pane.browser.navigation().on(listenerPair.getFirst(), listenerPair.getSecond()); |
|
|
|
|
} |
|
|
|
|
if (StringUtils.isNotEmpty(this.url)) { |
|
|
|
|
pane.browser.navigation().loadUrl(this.url); |
|
|
|
|
pane.browser.navigation().loadUrl(encodeWindowsPath(this.url)); |
|
|
|
|
} else if (StringUtils.isNotEmpty(this.html)) { |
|
|
|
|
pane.browser.mainFrame().ifPresent(f -> f.loadHtml(html)); |
|
|
|
|
} |
|
|
|
|