From 7d787fcd5db2e221dfe6651bcb3b291533ff58e7 Mon Sep 17 00:00:00 2001 From: MistEO Date: Thu, 23 Jun 2022 22:33:24 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=87=8F=E5=B0=91=E8=BD=BD=E5=85=A5?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E6=97=B6=E7=9A=84=E6=96=87=E4=BB=B6=E8=AF=BB?= =?UTF-8?q?=E5=86=99=E9=A2=91=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MeoAsstGui/ViewModels/CopilotViewModel.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/MeoAsstGui/ViewModels/CopilotViewModel.cs b/src/MeoAsstGui/ViewModels/CopilotViewModel.cs index c5d53cb439..d6a6960b3a 100644 --- a/src/MeoAsstGui/ViewModels/CopilotViewModel.cs +++ b/src/MeoAsstGui/ViewModels/CopilotViewModel.cs @@ -155,12 +155,14 @@ namespace MeoAsstGui } private string _curStageName = ""; + private string _curCopilotData = ""; private const string _tempCopilotFile = "resource/_temp_copilot.json"; private void _parseJsonAndShowInfo(string jsonStr) { try { + _curCopilotData = ""; var json = (JObject)JsonConvert.DeserializeObject(jsonStr); if (json == null || !json.ContainsKey("doc")) { @@ -235,7 +237,7 @@ namespace MeoAsstGui AddLog(string.Format("共 {0} 名干员", count), "black"); _curStageName = json["stage_name"].ToString(); - File.WriteAllText(_tempCopilotFile, json.ToString()); + _curCopilotData = json.ToString(); } catch (Exception) { @@ -310,11 +312,8 @@ namespace MeoAsstGui AddLog(errMsg, "darkred"); } - if (!File.Exists(_tempCopilotFile)) - { - AddLog("作业文件不存在", "darkred"); - return; - } + File.Delete(_tempCopilotFile); + File.WriteAllText(_tempCopilotFile, _curCopilotData); bool ret = asstProxy.AsstStartCopilot(_curStageName, _tempCopilotFile, Form); if (ret)