diff --git a/src/ST.Client.Desktop.Avalonia.App/CommandLineTools.cs b/src/ST.Client.Desktop.Avalonia.App/CommandLineTools.cs index ba8e10ea6..d749a7ad8 100644 --- a/src/ST.Client.Desktop.Avalonia.App/CommandLineTools.cs +++ b/src/ST.Client.Desktop.Avalonia.App/CommandLineTools.cs @@ -29,7 +29,8 @@ namespace System.Application.UI // https://docs.microsoft.com/zh-cn/archive/msdn-magazine/2019/march/net-parse-the-command-line-with-system-commandline var rootCommand = new RootCommand("命令行工具(Command Line Tools/CLT)"); - void MainHandler() + void MainHandler() => MainHandler_(null); + void MainHandler_(Action? onInitStartuped) { #if StartupTrace StartupTrace.Restart("ProcessCheck"); @@ -38,6 +39,7 @@ namespace System.Application.UI #if StartupTrace StartupTrace.Restart("Startup.Init"); #endif + onInitStartuped?.Invoke(); if (IsMainProcess) { var isInitAppInstanceReset = false; @@ -91,11 +93,12 @@ namespace System.Application.UI StartupTrace.Restart("InitAvaloniaApp"); #endif } - void MainHandlerByCLT() + void MainHandlerByCLT() => MainHandlerByCLT_(null); + void MainHandlerByCLT_(Action? onInitStartuped) { IsMainProcess = true; IsCLTProcess = false; - MainHandler(); + MainHandler_(onInitStartuped); } #if DEBUG @@ -122,8 +125,10 @@ namespace System.Application.UI devtools.Handler = CommandHandler.Create(() => { AppHelper.EnableDevtools = true; - AppHelper.LoggerMinLevel = LogLevel.Debug; - MainHandlerByCLT(); + MainHandlerByCLT_(onInitStartuped: () => + { + AppHelper.LoggerMinLevel = LogLevel.Debug; + }); }); rootCommand.AddCommand(devtools); diff --git a/src/ST.Client.Desktop/UI/AppHelper.cs b/src/ST.Client.Desktop/UI/AppHelper.cs index f9acd060a..25fdf3fe4 100644 --- a/src/ST.Client.Desktop/UI/AppHelper.cs +++ b/src/ST.Client.Desktop/UI/AppHelper.cs @@ -65,7 +65,7 @@ namespace System.Application.UI const LogLevel DefaultLoggerMinLevel = ThisAssembly.Debuggable ? LogLevel.Debug : LogLevel.Error; - public static NLogLevel DefaultNLoggerMinLevel = ConvertLogLevel(DefaultLoggerMinLevel); + public static readonly NLogLevel DefaultNLoggerMinLevel = ConvertLogLevel(DefaultLoggerMinLevel); /// /// Convert log level to NLog variant.