From 6def67095b2e809da8bfd928a7abdd82aba8a08b Mon Sep 17 00:00:00 2001 From: Aigio Liu Date: Sat, 26 Aug 2023 17:44:14 +0800 Subject: [PATCH] fix SetWebProxyMode --- src/BD.WTTS.Client/Startup/Startup.Host.cs | 23 +++++++++++----------- src/BD.WTTS.Client/Startup/Startup.cs | 6 ++++++ 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/BD.WTTS.Client/Startup/Startup.Host.cs b/src/BD.WTTS.Client/Startup/Startup.Host.cs index b481c0c42..5a0b37949 100644 --- a/src/BD.WTTS.Client/Startup/Startup.Host.cs +++ b/src/BD.WTTS.Client/Startup/Startup.Host.cs @@ -129,7 +129,7 @@ partial class Startup // 配置 Host if (HasHttpClientFactory || HasHttpProxy) { - static void SetWebProxyMode(AppWebProxyMode mode) + void SetWebProxyMode(AppWebProxyMode mode) { switch (mode) { @@ -138,27 +138,27 @@ partial class Startup // 配置 Host break; case AppWebProxyMode.Custom: WebProxy webProxy; - if (!string.IsNullOrEmpty(GeneralSettings.CustomWebProxyModeHost.Value) && GeneralSettings.CustomWebProxyModePort.Value != default) + if (!string.IsNullOrEmpty(generalSettings.CurrentValue.CustomWebProxyModeHost) && generalSettings.CurrentValue.CustomWebProxyModePort != default) { - webProxy = new(GeneralSettings.CustomWebProxyModeHost.Value, GeneralSettings.CustomWebProxyModePort.Value) + webProxy = new(generalSettings.CurrentValue.CustomWebProxyModeHost, generalSettings.CurrentValue.CustomWebProxyModePort) { - BypassProxyOnLocal = GeneralSettings.CustomWebProxyModeBypassOnLocal.Value, + BypassProxyOnLocal = generalSettings.CurrentValue.CustomWebProxyModeBypassOnLocal, }; } - else if (!string.IsNullOrEmpty(GeneralSettings.CustomWebProxyModeAddress.Value)) + else if (!string.IsNullOrEmpty(generalSettings.CurrentValue.CustomWebProxyModeAddress)) { - webProxy = new(GeneralSettings.CustomWebProxyModeAddress.Value, GeneralSettings.CustomWebProxyModeBypassOnLocal.Value); + webProxy = new(generalSettings.CurrentValue.CustomWebProxyModeAddress, generalSettings.CurrentValue.CustomWebProxyModeBypassOnLocal); } else { SetWebProxyMode(AppWebProxyMode.FollowSystem); return; } - if (!string.IsNullOrEmpty(GeneralSettings.CustomWebProxyModeCredentialUserName.Value)) + if (!string.IsNullOrEmpty(generalSettings.CurrentValue.CustomWebProxyModeCredentialUserName)) { - NetworkCredential credential = new(GeneralSettings.CustomWebProxyModeCredentialUserName.Value, - GeneralSettings.CustomWebProxyModeCredentialPassword.Value ?? "", - GeneralSettings.CustomWebProxyModeCredentialDomain.Value ?? ""); + NetworkCredential credential = new(generalSettings.CurrentValue.CustomWebProxyModeCredentialUserName, + generalSettings.CurrentValue.CustomWebProxyModeCredentialPassword ?? "", + generalSettings.CurrentValue.CustomWebProxyModeCredentialDomain ?? ""); webProxy.Credentials = credential; } HttpClient.DefaultProxy = webProxy; @@ -172,7 +172,8 @@ partial class Startup // 配置 Host break; } } - SetWebProxyMode(GeneralSettings.WebProxyMode.Value); + if (generalSettings != null) + SetWebProxyMode(generalSettings.CurrentValue.WebProxyMode); #if STARTUP_WATCH_TRACE || DEBUG WatchTrace.Record("DynamicHttpWindowsProxy"); #endif diff --git a/src/BD.WTTS.Client/Startup/Startup.cs b/src/BD.WTTS.Client/Startup/Startup.cs index eb9894289..67fc768ba 100644 --- a/src/BD.WTTS.Client/Startup/Startup.cs +++ b/src/BD.WTTS.Client/Startup/Startup.cs @@ -428,6 +428,12 @@ public abstract partial class Startup catch (Exception ex) { GlobalExceptionHandler.Handler(ex, nameof(StartAsync)); +#if WINDOWS + WPFMessageBox.Show(ex.ToString(), + AssemblyInfo.Trademark, + WPFMessageBoxButton.OK, + WPFMessageBoxImage.Error); +#endif throw; } finally -- GitLab