mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-05-21 09:45:48 +08:00
移除任务定义项双击重命名功能,简化界面交互
This commit is contained in:
@@ -169,37 +169,7 @@ public class GearTaskStorageService
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重命名任务定义文件
|
||||
/// </summary>
|
||||
/// <param name="oldName">旧名称</param>
|
||||
/// <param name="newName">新名称</param>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 将 ViewModel 转换为数据模型
|
||||
|
||||
@@ -173,7 +173,7 @@
|
||||
<Setter Property="Margin" Value="0" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<EventSetter Event="MouseDoubleClick" Handler="TaskDefinitionItem_MouseDoubleClick" />
|
||||
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
|
||||
@@ -19,15 +19,5 @@ public partial class GearTaskListPage : UserControl
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 任务定义项双击事件
|
||||
/// </summary>
|
||||
private void TaskDefinitionItem_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (sender is ListBoxItem item && item.DataContext is GearTaskDefinitionViewModel taskDefinition)
|
||||
{
|
||||
// 双击重命名
|
||||
ViewModel.RenameTaskDefinitionCommand.Execute(taskDefinition);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -337,31 +337,7 @@ public partial class GearTaskListPageViewModel : ViewModel
|
||||
await DeleteTaskDefinition(SelectedTaskDefinition);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重命名任务定义
|
||||
/// </summary>
|
||||
[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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加任务节点
|
||||
|
||||
Reference in New Issue
Block a user