提交 6def6709 编写于 作者: A Aigio Liu

fix SetWebProxyMode

上级 5653df99
......@@ -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
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册