fix: 错误的关卡名可能导致验证崩溃

This commit is contained in:
uye
2025-09-01 17:36:24 +08:00
parent 3943189550
commit 7b36d43e5e

View File

@@ -1123,6 +1123,11 @@ namespace MaaWpfGui.ViewModels.UI
var codeName = stageName![4..^2];
var characterInfo = DataHelper.GetCharacterByCodeName(codeName);
var name = DataHelper.GetLocalizedCharacterName(characterInfo);
if (string.IsNullOrEmpty(name))
{
name = stageName;
}
var item = new CopilotItemViewModel(name, cachePath, false, copilotId) { Index = CopilotItemViewModels.Count, };
CopilotItemViewModels.Add(item);
}
@@ -1433,7 +1438,7 @@ namespace MaaWpfGui.ViewModels.UI
return false;
}
if (copilotItemViewModels.Any(i => string.IsNullOrEmpty(i.Name.Trim())))
if (copilotItemViewModels.Any(i => string.IsNullOrEmpty(i.Name?.Trim())))
{
AddLog(LocalizationHelper.GetString("CopilotTasksWithEmptyName"), UiLogColor.Error, showTime: false);
return false;