feat: 增加SOCKS5支持 (#10061)

This commit is contained in:
Linisdjxm
2024-08-18 15:08:47 +08:00
committed by GitHub
parent 8c68d90a3d
commit 0bf6beac84
4 changed files with 27 additions and 5 deletions

1
src/MaaWpfGui/Constants/ConfigurationKeys.cs Normal file → Executable file
View File

@@ -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";

2
src/MaaWpfGui/Services/Web/HttpService.cs Normal file → Executable file
View File

@@ -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}";
}
}

18
src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs Normal file → Executable file
View File

@@ -3555,6 +3555,24 @@ namespace MaaWpfGui.ViewModels.UI
}
}
public List<CombinedData> 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;
/// <summary>

View File

@@ -88,11 +88,14 @@
<RowDefinition />
</Grid.RowDefinitions>
<controls:TextBlock
<ComboBox
Grid.Row="0"
Margin="1"
VerticalAlignment="Center"
Text="Http Proxy" />
Width="120"
Margin="10"
DisplayMemberPath="Display"
ItemsSource="{Binding PorxyTypeList}"
SelectedValue="{Binding ProxyType}"
SelectedValuePath="Value" />
<TextBox
Grid.Row="1"
Width="150"