Compare commits

..

9 Commits
7.0.5 ... 7.0.6

Author SHA1 Message Date
2dust
0accf262dc up 7.0.6 2024-11-03 16:49:06 +08:00
2dust
e0eb73bb0a Code clean 2024-11-03 16:45:48 +08:00
2dust
258e822c13 Add exit function to the main interface for Desktop 2024-11-03 14:48:13 +08:00
2dust
4f05b93d63 Bug fix
MainModule FileName only exists in Win32.
2024-11-03 13:44:12 +08:00
2dust
bb661d4f50 Only one instance is allowed to run 2024-11-03 13:30:32 +08:00
2dust
201cfaa922 Fix
https://github.com/2dust/v2rayN/issues/5966
2024-11-02 15:02:30 +08:00
2dust
c339aa349c up PackageReference 2024-11-02 14:42:26 +08:00
2dust
046421f345 Code clean 2024-11-02 14:42:01 +08:00
fonaix
3a2c9e7aaa 修复:日志文本框垂直显示上下空白问题 (#5967) 2024-11-02 10:28:18 +08:00
23 changed files with 133 additions and 95 deletions

View File

@@ -22,13 +22,13 @@ namespace AmazTool
Console.WriteLine("Try to end the process(尝试结束进程)."); Console.WriteLine("Try to end the process(尝试结束进程).");
try try
{ {
var path = GetPath(V2rayN);
Console.WriteLine(path);
var existing = Process.GetProcessesByName(V2rayN); var existing = Process.GetProcessesByName(V2rayN);
var pp = existing.FirstOrDefault(p => p.MainModule?.FileName != null && p.MainModule?.FileName.Contains(path) == true); foreach (var pp in existing)
{
pp?.Kill(); pp?.Kill();
pp?.WaitForExit(1000); pp?.WaitForExit(1000);
} }
}
catch (Exception ex) catch (Exception ex)
{ {
// Access may be denied without admin right. The user may not be an administrator. // Access may be denied without admin right. The user may not be an administrator.

View File

@@ -5,6 +5,7 @@
ClearMsg, ClearMsg,
SendMsgView, SendMsgView,
SendSnackMsg, SendSnackMsg,
RefreshProfiles RefreshProfiles,
StopSpeedtest
} }
} }

View File

@@ -108,13 +108,11 @@ namespace ServiceLib.Handler
{ {
try try
{ {
bool hasProc = false;
if (_process != null) if (_process != null)
{ {
await KillProcess(_process); await KillProcess(_process);
_process.Dispose(); _process.Dispose();
_process = null; _process = null;
hasProc = true;
} }
if (_processPre != null) if (_processPre != null)
@@ -122,26 +120,6 @@ namespace ServiceLib.Handler
await KillProcess(_processPre); await KillProcess(_processPre);
_processPre.Dispose(); _processPre.Dispose();
_processPre = null; _processPre = null;
hasProc = true;
}
if (!hasProc)
{
var coreInfo = CoreInfoHandler.Instance.GetCoreInfo();
foreach (var it in coreInfo)
{
if (it.CoreType == ECoreType.v2rayN)
{
continue;
}
foreach (var name in it.CoreExes)
{
var path = Utils.GetBinPath(Utils.GetExeName(name), it.CoreType.ToString());
var existing = Process.GetProcessesByName(name);
var pp = existing.FirstOrDefault(p => p.MainModule?.FileName != null && p.MainModule?.FileName.Contains(path) == true);
await KillProcess(pp);
}
}
} }
} }
catch (Exception ex) catch (Exception ex)

View File

@@ -870,6 +870,15 @@ namespace ServiceLib.Resx {
} }
} }
/// <summary>
/// 查找类似 Are you sure to exit? 的本地化字符串。
/// </summary>
public static string menuExitTips {
get {
return ResourceManager.GetString("menuExitTips", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Export selected server for complete configuration 的本地化字符串。 /// 查找类似 Export selected server for complete configuration 的本地化字符串。
/// </summary> /// </summary>

View File

@@ -1363,4 +1363,7 @@
<data name="TbSettingsCurrentFontFamilyLinuxTip" xml:space="preserve"> <data name="TbSettingsCurrentFontFamilyLinuxTip" xml:space="preserve">
<value>Install the font to the system and restart the settings</value> <value>Install the font to the system and restart the settings</value>
</data> </data>
<data name="menuExitTips" xml:space="preserve">
<value>Are you sure to exit?</value>
</data>
</root> </root>

View File

@@ -1360,4 +1360,7 @@
<data name="TbSettingsCurrentFontFamilyLinuxTip" xml:space="preserve"> <data name="TbSettingsCurrentFontFamilyLinuxTip" xml:space="preserve">
<value>安装字体到系统中,重启设置</value> <value>安装字体到系统中,重启设置</value>
</data> </data>
<data name="menuExitTips" xml:space="preserve">
<value>是否确定退出?</value>
</data>
</root> </root>

View File

@@ -1240,4 +1240,7 @@
<data name="TbSettingsCurrentFontFamilyLinuxTip" xml:space="preserve"> <data name="TbSettingsCurrentFontFamilyLinuxTip" xml:space="preserve">
<value>安裝字體到系統中,重新啟動設定</value> <value>安裝字體到系統中,重新啟動設定</value>
</data> </data>
<data name="menuExitTips" xml:space="preserve">
<value>是否確定退出?</value>
</data>
</root> </root>

View File

@@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<Version>7.0.5</Version> <Version>7.0.6</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@@ -1,4 +1,5 @@
using System.Diagnostics; using ReactiveUI;
using System.Diagnostics;
using System.Net; using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
@@ -80,10 +81,12 @@ namespace ServiceLib.Services
Task.Run(RunMixedtestAsync); Task.Run(RunMixedtestAsync);
break; break;
} }
MessageBus.Current.Listen<string>(EMsgCommand.StopSpeedtest.ToString()).Subscribe(ExitLoop);
} }
public void ExitLoop() private void ExitLoop(string x)
{ {
if (_exitLoop) return;
_exitLoop = true; _exitLoop = true;
UpdateFunc("", ResUI.SpeedtestingStop); UpdateFunc("", ResUI.SpeedtestingStop);
} }

View File

@@ -6,12 +6,10 @@ namespace ServiceLib.Services
public class UpdateService public class UpdateService
{ {
private Action<bool, string>? _updateFunc; private Action<bool, string>? _updateFunc;
private Config _config;
private int _timeout = 30; private int _timeout = 30;
public async Task CheckUpdateGuiN(Config config, Action<bool, string> updateFunc, bool preRelease) public async Task CheckUpdateGuiN(Config config, Action<bool, string> updateFunc, bool preRelease)
{ {
_config = config;
_updateFunc = updateFunc; _updateFunc = updateFunc;
var url = string.Empty; var url = string.Empty;
var fileName = string.Empty; var fileName = string.Empty;
@@ -53,7 +51,6 @@ namespace ServiceLib.Services
public async Task CheckUpdateCore(ECoreType type, Config config, Action<bool, string> updateFunc, bool preRelease) public async Task CheckUpdateCore(ECoreType type, Config config, Action<bool, string> updateFunc, bool preRelease)
{ {
_config = config;
_updateFunc = updateFunc; _updateFunc = updateFunc;
var url = string.Empty; var url = string.Empty;
var fileName = string.Empty; var fileName = string.Empty;
@@ -108,7 +105,6 @@ namespace ServiceLib.Services
public async Task UpdateSubscriptionProcess(Config config, string subId, bool blProxy, Action<bool, string> updateFunc) public async Task UpdateSubscriptionProcess(Config config, string subId, bool blProxy, Action<bool, string> updateFunc)
{ {
_config = config;
_updateFunc = updateFunc; _updateFunc = updateFunc;
_updateFunc?.Invoke(false, ResUI.MsgUpdateSubscriptionStart); _updateFunc?.Invoke(false, ResUI.MsgUpdateSubscriptionStart);
@@ -454,7 +450,6 @@ namespace ServiceLib.Services
private async Task UpdateGeoFile(string geoName, Config config, Action<bool, string> updateFunc) private async Task UpdateGeoFile(string geoName, Config config, Action<bool, string> updateFunc)
{ {
_config = config;
_updateFunc = updateFunc; _updateFunc = updateFunc;
var geoUrl = string.IsNullOrEmpty(config?.ConstItem.GeoSourceUrl) var geoUrl = string.IsNullOrEmpty(config?.ConstItem.GeoSourceUrl)
@@ -470,7 +465,6 @@ namespace ServiceLib.Services
private async Task UpdateSrsFileAll(Config config, Action<bool, string> updateFunc) private async Task UpdateSrsFileAll(Config config, Action<bool, string> updateFunc)
{ {
_config = config;
_updateFunc = updateFunc; _updateFunc = updateFunc;
var geoipFiles = new List<string>(); var geoipFiles = new List<string>();
@@ -521,9 +515,9 @@ namespace ServiceLib.Services
private async Task UpdateSrsFile(string type, string srsName, Config config, Action<bool, string> updateFunc) private async Task UpdateSrsFile(string type, string srsName, Config config, Action<bool, string> updateFunc)
{ {
var srsUrl = string.IsNullOrEmpty(_config.ConstItem.SrsSourceUrl) var srsUrl = string.IsNullOrEmpty(config.ConstItem.SrsSourceUrl)
? Global.SingboxRulesetUrl ? Global.SingboxRulesetUrl
: _config.ConstItem.SrsSourceUrl; : config.ConstItem.SrsSourceUrl;
var fileName = $"{type}-{srsName}.srs"; var fileName = $"{type}-{srsName}.srs";
var targetPath = Path.Combine(Utils.GetBinPath("srss"), fileName); var targetPath = Path.Combine(Utils.GetBinPath("srss"), fileName);

View File

@@ -52,6 +52,8 @@ namespace ServiceLib.ViewModels
public ReactiveCommand<Unit, Unit> ReloadCmd { get; } public ReactiveCommand<Unit, Unit> ReloadCmd { get; }
public ReactiveCommand<Unit, Unit> ExitCmd { get; }
[Reactive] [Reactive]
public bool BlReloadEnabled { get; set; } public bool BlReloadEnabled { get; set; }
@@ -187,6 +189,11 @@ namespace ServiceLib.ViewModels
await Reload(); await Reload();
}); });
ExitCmd = ReactiveCommand.CreateFromTask(async () =>
{
await Exit();
});
RegionalPresetDefaultCmd = ReactiveCommand.CreateFromTask(async () => RegionalPresetDefaultCmd = ReactiveCommand.CreateFromTask(async () =>
{ {
await ApplyRegionalPreset(EPresetType.Default); await ApplyRegionalPreset(EPresetType.Default);
@@ -266,7 +273,7 @@ namespace ServiceLib.ViewModels
try try
{ {
Locator.Current.GetService<StatusBarViewModel>()?.UpdateStatistics(update); Locator.Current.GetService<StatusBarViewModel>()?.UpdateStatistics(update);
if ((update.ProxyUp + update.ProxyDown) > 0 && DateTime.Now.Second % 3 == 0) if ((update.ProxyUp + update.ProxyDown) > 0 && DateTime.Now.Second % 9 == 0)
{ {
Locator.Current.GetService<ProfilesViewModel>()?.UpdateStatistics(update); Locator.Current.GetService<ProfilesViewModel>()?.UpdateStatistics(update);
} }
@@ -289,7 +296,7 @@ namespace ServiceLib.ViewModels
await ProfileExHandler.Instance.SaveTo(); await ProfileExHandler.Instance.SaveTo();
await StatisticsHandler.Instance.SaveTo(); await StatisticsHandler.Instance.SaveTo();
StatisticsHandler.Instance.Close(); StatisticsHandler.Instance.Close();
CoreHandler.Instance.CoreStop(); await CoreHandler.Instance.CoreStop();
Logging.SaveLog("MyAppExit End"); Logging.SaveLog("MyAppExit End");
} }
@@ -588,6 +595,16 @@ namespace ServiceLib.ViewModels
} }
} }
private async Task Exit()
{
if (await _updateView?.Invoke(EViewAction.ShowYesNo, null) == false)
{
return;
}
await MyAppExitAsync(false);
}
#endregion core job #endregion core job
#region Presets #region Presets

View File

@@ -16,7 +16,6 @@ namespace ServiceLib.ViewModels
private List<ProfileItem> _lstProfile; private List<ProfileItem> _lstProfile;
private string _serverFilter = string.Empty; private string _serverFilter = string.Empty;
private Dictionary<string, bool> _dicHeaderSort = new(); private Dictionary<string, bool> _dicHeaderSort = new();
private SpeedtestService? _speedtestHandler;
#endregion private prop #endregion private prop
@@ -686,12 +685,12 @@ namespace ServiceLib.ViewModels
} }
//ClearTestResult(); //ClearTestResult();
_speedtestHandler = new SpeedtestService(_config, lstSelecteds, actionType, UpdateSpeedtestHandler); _ = new SpeedtestService(_config, lstSelecteds, actionType, UpdateSpeedtestHandler);
} }
public void ServerSpeedtestStop() public void ServerSpeedtestStop()
{ {
_speedtestHandler?.ExitLoop(); MessageBus.Current.SendMessage("", EMsgCommand.StopSpeedtest.ToString());
} }
private async Task Export2ClientConfigAsync(bool blClipboard) private async Task Export2ClientConfigAsync(bool blClipboard)

View File

@@ -9,8 +9,6 @@ namespace v2rayN.Desktop;
public partial class App : Application public partial class App : Application
{ {
//public static EventWaitHandle ProgramStarted;
public override void Initialize() public override void Initialize()
{ {
if (!AppHandler.Instance.InitApp()) if (!AppHandler.Instance.InitApp())
@@ -32,7 +30,7 @@ public partial class App : Application
{ {
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{ {
OnStartup(desktop.Args); AppHandler.Instance.InitComponents();
desktop.Exit += OnExit; desktop.Exit += OnExit;
desktop.MainWindow = new MainWindow(); desktop.MainWindow = new MainWindow();
@@ -41,22 +39,6 @@ public partial class App : Application
base.OnFrameworkInitializationCompleted(); base.OnFrameworkInitializationCompleted();
} }
private void OnStartup(string[]? Args)
{
var exePathKey = Utils.GetMd5(Utils.GetExePath());
var rebootas = (Args ?? new string[] { }).Any(t => t == Global.RebootAs);
//ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, exePathKey, out bool bCreatedNew);
//if (!rebootas && !bCreatedNew)
//{
// ProgramStarted.Set();
// Environment.Exit(0);
// return;
//}
AppHandler.Instance.InitComponents();
}
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{ {
if (e.ExceptionObject != null) if (e.ExceptionObject != null)

View File

@@ -5,12 +5,44 @@ namespace v2rayN.Desktop;
internal class Program internal class Program
{ {
public static EventWaitHandle ProgramStarted;
// Initialization code. Don't use any Avalonia, third-party APIs or any // Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized // SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break. // yet and stuff might break.
[STAThread] [STAThread]
public static void Main(string[] args) => BuildAvaloniaApp() public static void Main(string[] args)
{
OnStartup(args);
BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args); .StartWithClassicDesktopLifetime(args);
}
private static void OnStartup(string[]? Args)
{
if (Utils.IsWindows())
{
var exePathKey = Utils.GetMd5(Utils.GetExePath());
var rebootas = (Args ?? new string[] { }).Any(t => t == Global.RebootAs);
ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, exePathKey, out bool bCreatedNew);
if (!rebootas && !bCreatedNew)
{
ProgramStarted.Set();
Environment.Exit(0);
return;
}
}
else
{
_ = new Mutex(true, "v2rayN", out var bOnlyOneInstance);
if (!bOnlyOneInstance)
{
Environment.Exit(0);
return;
}
}
}
// Avalonia configuration, don't remove; also used by visual designer. // Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp() public static AppBuilder BuildAvaloniaApp()

View File

@@ -114,7 +114,7 @@
<MenuItem x:Name="menuClose" Padding="8,0"> <MenuItem x:Name="menuClose" Padding="8,0">
<MenuItem.Header> <MenuItem.Header>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBlock Text="{x:Static resx:ResUI.menuClose}" /> <TextBlock Text="{x:Static resx:ResUI.menuExit}" />
</StackPanel> </StackPanel>
</MenuItem.Header> </MenuItem.Header>
</MenuItem> </MenuItem>

View File

@@ -7,6 +7,7 @@ using Avalonia.Interactivity;
using Avalonia.ReactiveUI; using Avalonia.ReactiveUI;
using Avalonia.Threading; using Avalonia.Threading;
using DialogHostAvalonia; using DialogHostAvalonia;
using MsBox.Avalonia.Enums;
using ReactiveUI; using ReactiveUI;
using Splat; using Splat;
using System.ComponentModel; using System.ComponentModel;
@@ -29,13 +30,10 @@ namespace v2rayN.Desktop.Views
_config = AppHandler.Instance.Config; _config = AppHandler.Instance.Config;
_manager = new WindowNotificationManager(TopLevel.GetTopLevel(this)) { MaxItems = 3, Position = NotificationPosition.BottomRight }; _manager = new WindowNotificationManager(TopLevel.GetTopLevel(this)) { MaxItems = 3, Position = NotificationPosition.BottomRight };
//ThreadPool.RegisterWaitForSingleObject(App.ProgramStarted, OnProgramStarted, null, -1, false);
this.Closing += MainWindow_Closing; this.Closing += MainWindow_Closing;
this.KeyDown += MainWindow_KeyDown; this.KeyDown += MainWindow_KeyDown;
menuSettingsSetUWP.Click += menuSettingsSetUWP_Click; menuSettingsSetUWP.Click += menuSettingsSetUWP_Click;
menuPromotion.Click += menuPromotion_Click; menuPromotion.Click += menuPromotion_Click;
menuClose.Click += menuClose_Click;
menuCheckUpdate.Click += MenuCheckUpdate_Click; menuCheckUpdate.Click += MenuCheckUpdate_Click;
menuBackupAndRestore.Click += MenuBackupAndRestore_Click; menuBackupAndRestore.Click += MenuBackupAndRestore_Click;
@@ -82,6 +80,7 @@ namespace v2rayN.Desktop.Views
this.BindCommand(ViewModel, vm => vm.ReloadCmd, v => v.menuReload).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.ReloadCmd, v => v.menuReload).DisposeWith(disposables);
this.OneWayBind(ViewModel, vm => vm.BlReloadEnabled, v => v.menuReload.IsEnabled).DisposeWith(disposables); this.OneWayBind(ViewModel, vm => vm.BlReloadEnabled, v => v.menuReload.IsEnabled).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.ExitCmd, v => v.menuClose).DisposeWith(disposables);
switch (_config.UiItem.MainGirdOrientation) switch (_config.UiItem.MainGirdOrientation)
{ {
@@ -114,6 +113,8 @@ namespace v2rayN.Desktop.Views
this.Title = $"{Utils.GetVersion()} - {(AppHandler.Instance.IsAdministrator ? ResUI.RunAsAdmin : ResUI.NotRunAsAdmin)}"; this.Title = $"{Utils.GetVersion()} - {(AppHandler.Instance.IsAdministrator ? ResUI.RunAsAdmin : ResUI.NotRunAsAdmin)}";
if (Utils.IsWindows()) if (Utils.IsWindows())
{ {
ThreadPool.RegisterWaitForSingleObject(Program.ProgramStarted, OnProgramStarted, null, -1, false);
menuGlobalHotkeySetting.IsVisible = false; menuGlobalHotkeySetting.IsVisible = false;
} }
else else
@@ -158,7 +159,9 @@ namespace v2rayN.Desktop.Views
private void OnProgramStarted(object state, bool timeout) private void OnProgramStarted(object state, bool timeout)
{ {
ShowHideWindow(true); Dispatcher.UIThread.Post(() =>
ShowHideWindow(true),
DispatcherPriority.Default);
} }
private void DelegateSnackMsg(string content) private void DelegateSnackMsg(string content)
@@ -240,6 +243,14 @@ namespace v2rayN.Desktop.Views
Locator.Current.GetService<ProfilesViewModel>()?.AutofitColumnWidthAsync(), Locator.Current.GetService<ProfilesViewModel>()?.AutofitColumnWidthAsync(),
DispatcherPriority.Default); DispatcherPriority.Default);
break; break;
case EViewAction.ShowYesNo:
if (await UI.ShowYesNo(this, ResUI.menuExitTips) == ButtonResult.No)
{
return false;
}
StorageUI();
break;
} }
return await Task.FromResult(true); return await Task.FromResult(true);
@@ -302,12 +313,6 @@ namespace v2rayN.Desktop.Views
} }
} }
private void menuClose_Click(object? sender, RoutedEventArgs e)
{
StorageUI();
ShowHideWindow(false);
}
private void menuPromotion_Click(object? sender, RoutedEventArgs e) private void menuPromotion_Click(object? sender, RoutedEventArgs e)
{ {
Utils.ProcessStart($"{Utils.Base64Decode(Global.PromotionUrl)}?t={DateTime.Now.Ticks}"); Utils.ProcessStart($"{Utils.Base64Decode(Global.PromotionUrl)}?t={DateTime.Now.Ticks}");
@@ -373,9 +378,17 @@ namespace v2rayN.Desktop.Views
this.Focus(); this.Focus();
} }
else else
{
if (Utils.IsWindows())
{ {
this.Hide(); this.Hide();
} }
else
{
this.WindowState = WindowState.Minimized;
}
}
_config.UiItem.ShowInTaskbar = bl; _config.UiItem.ShowInTaskbar = bl;
} }

View File

@@ -83,6 +83,7 @@
Classes="TextArea" Classes="TextArea"
IsReadOnly="True" IsReadOnly="True"
TextAlignment="Left" TextAlignment="Left"
VerticalAlignment="Stretch"
TextWrapping="Wrap"> TextWrapping="Wrap">
<TextBox.ContextMenu> <TextBox.ContextMenu>
<ContextMenu> <ContextMenu>

View File

@@ -20,16 +20,16 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Avalonia" Version="11.1.4" /> <PackageReference Include="Avalonia" Version="11.2.0" />
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.1.4" /> <PackageReference Include="Avalonia.Controls.DataGrid" Version="11.2.0" />
<PackageReference Include="Avalonia.Desktop" Version="11.1.4" /> <PackageReference Include="Avalonia.Desktop" Version="11.2.0" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.1.4" /> <PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.0" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.1.4" /> <PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.2.0" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.1.4" /> <PackageReference Include="Avalonia.ReactiveUI" Version="11.2.0" />
<PackageReference Include="DialogHost.Avalonia" Version="0.8.1" /> <PackageReference Include="DialogHost.Avalonia" Version="0.8.1" />
<PackageReference Include="MessageBox.Avalonia" Version="3.2.0" /> <PackageReference Include="MessageBox.Avalonia" Version="3.2.0" />
<PackageReference Include="Semi.Avalonia" Version="11.1.0.4" /> <PackageReference Include="Semi.Avalonia" Version="11.2.0" />
<PackageReference Include="Semi.Avalonia.DataGrid" Version="11.1.0.4" /> <PackageReference Include="Semi.Avalonia.DataGrid" Version="11.2.0" />
<PackageReference Include="ReactiveUI" Version="20.1.63" /> <PackageReference Include="ReactiveUI" Version="20.1.63" />
<PackageReference Include="ReactiveUI.Fody" Version="19.5.41" /> <PackageReference Include="ReactiveUI.Fody" Version="19.5.41" />
</ItemGroup> </ItemGroup>

View File

@@ -367,17 +367,17 @@ namespace v2rayN.Views
var bl = blShow ?? !_config.UiItem.ShowInTaskbar; var bl = blShow ?? !_config.UiItem.ShowInTaskbar;
if (bl) if (bl)
{ {
Application.Current.MainWindow.Show(); this?.Show();
if (Application.Current.MainWindow.WindowState == WindowState.Minimized) if (this?.WindowState == WindowState.Minimized)
{ {
Application.Current.MainWindow.WindowState = WindowState.Normal; this.WindowState = WindowState.Normal;
} }
Application.Current.MainWindow.Activate(); this?.Activate();
Application.Current.MainWindow.Focus(); this?.Focus();
} }
else else
{ {
Application.Current.MainWindow.Hide(); this?.Hide();
} }
_config.UiItem.ShowInTaskbar = bl; _config.UiItem.ShowInTaskbar = bl;
} }