Skip to content

Commit

Permalink
macOS 一些优化 (#6596)
Browse files Browse the repository at this point in the history
* [macOS] hide icon in Dock

* [macOS] fix: close button not work

* [macOS] fix: cant directly show window when click `Show or hide the main window` on minimized
  • Loading branch information
ShiinaRinne authored Jan 29, 2025
1 parent e674a02 commit f71125d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
3 changes: 2 additions & 1 deletion v2rayN/v2rayN.Desktop/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@ public static AppBuilder BuildAvaloniaApp()
//.WithInterFont()
.WithFontByDefault()
.LogToTrace()
.UseReactiveUI();
.UseReactiveUI()
.With(new MacOSPlatformOptions { ShowInDock = false});
}
47 changes: 24 additions & 23 deletions v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,8 @@ private async void MenuClose_Click(object? sender, RoutedEventArgs e)
_blCloseByUser = true;
StorageUI();

await ViewModel?.MyAppExitAsync(false);
await ViewModel?.MyAppExitAsync(false);
Close();
}

#endregion Event
Expand All @@ -398,28 +399,28 @@ private async void MenuClose_Click(object? sender, RoutedEventArgs e)

public void ShowHideWindow(bool? blShow)
{
var bl = blShow ?? !_config.UiItem.ShowInTaskbar;
if (bl)
{
this.Show();
if (this.WindowState == WindowState.Minimized)
{
this.WindowState = WindowState.Normal;
}
this.Activate();
this.Focus();
}
else
{
if (_config.UiItem.Hide2TrayWhenClose)
{
this.Hide();
}
else
{
this.WindowState = WindowState.Minimized;
}
}
var bl = blShow ?? (!_config.UiItem.ShowInTaskbar ^ (WindowState==WindowState.Minimized));
if (bl)
{
this.Show();
if (this.WindowState == WindowState.Minimized)
{
this.WindowState = WindowState.Normal;
}
this.Activate();
this.Focus();
}
else
{
if (Utils.IsOSX() || _config.UiItem.Hide2TrayWhenClose)
{
this.Hide();
}
else
{
this.WindowState = WindowState.Minimized;
}
}

_config.UiItem.ShowInTaskbar = bl;
}
Expand Down

0 comments on commit f71125d

Please sign in to comment.