From c9209454397d893a5350bd22507418a743ad22c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BE=89=E9=B8=AD=E8=9B=8B?= Date: Mon, 4 May 2026 13:46:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=89=A7=E8=A1=8C=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E7=BB=84=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../View/Pages/GearTaskListPage.xaml | 10 ++++- .../Pages/GearTaskListPageViewModel.cs | 40 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/BetterGenshinImpact/View/Pages/GearTaskListPage.xaml b/BetterGenshinImpact/View/Pages/GearTaskListPage.xaml index f6cb413e..9ff18221 100644 --- a/BetterGenshinImpact/View/Pages/GearTaskListPage.xaml +++ b/BetterGenshinImpact/View/Pages/GearTaskListPage.xaml @@ -144,6 +144,10 @@ Content="新建" Icon="{ui:SymbolIcon Add24}" Margin="0,0,4,0" /> + @@ -167,6 +171,10 @@ + - \ No newline at end of file + diff --git a/BetterGenshinImpact/ViewModel/Pages/GearTaskListPageViewModel.cs b/BetterGenshinImpact/ViewModel/Pages/GearTaskListPageViewModel.cs index 7fcb039d..357d06d8 100644 --- a/BetterGenshinImpact/ViewModel/Pages/GearTaskListPageViewModel.cs +++ b/BetterGenshinImpact/ViewModel/Pages/GearTaskListPageViewModel.cs @@ -317,6 +317,46 @@ public partial class GearTaskListPageViewModel : ViewModel await DeleteTaskDefinition(SelectedTaskDefinition); } + /// + /// 执行选中的任务定义(整组执行) + /// + [RelayCommand] + private async Task ExecuteSelectedTaskDefinition() + { + await ExecuteTaskDefinition(SelectedTaskDefinition); + } + + /// + /// 执行指定任务定义(整组执行) + /// + [RelayCommand] + private async Task ExecuteTaskDefinition(GearTaskDefinitionViewModel? taskDefinition) + { + taskDefinition ??= SelectedTaskDefinition; + if (taskDefinition == null) + { + Toast.Warning("请先选择要执行的任务组"); + return; + } + + try + { + var executor = App.GetRequiredService(); + if (executor.IsExecuting) + { + Toast.Warning("已有任务组正在执行,请稍后再试"); + return; + } + + await executor.ExecuteTaskDefinitionAsync(taskDefinition.Name); + } + catch (Exception ex) + { + _logger.LogError(ex, "执行任务定义失败: {TaskName}", taskDefinition.Name); + Toast.Error($"执行任务组失败:{ex.Message}"); + } + } + /// /// 添加任务节点