From cff3586c102e855f9690ef5870bcd1f88f742557 Mon Sep 17 00:00:00 2001 From: shine Date: Fri, 26 Feb 2021 10:54:06 +0800 Subject: [PATCH] =?UTF-8?q?CHART-18181=20=E8=AE=BE=E7=BD=AE=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/ui/Assistant.java | 11 +++++++++++ .../main/java/com/fr/design/ui/ModernUIPane.java | 14 +++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/ui/Assistant.java b/designer-base/src/main/java/com/fr/design/ui/Assistant.java index 7e9430672..6a04cf358 100644 --- a/designer-base/src/main/java/com/fr/design/ui/Assistant.java +++ b/designer-base/src/main/java/com/fr/design/ui/Assistant.java @@ -3,6 +3,7 @@ package com.fr.design.ui; import com.fr.stable.StringUtils; import com.teamdev.jxbrowser.chromium.Browser; import com.teamdev.jxbrowser.chromium.BrowserContext; +import com.teamdev.jxbrowser.chromium.BrowserPreferences; import com.teamdev.jxbrowser.chromium.ProtocolService; import com.teamdev.jxbrowser.chromium.URLResponse; @@ -12,6 +13,8 @@ import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Collections; +import java.util.List; /** * @author richie @@ -20,6 +23,14 @@ import java.nio.file.Path; */ public class Assistant { + public static void addChromiumSwitches(String... switches) { + + List list = BrowserPreferences.getChromiumSwitches(); + Collections.addAll(list, switches); + + BrowserPreferences.setChromiumSwitches((list.toArray(new String[0]))); + } + public static URLResponse inputStream2Response(InputStream inputStream, String filePath) throws Exception { URLResponse response = new URLResponse(); DataInputStream stream = new DataInputStream(inputStream); diff --git a/designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java b/designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java index 4a92d3715..745c56ea7 100644 --- a/designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java +++ b/designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java @@ -8,18 +8,18 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.web.struct.AssembleComponent; import com.teamdev.jxbrowser.chromium.Browser; -import com.teamdev.jxbrowser.chromium.BrowserPreferences; import com.teamdev.jxbrowser.chromium.JSValue; -import com.teamdev.jxbrowser.chromium.events.FinishLoadingEvent; -import com.teamdev.jxbrowser.chromium.events.LoadAdapter; import com.teamdev.jxbrowser.chromium.events.LoadListener; import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter; import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent; import com.teamdev.jxbrowser.chromium.events.ScriptContextListener; import com.teamdev.jxbrowser.chromium.swing.BrowserView; -import javax.swing.*; -import java.awt.*; +import javax.swing.JDialog; +import javax.swing.SwingUtilities; +import javax.swing.WindowConstants; +import java.awt.BorderLayout; +import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Map; @@ -44,7 +44,7 @@ public class ModernUIPane extends BasicPane { private void initialize() { if (browser == null) { setLayout(new BorderLayout()); - BrowserPreferences.setChromiumSwitches("--disable-google-traffic"); + Assistant.addChromiumSwitches("--disable-google-traffic"); if (DesignerEnvManager.getEnvManager().isOpenDebug()) { UIToolbar toolbar = new UIToolbar(); add(toolbar, BorderLayout.NORTH); @@ -75,7 +75,7 @@ public class ModernUIPane extends BasicPane { SwingUtilities.getWindowAncestor(ModernUIPane.this).setVisible(false); } }); - BrowserPreferences.setChromiumSwitches("--remote-debugging-port=9222"); + Assistant.addChromiumSwitches("--remote-debugging-port=9222"); initializeBrowser(); add(new BrowserView(browser), BorderLayout.CENTER); } else {