Compare commits

...

5 commits

Author SHA1 Message Date
2dust
0c758a7fdc Optimize UI for macos
Some checks are pending
release macos / build (Release) (push) Waiting to run
release / build (Release) (push) Waiting to run
2024-12-19 13:36:45 +08:00
2dust
85cb1d1c92 Bug fix system proxy for macos 2024-12-19 13:20:12 +08:00
2dust
2cd2e8894d Add system proxy exception function for macos 2024-12-19 11:40:16 +08:00
2dust
abb58379b3 Add IsNonWindows instead of IsLinux or IsOSX 2024-12-19 11:24:52 +08:00
2dust
4f48e8b190 Optimize UI 2024-12-19 10:23:46 +08:00
20 changed files with 45 additions and 34 deletions

View file

@ -710,7 +710,7 @@ namespace ServiceLib.Common
public static string StartupPath()
{
if (Utils.IsLinux() && Environment.GetEnvironmentVariable("V2RAYN_LOCAL_APPLICATION_DATA") == "1")
if (Utils.IsNonWindows() && Environment.GetEnvironmentVariable("V2RAYN_LOCAL_APPLICATION_DATA") == "1")
{
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "v2rayN");
}
@ -838,6 +838,8 @@ namespace ServiceLib.Common
public static bool IsOSX() => RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
public static bool IsNonWindows() => !RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
public static string GetExeName(string name)
{
return IsWindows() ? $"{name}.exe" : name;

View file

@ -46,7 +46,7 @@
public bool InitApp()
{
if (Utils.IsLinux() && Utils.HasWritePermission() == false)
if (Utils.IsNonWindows() && Utils.HasWritePermission() == false)
{
Environment.SetEnvironmentVariable("V2RAYN_LOCAL_APPLICATION_DATA", "1", EnvironmentVariableTarget.Process);
}

View file

@ -24,7 +24,7 @@ namespace ServiceLib.Handler
Environment.SetEnvironmentVariable("V2RAY_LOCATION_ASSET", Utils.GetBinPath(""), EnvironmentVariableTarget.Process);
Environment.SetEnvironmentVariable("XRAY_LOCATION_ASSET", Utils.GetBinPath(""), EnvironmentVariableTarget.Process);
if (Utils.IsLinux() || Utils.IsOSX())
if (Utils.IsNonWindows())
{
var coreInfo = CoreInfoHandler.Instance.GetCoreInfo();
foreach (var it in coreInfo)
@ -221,7 +221,7 @@ namespace ServiceLib.Handler
{
return _config.TunModeItem.EnableTun
&& eCoreType == ECoreType.sing_box
&& (Utils.IsLinux() || Utils.IsOSX())
&& (Utils.IsNonWindows())
//&& _config.TunModeItem.LinuxSudoPwd.IsNotEmpty()
;
}

View file

@ -16,9 +16,9 @@
/// </summary>
private static readonly List<string> LstTypes = ["setwebproxy", "setsecurewebproxy", "setsocksfirewallproxy"];
public static async Task SetProxy(string host, int port)
public static async Task SetProxy(string host, int port, string exceptions)
{
var lstCmd = GetSetCmds(host, port);
var lstCmd = GetSetCmds(host, port, exceptions);
await ExecCmd(lstCmd);
}
@ -42,7 +42,7 @@
}
}
private static List<CmdItem> GetSetCmds(string host, int port)
private static List<CmdItem> GetSetCmds(string host, int port, string exceptions)
{
List<CmdItem> lstCmd = [];
foreach (var interf in LstInterface)
@ -52,7 +52,17 @@
lstCmd.Add(new CmdItem()
{
Cmd = "networksetup",
Arguments = [$"-{type}", interf, host, (type.Contains("socks") ? (port - 1) : port).ToString()]
Arguments = [$"-{type}", interf, host, port.ToString()]
});
}
if (exceptions.IsNotEmpty())
{
List<string> args = [$"-setproxybypassdomains", interf];
args.AddRange(exceptions.Split(','));
lstCmd.Add(new CmdItem()
{
Cmd = "networksetup",
Arguments = args
});
}
}

View file

@ -32,7 +32,7 @@
break;
case ESysProxyType.ForcedChange when Utils.IsOSX():
await ProxySettingOSX.SetProxy(Global.Loopback, port);
await ProxySettingOSX.SetProxy(Global.Loopback, port, exceptions);
break;
case ESysProxyType.ForcedClear when Utils.IsWindows():

View file

@ -262,7 +262,7 @@ namespace ServiceLib.ViewModels
FileManager.ZipExtractToFile(fileName, toPath, _config.GuiItem.IgnoreGeoUpdateCore ? "geo" : "");
}
if (Utils.IsLinux() || Utils.IsOSX())
if (Utils.IsNonWindows())
{
var filesList = (new DirectoryInfo(toPath)).GetFiles().Select(u => u.FullName).ToList();
foreach (var file in filesList)

View file

@ -6,18 +6,18 @@
</Design.PreviewWith>
<Style Selector="TextBlock.Margin8">
<Setter Property="Margin" Value="10" />
<Setter Property="Margin" Value="8" />
</Style>
<Style Selector="StackPanel.Margin8">
<Setter Property="Margin" Value="10" />
<Setter Property="Margin" Value="8" />
</Style>
<Style Selector="DockPanel.Margin8">
<Setter Property="Margin" Value="10" />
<Setter Property="Margin" Value="8" />
</Style>
<Style Selector="WrapPanel.Margin8">
<Setter Property="Margin" Value="10" />
<Setter Property="Margin" Value="8" />
</Style>
<Style Selector="Grid.Margin8">
<Setter Property="Margin" Value="10" />
<Setter Property="Margin" Value="8" />
</Style>
</Styles>

View file

@ -8,7 +8,7 @@
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
Title="{x:Static resx:ResUI.menuServers}"
Width="900"
Height="700"
Height="600"
x:DataType="vms:AddServerViewModel"
ShowInTaskbar="False"
WindowStartupLocation="CenterScreen"

View file

@ -50,7 +50,7 @@
<Border
Width="500"
Height="80"
Margin="-2"
Margin="-8"
VerticalAlignment="Center"
Theme="{StaticResource CardBorder}">
<Grid>

View file

@ -7,8 +7,8 @@
xmlns:resx="clr-namespace:ServiceLib.Resx;assembly=ServiceLib"
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
Title="{x:Static resx:ResUI.menuDNSSetting}"
Width="1000"
Height="700"
Width="900"
Height="600"
x:DataType="vms:DNSSettingViewModel"
ShowInTaskbar="False"
WindowStartupLocation="CenterScreen"

View file

@ -10,7 +10,7 @@
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
Title="v2rayN"
Width="900"
Height="700"
Height="600"
MinWidth="900"
x:DataType="vms:MainWindowViewModel"
Icon="/Assets/NotifyIcon1.ico"

View file

@ -8,7 +8,7 @@
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
Title="{x:Static resx:ResUI.menuSetting}"
Width="1000"
Height="700"
Height="600"
x:DataType="vms:OptionSettingViewModel"
ShowInTaskbar="False"
WindowStartupLocation="CenterScreen"

View file

@ -215,7 +215,7 @@ namespace v2rayN.Desktop.Views
{
return lstFonts;
}
else if (Utils.IsLinux() || Utils.IsOSX())
else if (Utils.IsNonWindows())
{
var result = await Utils.GetLinuxFontFamily("zh");
if (result.IsNullOrEmpty())

View file

@ -8,7 +8,7 @@
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
Title="{x:Static resx:ResUI.menuRoutingRuleDetailsSetting}"
Width="900"
Height="700"
Height="600"
x:DataType="vms:RoutingRuleDetailsViewModel"
ShowInTaskbar="False"
WindowStartupLocation="CenterScreen"

View file

@ -7,8 +7,8 @@
xmlns:resx="clr-namespace:ServiceLib.Resx;assembly=ServiceLib"
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
Title="{x:Static resx:ResUI.menuRoutingRuleSetting}"
Width="1000"
Height="700"
Width="900"
Height="600"
x:DataType="vms:RoutingRuleSettingViewModel"
ShowInTaskbar="False"
WindowStartupLocation="CenterScreen"

View file

@ -7,8 +7,8 @@
xmlns:resx="clr-namespace:ServiceLib.Resx;assembly=ServiceLib"
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
Title="{x:Static resx:ResUI.menuRoutingSetting}"
Width="1000"
Height="700"
Width="900"
Height="600"
x:DataType="vms:RoutingSettingViewModel"
ShowInTaskbar="False"
WindowStartupLocation="CenterScreen"

View file

@ -23,7 +23,6 @@
</StackPanel>
<StackPanel
Width="120"
Margin="8,0"
VerticalAlignment="Center"
DockPanel.Dock="Left">
@ -34,7 +33,6 @@
<StackPanel
x:Name="spEnableTun"
Width="100"
Margin="8,0"
VerticalAlignment="Center"
DockPanel.Dock="Left"

View file

@ -8,7 +8,7 @@
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
Title="{x:Static resx:ResUI.menuSubSetting}"
Width="700"
Height="650"
Height="600"
ShowInTaskbar="False"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">

View file

@ -8,8 +8,8 @@
xmlns:resx="clr-namespace:ServiceLib.Resx;assembly=ServiceLib"
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
Title="{x:Static resx:ResUI.menuSubSetting}"
Width="1000"
Height="700"
Width="900"
Height="600"
x:DataType="vms:SubSettingViewModel"
ShowInTaskbar="False"
WindowStartupLocation="CenterScreen"

View file

@ -27,7 +27,7 @@
</StackPanel>
<StackPanel
Width="120"
Width="Auto"
Margin="{StaticResource MarginLeftRight8}"
VerticalAlignment="Center"
DockPanel.Dock="Left">
@ -38,7 +38,7 @@
<StackPanel
x:Name="spEnableTun"
Width="auto"
Width="Auto"
Margin="{StaticResource MarginLeftRight8}"
VerticalAlignment="Center"
DockPanel.Dock="Left"
@ -46,6 +46,7 @@
<TextBlock
Margin="{StaticResource MarginLeftRight8}"
VerticalAlignment="Center"
Style="{StaticResource StatusbarItem}"
Text="{x:Static resx:ResUI.TbEnableTunAs}" />
<ToggleButton
x:Name="togEnableTun"