From d1183830bdbbe26c45c383d9b8a30f30a8ffcea8 Mon Sep 17 00:00:00 2001 From: status102 <102887808+status102@users.noreply.github.com> Date: Thu, 18 Jul 2024 18:27:46 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E8=87=AA=E5=8A=A8=E6=88=98=E6=96=97-?= =?UTF-8?q?=E6=88=98=E6=96=97=E5=88=97=E8=A1=A8=20=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=85=B3=E5=8D=A1=E5=90=8D=E6=AD=A3=E5=88=99?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaWpfGui/Main/AsstProxy.cs | 2 +- src/MaaWpfGui/ViewModels/UI/CopilotViewModel.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/MaaWpfGui/Main/AsstProxy.cs b/src/MaaWpfGui/Main/AsstProxy.cs index 2167a7a145..afd00022ab 100644 --- a/src/MaaWpfGui/Main/AsstProxy.cs +++ b/src/MaaWpfGui/Main/AsstProxy.cs @@ -345,7 +345,7 @@ namespace MaaWpfGui.Main private void CallbackFunction(int msg, AsstHandle jsonBuffer, AsstHandle customArg) { - string jsonStr = PtrToStringCustom(jsonBuffer, Encoding.UTF8); + var jsonStr = PtrToStringCustom(jsonBuffer, Encoding.UTF8); // Console.WriteLine(json_str); var json = (JObject?)JsonConvert.DeserializeObject(jsonStr); diff --git a/src/MaaWpfGui/ViewModels/UI/CopilotViewModel.cs b/src/MaaWpfGui/ViewModels/UI/CopilotViewModel.cs index b14d20fd01..7b134b6072 100644 --- a/src/MaaWpfGui/ViewModels/UI/CopilotViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/CopilotViewModel.cs @@ -283,7 +283,7 @@ namespace MaaWpfGui.ViewModels.UI private const string TempCopilotFile = "cache/_temp_copilot.json"; private string _taskType = "General"; - private const string StageNameRegex = @"(?:[a-z]{0,3})(?:\d{0,2})-(?:(?:A|B|C|D|EX|S|TR|MO)-)?(?:\d{1,2})(\(Raid\))?"; + private const string StageNameRegex = @"(?:[a-z]{0,3})(?:\d{0,2})-(?:(?:A|B|C|D|EX|S|TR|MO)-)?(?:\d{1,2})(\(Raid\)(?=\.json))?"; /// /// 为自动战斗列表匹配名字 @@ -299,7 +299,7 @@ namespace MaaWpfGui.ViewModels.UI } // 一旦有由小写字母、数字、'-'组成的name则视为关卡名直接使用 - var directName = names.FirstOrDefault(name => name.ToLower().All(c => (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '-')); + var directName = names.FirstOrDefault(name => Regex.IsMatch(name.ToLower(), @"^[0-9a-z\-]+$")); if (!string.IsNullOrEmpty(directName)) { return directName; @@ -589,7 +589,7 @@ namespace MaaWpfGui.ViewModels.UI } var fileName = fileInfo.Name[..^fileInfo.Extension.Length]; - var stageName = FindStageName(fileName); + var stageName = FindStageName(fileInfo.Name, fileName); if (string.IsNullOrEmpty(stageName)) {