From ca47a8eaf9cd2d5d6a0355580c23d89bb5cfbdb8 Mon Sep 17 00:00:00 2001 From: status102 <102887808+status102@users.noreply.github.com> Date: Sun, 21 Dec 2025 00:59:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20Wpf=E6=97=A5=E5=BF=97=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=BE=93=E5=87=BA=E5=88=86=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModels/UI/CopilotViewModel.cs | 20 +++++++++++++++++-- .../ViewModels/UI/TaskQueueViewModel.cs | 20 +++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/MaaWpfGui/ViewModels/UI/CopilotViewModel.cs b/src/MaaWpfGui/ViewModels/UI/CopilotViewModel.cs index 0f549d03dc..5c27687c4f 100644 --- a/src/MaaWpfGui/ViewModels/UI/CopilotViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/CopilotViewModel.cs @@ -126,14 +126,30 @@ public partial class CopilotViewModel : Screen /// The font color. /// The font weight. /// Whether show time. - public void AddLog(string content, string color = UiLogColor.Trace, string weight = "Regular", bool showTime = true) + public void AddLog(string? content, string color = UiLogColor.Trace, string weight = "Regular", bool showTime = true) { + if (string.IsNullOrEmpty(content)) + { + return; + } + Execute.OnUIThread(() => { LogItemViewModels.Add(new LogItemViewModel(content, color, weight, "HH':'mm':'ss", showTime: showTime)); if (showTime) { - _logger.Information(content); + switch (color) + { + case UiLogColor.Error: + _logger.Error("{Content}", content); + break; + case UiLogColor.Warning: + _logger.Warning("{Content}", content); + break; + default: + _logger.Information("{Content}", content); + break; + } } }); diff --git a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs index ec449047e6..e8f7a1a903 100644 --- a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs @@ -884,13 +884,29 @@ public class TaskQueueViewModel : Screen /// The font color. /// The font weight. /// The toolTip - public void AddLog(string content, string color = UiLogColor.Trace, string weight = "Regular", ToolTip? toolTip = null) + public void AddLog(string? content, string color = UiLogColor.Trace, string weight = "Regular", ToolTip? toolTip = null) { + if (string.IsNullOrWhiteSpace(content)) + { + return; + } + Execute.OnUIThread(() => { var log = new LogItemViewModel(content, color, weight, toolTip: toolTip); LogItemViewModels.Add(log); - _logger.Information("{Content}", content); + switch (color) + { + case UiLogColor.Error: + _logger.Error("{Content}", content); + break; + case UiLogColor.Warning: + _logger.Warning("{Content}", content); + break; + default: + _logger.Information("{Content}", content); + break; + } }); }