diff --git a/RevokeMsgPatcher/FormMain.cs b/RevokeMsgPatcher/FormMain.cs index f4c1b19..41a9364 100644 --- a/RevokeMsgPatcher/FormMain.cs +++ b/RevokeMsgPatcher/FormMain.cs @@ -90,7 +90,12 @@ namespace RevokeMsgPatcher panelCategories.Controls.Clear(); // 重新计算并修改界面元素 - modifier.InitEditors(path); + bool hasEditors = modifier.InitEditors(path); + if (!hasEditors) + { + btnPatch.Enabled = false; + return; + } modifier.SetVersionLabelAndCategoryCategories(lblVersion, panelCategories); EnableAllButton(true); @@ -134,7 +139,12 @@ namespace RevokeMsgPatcher EnableAllButton(false); // a.重新初始化编辑器 - modifier.InitEditors(txtPath.Text); + bool hasEditors = modifier.InitEditors(txtPath.Text); + if (!hasEditors) + { + btnPatch.Enabled = false; + return; + } // b.获取选择的功能 (精准匹配返回null) // TODO 此处逻辑可以优化 不可完全信任UI信息 List categories = UIController.GetCategoriesFromPanel(panelCategories); if (categories != null && categories.Count == 0) @@ -285,7 +295,7 @@ namespace RevokeMsgPatcher lblUpdatePachJson.Text = $"[ 存在最新版本 {newBag.LatestVersion} ]"; lblUpdatePachJson.ForeColor = Color.Red; } - else if(bag.PatchVersion == 0 || newBag.PatchVersion > bag.PatchVersion) + else if (bag.PatchVersion == 0 || newBag.PatchVersion > bag.PatchVersion) { needUpdate = false; lblUpdatePachJson.Text = "[ 获取成功,点击查看更多信息 ]"; diff --git a/RevokeMsgPatcher/Modifier/AppModifier.cs b/RevokeMsgPatcher/Modifier/AppModifier.cs index 4b2452e..b7fd58b 100644 --- a/RevokeMsgPatcher/Modifier/AppModifier.cs +++ b/RevokeMsgPatcher/Modifier/AppModifier.cs @@ -235,7 +235,7 @@ namespace RevokeMsgPatcher.Modifier /// a.初始化修改器 /// /// APP安装路径 - public void InitEditors(string installPath) + public bool InitEditors(string installPath) { // 初始化文件修改器 editors = new List(); @@ -251,8 +251,10 @@ namespace RevokeMsgPatcher.Modifier } if (editors.Count == 0) { - throw new BusinessException("no_support_editor", "当前版本没有对应的文件修改信息,请确认补丁信息是否正常!"); + MessageBox.Show("当前版本没有对应的文件修改信息,请确认补丁信息是否正常!"); + return false; } + return true; } ///