From 0bf6beac84103a856ec1eef96866cb51633e092c Mon Sep 17 00:00:00 2001 From: Linisdjxm <35957435+Linisdjxm@users.noreply.github.com> Date: Sun, 18 Aug 2024 15:08:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0SOCKS5=E6=94=AF?= =?UTF-8?q?=E6=8C=81=20(#10061)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaWpfGui/Constants/ConfigurationKeys.cs | 1 + src/MaaWpfGui/Services/Web/HttpService.cs | 2 +- .../ViewModels/UI/SettingsViewModel.cs | 18 ++++++++++++++++++ .../VersionUpdateSettingsUserControl.xaml | 11 +++++++---- 4 files changed, 27 insertions(+), 5 deletions(-) mode change 100644 => 100755 src/MaaWpfGui/Constants/ConfigurationKeys.cs mode change 100644 => 100755 src/MaaWpfGui/Services/Web/HttpService.cs mode change 100644 => 100755 src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs mode change 100644 => 100755 src/MaaWpfGui/Views/UserControl/VersionUpdateSettingsUserControl.xaml diff --git a/src/MaaWpfGui/Constants/ConfigurationKeys.cs b/src/MaaWpfGui/Constants/ConfigurationKeys.cs old mode 100644 new mode 100755 index 7e4f536578..f192219dd4 --- a/src/MaaWpfGui/Constants/ConfigurationKeys.cs +++ b/src/MaaWpfGui/Constants/ConfigurationKeys.cs @@ -174,6 +174,7 @@ namespace MaaWpfGui.Constants public const string CopilotLoopTimes = "Copilot.LoopTimes"; public const string CopilotTaskList = "Copilot.CopilotTaskList"; public const string UpdateProxy = "VersionUpdate.Proxy"; + public const string ProxyType = "VersionUpdate.ProxyType"; public const string VersionType = "VersionUpdate.VersionType"; public const string UpdateCheck = "VersionUpdate.UpdateCheck"; public const string UpdateAutoCheck = "VersionUpdate.ScheduledUpdateCheck"; diff --git a/src/MaaWpfGui/Services/Web/HttpService.cs b/src/MaaWpfGui/Services/Web/HttpService.cs old mode 100644 new mode 100755 index c25cd90e52..2574b14f3b --- a/src/MaaWpfGui/Services/Web/HttpService.cs +++ b/src/MaaWpfGui/Services/Web/HttpService.cs @@ -43,7 +43,7 @@ namespace MaaWpfGui.Services.Web return string.Empty; } - return p.Contains("://") ? p : $"http://{p}"; + return p.Contains("://") ? p : ConfigurationHelper.GetGlobalValue(ConfigurationKeys.ProxyType, "http") + $"://{p}"; } } diff --git a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs old mode 100644 new mode 100755 index d420e0cf25..3895ae56cb --- a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs @@ -3555,6 +3555,24 @@ namespace MaaWpfGui.ViewModels.UI } } + public List PorxyTypeList { get; } = + [ + new() { Display = "HTTP proxy", Value = "http" }, + new() { Display = "SOCKS5 proxy", Value = "socks5" }, + ]; + + string _proxyType = "http"; + + public string ProxyType + { + get => _proxyType; + set + { + SetAndNotify(ref _proxyType, value); + ConfigurationHelper.SetGlobalValue(ConfigurationKeys.ProxyType, value); + } + } + private bool _isCheckingForUpdates; /// diff --git a/src/MaaWpfGui/Views/UserControl/VersionUpdateSettingsUserControl.xaml b/src/MaaWpfGui/Views/UserControl/VersionUpdateSettingsUserControl.xaml old mode 100644 new mode 100755 index 8ce72b207b..37fea48d6b --- a/src/MaaWpfGui/Views/UserControl/VersionUpdateSettingsUserControl.xaml +++ b/src/MaaWpfGui/Views/UserControl/VersionUpdateSettingsUserControl.xaml @@ -88,11 +88,14 @@ - + Width="120" + Margin="10" + DisplayMemberPath="Display" + ItemsSource="{Binding PorxyTypeList}" + SelectedValue="{Binding ProxyType}" + SelectedValuePath="Value" />