diff --git a/Assets/Scripts/Tools/AsposeHelper.cs b/Assets/Scripts/Tools/AsposeHelper.cs index db787fc5..f0bafae1 100644 --- a/Assets/Scripts/Tools/AsposeHelper.cs +++ b/Assets/Scripts/Tools/AsposeHelper.cs @@ -5,14 +5,14 @@ using System.IO; using UnityEngine; using System.Windows.Forms; using Newtonsoft.Json.Linq; +using System; public class AsposeHelper : MonoBehaviour { - public static void Writer(string json) + public static void Writer(string json, Action callback = null) { - Debug.LogError(File.Exists(Global.reportDemoPath)); // 加载Word文档 Document doc = new Document(Global.reportDemoPath); @@ -25,21 +25,23 @@ public class AsposeHelper : MonoBehaviour doc.Range.Replace($"{{{key}}}", $"{value}", new FindReplaceOptions()); } // 替换文本 - SaveWithDialog(doc); + SaveWithDialog(doc, callback); //Debug.Log("文档处理完成,新文档已保存到: " + outputFilePath); } - private static void SaveWithDialog(Document doc) + private static void SaveWithDialog(Document doc, Action callback) { SaveFileDialog dialog = new SaveFileDialog(); dialog.Filter = "Word文档|*.docx"; - if (dialog.ShowDialog() == DialogResult.OK) + var result = dialog.ShowDialog(); + if (result == DialogResult.OK) { doc.Save(dialog.FileName); } + callback?.Invoke(result); } } diff --git a/Assets/Scripts/UI/UIScore.cs b/Assets/Scripts/UI/UIScore.cs index 68ff27c3..1b8d5ea4 100644 --- a/Assets/Scripts/UI/UIScore.cs +++ b/Assets/Scripts/UI/UIScore.cs @@ -36,7 +36,12 @@ namespace QFramework.Example }); loader.LoadAsync(); #elif UNITY_STANDALONE_WIN - AsposeHelper.Writer(GetScoreDataJson()); + DownLoad.interactable = false; + AsposeHelper.Writer(GetScoreDataJson(), result => + { + Debug.LogError("111"); + DownLoad.interactable = true; + }); #endif