diff --git a/CollapseLauncher/Classes/EventsManagement/EventsHandler.cs b/CollapseLauncher/Classes/EventsManagement/EventsHandler.cs index f39c03509..46ad4aeda 100644 --- a/CollapseLauncher/Classes/EventsManagement/EventsHandler.cs +++ b/CollapseLauncher/Classes/EventsManagement/EventsHandler.cs @@ -1,6 +1,5 @@ using Hi3Helper; using Hi3Helper.Data; -using Hi3Helper.Http; using Hi3Helper.Shared.ClassStruct; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; @@ -8,7 +7,7 @@ using Squirrel; using System; using System.Collections.Generic; -using System.IO; +using System.Diagnostics; using System.Threading.Tasks; using Windows.Foundation; using Windows.Networking.Connectivity; @@ -329,7 +328,18 @@ internal BackgroundImgProperty(string ImgPath, bool IsCustom) internal static class SpawnWebView2 { static SpawnWebView2Invoker invoker = new SpawnWebView2Invoker(); - public static void SpawnWebView2Window(string URL) => invoker.SpawnWebView2Window(URL); + public static void SpawnWebView2Window(string URL) + { + if (GetAppConfigValue("UseExternalBrowser").ToBool()) + { + Process.Start(new ProcessStartInfo + { + FileName = URL, + UseShellExecute = true, + }); + } + else invoker.SpawnWebView2Window(URL); + } } internal class SpawnWebView2Invoker diff --git a/CollapseLauncher/XAMLs/MainApp/Pages/SettingsPage.xaml.cs b/CollapseLauncher/XAMLs/MainApp/Pages/SettingsPage.xaml.cs index 9c8d58b0c..6ccf73355 100644 --- a/CollapseLauncher/XAMLs/MainApp/Pages/SettingsPage.xaml.cs +++ b/CollapseLauncher/XAMLs/MainApp/Pages/SettingsPage.xaml.cs @@ -649,7 +649,7 @@ private bool IsLowerCollapsePriorityOnGameLaunch private bool IsAlwaysUseExternalBrowser { - get => GetAppConfigValue("UserExternalBrowser").ToBool(); + get => GetAppConfigValue("UseExternalBrowser").ToBool(); set => SetAndSaveConfigValue("UseExternalBrowser", value); } diff --git a/CollapseLauncher/XAMLs/MainApp/WebView2FramePage.xaml.cs b/CollapseLauncher/XAMLs/MainApp/WebView2FramePage.xaml.cs index 5098e20e3..c81f0122f 100644 --- a/CollapseLauncher/XAMLs/MainApp/WebView2FramePage.xaml.cs +++ b/CollapseLauncher/XAMLs/MainApp/WebView2FramePage.xaml.cs @@ -18,21 +18,8 @@ public sealed partial class WebView2FramePage : Page public WebView2FramePage() { - if (WebView2URL == null) return; - - if (GetAppConfigValue("UseExternalBrowser").ToBool()) - { - Process.Start(new ProcessStartInfo - { - FileName = WebView2URL.ToString(), - UseShellExecute = true, - }); - } - else - { - this.InitializeComponent(); - SpawnWebView2Panel(WebView2URL); - } + this.InitializeComponent(); + SpawnWebView2Panel(WebView2URL); } private async void SpawnWebView2Panel(Uri URL) @@ -42,20 +29,20 @@ private async void SpawnWebView2Panel(Uri URL) Environment.SetEnvironmentVariable("WEBVIEW2_USER_DATA_FOLDER", Path.Combine(AppGameFolder, "_webView2")); WebView2Runtime = new WebView2() - { - HorizontalAlignment = HorizontalAlignment.Stretch, - VerticalAlignment = VerticalAlignment.Stretch - }; + { + HorizontalAlignment = HorizontalAlignment.Stretch, + VerticalAlignment = VerticalAlignment.Stretch + }; WebViewWindowTitle.Text = string.Empty; WebView2Runtime.CoreWebView2Initialized += WebView2Window_CoreWebView2Initialized; - WebView2Runtime.NavigationStarting += WebView2Window_PageLoading; - WebView2Runtime.NavigationCompleted += WebView2Window_PageLoaded; + WebView2Runtime.NavigationStarting += WebView2Window_PageLoading; + WebView2Runtime.NavigationCompleted += WebView2Window_PageLoaded; WebView2WindowContainer.Children.Clear(); WebView2WindowContainer.Children.Add(WebView2Runtime); - WebView2Panel.Visibility = Visibility.Visible; + WebView2Panel.Visibility = Visibility.Visible; WebView2Panel.Translation += Shadow32; await WebView2Runtime.EnsureCoreWebView2Async();