From b793f92a739ca5f0814e1537b82aa12d6379f7c6 Mon Sep 17 00:00:00 2001 From: fonaix Date: Sun, 1 Dec 2024 02:51:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E6=97=B6=EF=BC=8C=E7=AA=97=E5=8F=A3=E4=BC=9A?= =?UTF-8?q?=E9=97=AA=E4=B8=80=E4=B8=8B=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- v2rayN/v2rayN.Desktop/App.axaml.cs | 10 +++++++++- v2rayN/v2rayN.Desktop/Views/StatusBarView.axaml.cs | 11 +++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/v2rayN/v2rayN.Desktop/App.axaml.cs b/v2rayN/v2rayN.Desktop/App.axaml.cs index 898de4e8..d3bbde67 100644 --- a/v2rayN/v2rayN.Desktop/App.axaml.cs +++ b/v2rayN/v2rayN.Desktop/App.axaml.cs @@ -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(); diff --git a/v2rayN/v2rayN.Desktop/Views/StatusBarView.axaml.cs b/v2rayN/v2rayN.Desktop/Views/StatusBarView.axaml.cs index f97e0e85..1fdf2791 100644 --- a/v2rayN/v2rayN.Desktop/Views/StatusBarView.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/StatusBarView.axaml.cs @@ -77,10 +77,13 @@ namespace v2rayN.Desktop.Views { if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { - desktop.MainWindow.Icon = AvaUtils.GetAppIcon(_config.SystemProxyItem.SysProxyType); - var iconslist = TrayIcon.GetIcons(Application.Current); - iconslist[0].Icon = desktop.MainWindow.Icon; - TrayIcon.SetIcons(Application.Current, iconslist); + if (desktop.MainWindow != null) + { + desktop.MainWindow.Icon = AvaUtils.GetAppIcon(_config.SystemProxyItem.SysProxyType); + var iconslist = TrayIcon.GetIcons(Application.Current); + iconslist[0].Icon = desktop.MainWindow.Icon; + TrayIcon.SetIcons(Application.Current, iconslist); + } } }