Skip to content

Commit 0b1b681

Browse files
committed
Add system proxy pac to the Windows desktop version
1 parent deafd73 commit 0b1b681

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ public class StatusBarViewModel : MyReactiveObject
6060
[Reactive]
6161
public int SystemProxySelected { get; set; }
6262

63+
[Reactive]
64+
public bool BlSystemProxyPacVisible { get; set; }
65+
6366
#endregion System Proxy
6467

6568
#region UI
@@ -96,6 +99,7 @@ public StatusBarViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
9699
SelectedRouting = new();
97100
SelectedServer = new();
98101
RunningServerToolTipText = "-";
102+
BlSystemProxyPacVisible = Utils.IsWindows();
99103

100104
if (_config.TunModeItem.EnableTun && AllowEnableTun())
101105
{

v2rayN/v2rayN.Desktop/App.axaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@
4646
Header="{x:Static resx:ResUI.menuSystemProxyNothing}"
4747
IsChecked="{Binding BlSystemProxyNothing}"
4848
ToggleType="Radio" />
49+
<NativeMenuItem
50+
Command="{Binding SystemProxyPacCmd}"
51+
Header="{x:Static resx:ResUI.menuSystemProxyPac}"
52+
IsChecked="{Binding BlSystemProxyPac}"
53+
IsVisible="{Binding BlSystemProxyPacVisible}"
54+
ToggleType="Radio" />
4955
<NativeMenuItemSeparator />
5056
<NativeMenuItem Click="MenuAddServerViaClipboardClick" Header="{x:Static resx:ResUI.menuAddServerViaClipboard}" />
5157
<NativeMenuItem Header="{x:Static resx:ResUI.menuAddServerViaScan}" IsVisible="False" />
@@ -61,4 +67,4 @@
6167
</TrayIcon>
6268
</TrayIcons>
6369
</TrayIcon.Icons>
64-
</Application>
70+
</Application>

v2rayN/v2rayN.Desktop/Views/StatusBarView.axaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
<ComboBoxItem Content="{x:Static resx:ResUI.menuSystemProxyClear}" />
6161
<ComboBoxItem Content="{x:Static resx:ResUI.menuSystemProxySet}" />
6262
<ComboBoxItem Content="{x:Static resx:ResUI.menuSystemProxyNothing}" />
63+
<ComboBoxItem Content="{x:Static resx:ResUI.menuSystemProxyPac}" />
6364
</ComboBox>
6465

6566
<ComboBox
@@ -78,4 +79,4 @@
7879
</StackPanel>
7980
</DockPanel>
8081
</Grid>
81-
</UserControl>
82+
</UserControl>

v2rayN/v2rayN.Desktop/Views/StatusBarView.axaml.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ public StatusBarView()
4343
});
4444

4545
//spEnableTun.IsVisible = (Utils.IsWindows() || AppHandler.Instance.IsAdministrator);
46+
47+
if (Utils.IsNonWindows() && cmbSystemProxy.Items.IsReadOnly == false)
48+
{
49+
cmbSystemProxy.Items.RemoveAt(cmbSystemProxy.Items.Count - 1);
50+
}
4651
}
4752

4853
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)

v2rayN/v2rayN/Views/StatusBarView.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ public StatusBarView()
3232
this.OneWayBind(ViewModel, vm => vm.BlSystemProxyPac, v => v.menuSystemProxyPac2.Visibility, conversionHint: BooleanToVisibilityHint.UseHidden, vmToViewConverterOverride: new BooleanToVisibilityTypeConverter()).DisposeWith(disposables);
3333
this.BindCommand(ViewModel, vm => vm.SystemProxyClearCmd, v => v.menuSystemProxyClear).DisposeWith(disposables);
3434
this.BindCommand(ViewModel, vm => vm.SystemProxySetCmd, v => v.menuSystemProxySet).DisposeWith(disposables);
35-
this.BindCommand(ViewModel, vm => vm.SystemProxyPacCmd, v => v.menuSystemProxyPac).DisposeWith(disposables);
3635
this.BindCommand(ViewModel, vm => vm.SystemProxyNothingCmd, v => v.menuSystemProxyNothing).DisposeWith(disposables);
36+
this.BindCommand(ViewModel, vm => vm.SystemProxyPacCmd, v => v.menuSystemProxyPac).DisposeWith(disposables);
3737

3838
//routings and servers
3939
this.OneWayBind(ViewModel, vm => vm.RoutingItems, v => v.cmbRoutings.ItemsSource).DisposeWith(disposables);

0 commit comments

Comments
 (0)