修复:后台启动时,窗口会闪一下的问题

This commit is contained in:
fonaix 2024-12-01 02:51:59 +08:00
parent d3a0b44247
commit b793f92a73
2 changed files with 16 additions and 5 deletions

View file

@ -33,7 +33,15 @@ public partial class App : Application
AppHandler.Instance.InitComponents();
desktop.Exit += OnExit;
desktop.MainWindow = new MainWindow();
var mainWindow = new MainWindow();
if (!AppHandler.Instance.Config.UiItem.AutoHideStartup)
{
desktop.MainWindow = mainWindow;
}
else
{
desktop.MainWindow = null;
}
}
base.OnFrameworkInitializationCompleted();

View file

@ -76,6 +76,8 @@ namespace v2rayN.Desktop.Views
private void RefreshIcon()
{
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
if (desktop.MainWindow != null)
{
desktop.MainWindow.Icon = AvaUtils.GetAppIcon(_config.SystemProxyItem.SysProxyType);
var iconslist = TrayIcon.GetIcons(Application.Current);
@ -83,6 +85,7 @@ namespace v2rayN.Desktop.Views
TrayIcon.SetIcons(Application.Current, iconslist);
}
}
}
private void TxtRunningServerDisplay_Tapped(object? sender, Avalonia.Input.TappedEventArgs e)
{