From 91c4151975c995eedc1726a437b39c42334b2420 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BE=89=E9=B8=AD=E8=9B=8B?= Date: Sat, 6 Sep 2025 21:27:50 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E4=BB=BB=E5=8A=A1=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E9=A1=B9=E5=8F=8C=E5=87=BB=E9=87=8D=E5=91=BD=E5=90=8D?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=8C=E7=AE=80=E5=8C=96=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E4=BA=A4=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GearTask/GearTaskStorageService.cs | 32 +------------------ .../View/Pages/GearTaskListPage.xaml | 2 +- .../View/Pages/GearTaskListPage.xaml.cs | 12 +------ .../Pages/GearTaskListPageViewModel.cs | 26 +-------------- 4 files changed, 4 insertions(+), 68 deletions(-) diff --git a/BetterGenshinImpact/Service/GearTask/GearTaskStorageService.cs b/BetterGenshinImpact/Service/GearTask/GearTaskStorageService.cs index cbedc921..04f44857 100644 --- a/BetterGenshinImpact/Service/GearTask/GearTaskStorageService.cs +++ b/BetterGenshinImpact/Service/GearTask/GearTaskStorageService.cs @@ -169,37 +169,7 @@ public class GearTaskStorageService } } - /// - /// 重命名任务定义文件 - /// - /// 旧名称 - /// 新名称 - /// - public async Task RenameTaskDefinitionAsync(string oldName, string newName) - { - try - { - var oldFileName = GetSafeFileName(oldName) + ".json"; - var newFileName = GetSafeFileName(newName) + ".json"; - var oldFilePath = Path.Combine(_taskStoragePath, oldFileName); - var newFilePath = Path.Combine(_taskStoragePath, newFileName); - - if (File.Exists(oldFilePath)) - { - await Task.Run(() => File.Move(oldFilePath, newFilePath)); - _logger.LogInformation("任务定义文件已重命名: {OldPath} -> {NewPath}", oldFilePath, newFilePath); - } - else - { - _logger.LogWarning("要重命名的任务定义文件不存在: {FilePath}", oldFilePath); - } - } - catch (Exception ex) - { - _logger.LogError(ex, "重命名任务定义 '{OldName}' -> '{NewName}' 时发生错误", oldName, newName); - throw; - } - } + /// /// 将 ViewModel 转换为数据模型 diff --git a/BetterGenshinImpact/View/Pages/GearTaskListPage.xaml b/BetterGenshinImpact/View/Pages/GearTaskListPage.xaml index f997b363..a9b4f093 100644 --- a/BetterGenshinImpact/View/Pages/GearTaskListPage.xaml +++ b/BetterGenshinImpact/View/Pages/GearTaskListPage.xaml @@ -173,7 +173,7 @@ - + diff --git a/BetterGenshinImpact/View/Pages/GearTaskListPage.xaml.cs b/BetterGenshinImpact/View/Pages/GearTaskListPage.xaml.cs index 91027ec7..74fbca7a 100644 --- a/BetterGenshinImpact/View/Pages/GearTaskListPage.xaml.cs +++ b/BetterGenshinImpact/View/Pages/GearTaskListPage.xaml.cs @@ -19,15 +19,5 @@ public partial class GearTaskListPage : UserControl InitializeComponent(); } - /// - /// 任务定义项双击事件 - /// - private void TaskDefinitionItem_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - if (sender is ListBoxItem item && item.DataContext is GearTaskDefinitionViewModel taskDefinition) - { - // 双击重命名 - ViewModel.RenameTaskDefinitionCommand.Execute(taskDefinition); - } - } + } \ No newline at end of file diff --git a/BetterGenshinImpact/ViewModel/Pages/GearTaskListPageViewModel.cs b/BetterGenshinImpact/ViewModel/Pages/GearTaskListPageViewModel.cs index 27a1f3d2..44e27c87 100644 --- a/BetterGenshinImpact/ViewModel/Pages/GearTaskListPageViewModel.cs +++ b/BetterGenshinImpact/ViewModel/Pages/GearTaskListPageViewModel.cs @@ -337,31 +337,7 @@ public partial class GearTaskListPageViewModel : ViewModel await DeleteTaskDefinition(SelectedTaskDefinition); } - /// - /// 重命名任务定义 - /// - [RelayCommand] - private async Task RenameTaskDefinition(GearTaskDefinitionViewModel? taskDefinition) - { - if (taskDefinition == null) return; - - // 这里可以弹出重命名对话框,暂时简单处理 - var newName = "新名称"; // 简化处理,实际应该弹出输入框 - - if (!string.IsNullOrWhiteSpace(newName) && newName != taskDefinition.Name) - { - var oldName = taskDefinition.Name; - taskDefinition.Name = newName; - taskDefinition.ModifiedTime = DateTime.Now; - if (taskDefinition.RootTask != null) - { - taskDefinition.RootTask.Name = newName; - } - - // 重命名对应的 JSON 文件 - await _storageService.RenameTaskDefinitionAsync(oldName, newName); - } - } + /// /// 添加任务节点