From c2ef3a4a8c8ea2f2aa1cba8921c44f78f0c278a5 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Wed, 29 Oct 2025 20:21:41 +0800 Subject: [PATCH] Add Design.IsDesignMode to the desktop version --- v2rayN/v2rayN.Desktop/App.axaml.cs | 8 +++++--- v2rayN/v2rayN.Desktop/Program.cs | 21 ++++++++++++++------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/v2rayN/v2rayN.Desktop/App.axaml.cs b/v2rayN/v2rayN.Desktop/App.axaml.cs index 5da86c6e..35371f0f 100644 --- a/v2rayN/v2rayN.Desktop/App.axaml.cs +++ b/v2rayN/v2rayN.Desktop/App.axaml.cs @@ -10,15 +10,17 @@ public partial class App : Application AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException; - - DataContext = StatusBarViewModel.Instance; } public override void OnFrameworkInitializationCompleted() { if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { - AppManager.Instance.InitComponents(); + if (!Design.IsDesignMode) + { + AppManager.Instance.InitComponents(); + DataContext = StatusBarViewModel.Instance; + } desktop.Exit += OnExit; desktop.MainWindow = new MainWindow(); diff --git a/v2rayN/v2rayN.Desktop/Program.cs b/v2rayN/v2rayN.Desktop/Program.cs index 1a0ce38e..70c43130 100644 --- a/v2rayN/v2rayN.Desktop/Program.cs +++ b/v2rayN/v2rayN.Desktop/Program.cs @@ -54,12 +54,19 @@ internal class Program // Avalonia configuration, don't remove; also used by visual designer. public static AppBuilder BuildAvaloniaApp() { - return AppBuilder.Configure() - .UsePlatformDetect() - //.WithInterFont() - .WithFontByDefault() - .LogToTrace() - .UseReactiveUI() - .With(new MacOSPlatformOptions { ShowInDock = AppManager.Instance.Config.UiItem.MacOSShowInDock }); + var builder = AppBuilder.Configure() + .UsePlatformDetect() + //.WithInterFont() + .WithFontByDefault() + .LogToTrace() + .UseReactiveUI(); + + if (OperatingSystem.IsMacOS()) + { + var showInDock = Design.IsDesignMode || AppManager.Instance.Config.UiItem.MacOSShowInDock; + builder = builder.With(new MacOSPlatformOptions { ShowInDock = showInDock }); + } + + return builder; } }