Add system proxy pac to the Windows desktop version

master
2dust 2025-02-18 14:38:08 +08:00
parent deafd73306
commit 0b1b681655
5 changed files with 19 additions and 3 deletions

View File

@ -60,6 +60,9 @@ namespace ServiceLib.ViewModels
[Reactive]
public int SystemProxySelected { get; set; }
[Reactive]
public bool BlSystemProxyPacVisible { get; set; }
#endregion System Proxy
#region UI
@ -96,6 +99,7 @@ namespace ServiceLib.ViewModels
SelectedRouting = new();
SelectedServer = new();
RunningServerToolTipText = "-";
BlSystemProxyPacVisible = Utils.IsWindows();
if (_config.TunModeItem.EnableTun && AllowEnableTun())
{

View File

@ -46,6 +46,12 @@
Header="{x:Static resx:ResUI.menuSystemProxyNothing}"
IsChecked="{Binding BlSystemProxyNothing}"
ToggleType="Radio" />
<NativeMenuItem
Command="{Binding SystemProxyPacCmd}"
Header="{x:Static resx:ResUI.menuSystemProxyPac}"
IsChecked="{Binding BlSystemProxyPac}"
IsVisible="{Binding BlSystemProxyPacVisible}"
ToggleType="Radio" />
<NativeMenuItemSeparator />
<NativeMenuItem Click="MenuAddServerViaClipboardClick" Header="{x:Static resx:ResUI.menuAddServerViaClipboard}" />
<NativeMenuItem Header="{x:Static resx:ResUI.menuAddServerViaScan}" IsVisible="False" />
@ -61,4 +67,4 @@
</TrayIcon>
</TrayIcons>
</TrayIcon.Icons>
</Application>
</Application>

View File

@ -60,6 +60,7 @@
<ComboBoxItem Content="{x:Static resx:ResUI.menuSystemProxyClear}" />
<ComboBoxItem Content="{x:Static resx:ResUI.menuSystemProxySet}" />
<ComboBoxItem Content="{x:Static resx:ResUI.menuSystemProxyNothing}" />
<ComboBoxItem Content="{x:Static resx:ResUI.menuSystemProxyPac}" />
</ComboBox>
<ComboBox
@ -78,4 +79,4 @@
</StackPanel>
</DockPanel>
</Grid>
</UserControl>
</UserControl>

View File

@ -43,6 +43,11 @@ namespace v2rayN.Desktop.Views
});
//spEnableTun.IsVisible = (Utils.IsWindows() || AppHandler.Instance.IsAdministrator);
if (Utils.IsNonWindows() && cmbSystemProxy.Items.IsReadOnly == false)
{
cmbSystemProxy.Items.RemoveAt(cmbSystemProxy.Items.Count - 1);
}
}
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)

View File

@ -32,8 +32,8 @@ namespace v2rayN.Views
this.OneWayBind(ViewModel, vm => vm.BlSystemProxyPac, v => v.menuSystemProxyPac2.Visibility, conversionHint: BooleanToVisibilityHint.UseHidden, vmToViewConverterOverride: new BooleanToVisibilityTypeConverter()).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.SystemProxyClearCmd, v => v.menuSystemProxyClear).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.SystemProxySetCmd, v => v.menuSystemProxySet).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.SystemProxyPacCmd, v => v.menuSystemProxyPac).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.SystemProxyNothingCmd, v => v.menuSystemProxyNothing).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.SystemProxyPacCmd, v => v.menuSystemProxyPac).DisposeWith(disposables);
//routings and servers
this.OneWayBind(ViewModel, vm => vm.RoutingItems, v => v.cmbRoutings.ItemsSource).DisposeWith(disposables);