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

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(); AppHandler.Instance.InitComponents();
desktop.Exit += OnExit; 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(); base.OnFrameworkInitializationCompleted();

View file

@ -77,10 +77,13 @@ namespace v2rayN.Desktop.Views
{ {
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{ {
desktop.MainWindow.Icon = AvaUtils.GetAppIcon(_config.SystemProxyItem.SysProxyType); if (desktop.MainWindow != null)
var iconslist = TrayIcon.GetIcons(Application.Current); {
iconslist[0].Icon = desktop.MainWindow.Icon; desktop.MainWindow.Icon = AvaUtils.GetAppIcon(_config.SystemProxyItem.SysProxyType);
TrayIcon.SetIcons(Application.Current, iconslist); var iconslist = TrayIcon.GetIcons(Application.Current);
iconslist[0].Icon = desktop.MainWindow.Icon;
TrayIcon.SetIcons(Application.Current, iconslist);
}
} }
} }