From 536ed10dbf87fa58567d52e0dd85e8c8f4e2dabb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BE=89=E9=B8=AD=E8=9B=8B?= Date: Tue, 17 Feb 2026 22:45:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E8=A1=8C=E5=8F=82=E6=95=B0=E6=A3=80=E6=B5=8B=E5=92=8C=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E7=BF=BB=E8=AF=91=E7=9A=84=E6=9D=A1=E4=BB=B6=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 命令行参数检测改为不区分大小写,确保参数匹配的可靠性 - 调试模式下禁用日志翻译,避免开发过程中的翻译干扰 - 仅非中文界面启用翻译日志提供程序,中文界面使用标准日志 --- BetterGenshinImpact/App.xaml.cs | 19 +++++++++++++++---- .../TranslatingSerilogLoggerProvider.cs | 4 +++- .../Service/ApplicationHostService.cs | 2 +- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/BetterGenshinImpact/App.xaml.cs b/BetterGenshinImpact/App.xaml.cs index 02f735bd..92bdc3f2 100644 --- a/BetterGenshinImpact/App.xaml.cs +++ b/BetterGenshinImpact/App.xaml.cs @@ -88,11 +88,22 @@ public partial class App : Application Log.Logger = loggerConfiguration.CreateLogger(); services.AddSingleton(); services.AddSingleton(); - services.AddLogging(logging => + + if ("zh-Hans".Equals(all.OtherConfig.UiCultureInfoName, StringComparison.OrdinalIgnoreCase)) { - logging.ClearProviders(); - logging.Services.AddSingleton(); - }); + services.AddLogging(c => c.AddSerilog()); + } + else + { + services.AddLogging(logging => + { + logging.ClearProviders(); + logging.SetMinimumLevel(LogLevel.Debug); + logging.AddFilter("Microsoft", LogLevel.Warning); + logging.AddFilter("Microsoft.Hosting.Lifetime", LogLevel.Warning); + logging.Services.AddSingleton(); + }); + } services.AddLocalization(); diff --git a/BetterGenshinImpact/Helpers/TranslatingSerilogLoggerProvider.cs b/BetterGenshinImpact/Helpers/TranslatingSerilogLoggerProvider.cs index 6b72fc44..e4e73304 100644 --- a/BetterGenshinImpact/Helpers/TranslatingSerilogLoggerProvider.cs +++ b/BetterGenshinImpact/Helpers/TranslatingSerilogLoggerProvider.cs @@ -66,7 +66,9 @@ public sealed class TranslatingSerilogLoggerProvider : ILoggerProvider } var (template, values) = ExtractTemplateAndValues(state, formatter, exception); - var translatedTemplate = _translationService.Translate(template, TranslationSourceInfo.From(MissingTextSource.Log)); + var translatedTemplate = RuntimeHelper.IsDebuggerAttached + ? template + : _translationService.Translate(template, TranslationSourceInfo.From(MissingTextSource.Log)); if (values.Length == 0) { diff --git a/BetterGenshinImpact/Service/ApplicationHostService.cs b/BetterGenshinImpact/Service/ApplicationHostService.cs index 53e0fbef..21841f89 100644 --- a/BetterGenshinImpact/Service/ApplicationHostService.cs +++ b/BetterGenshinImpact/Service/ApplicationHostService.cs @@ -58,7 +58,7 @@ public class ApplicationHostService(IServiceProvider serviceProvider) : IHostedS //无论如何,先跳到主页,否则在通过参数的任务在执行完之前,不会加载快捷键 _ = _navigationWindow.Navigate(typeof(HomePage)); - if (args[1].Contains("startOneDragon")) + if (args[1].Contains("startOneDragon", StringComparison.InvariantCultureIgnoreCase)) { // 通过命令行参数启动「一条龙」 => 跳转到一条龙配置页。