From 55e98b5d49fce3f5c7e11fbec905b72f669dd55b Mon Sep 17 00:00:00 2001 From: huiyadanli Date: Sat, 3 Aug 2019 19:38:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=8E=E7=BD=91=E4=B8=8A=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=9C=80=E6=96=B0=E7=9A=84=E8=A1=A5=E4=B8=81?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E7=94=A8=E4=BA=8E=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RevokeMsgPatcher/FormMain.Designer.cs | 15 ++++++++++ RevokeMsgPatcher/FormMain.cs | 33 +++++++++++++++++++++ RevokeMsgPatcher/Patcher.cs | 11 +++++-- RevokeMsgPatcher/Properties/AssemblyInfo.cs | 4 +-- 4 files changed, 58 insertions(+), 5 deletions(-) diff --git a/RevokeMsgPatcher/FormMain.Designer.cs b/RevokeMsgPatcher/FormMain.Designer.cs index 1fd1071..b8c0d0f 100644 --- a/RevokeMsgPatcher/FormMain.Designer.cs +++ b/RevokeMsgPatcher/FormMain.Designer.cs @@ -36,6 +36,7 @@ this.label1 = new System.Windows.Forms.Label(); this.linkLabel1 = new System.Windows.Forms.LinkLabel(); this.btnRestore = new System.Windows.Forms.Button(); + this.lblUpdatePachJson = new System.Windows.Forms.Label(); this.SuspendLayout(); // // label2 @@ -109,11 +110,23 @@ this.btnRestore.UseVisualStyleBackColor = true; this.btnRestore.Click += new System.EventHandler(this.btnRestore_Click); // + // lblUpdatePachJson + // + this.lblUpdatePachJson.AutoSize = true; + this.lblUpdatePachJson.Cursor = System.Windows.Forms.Cursors.Hand; + this.lblUpdatePachJson.Location = new System.Drawing.Point(198, 44); + this.lblUpdatePachJson.Name = "lblUpdatePachJson"; + this.lblUpdatePachJson.Size = new System.Drawing.Size(131, 12); + this.lblUpdatePachJson.TabIndex = 9; + this.lblUpdatePachJson.Text = "获取最新补丁信息中..."; + this.lblUpdatePachJson.Click += new System.EventHandler(this.lblUpdatePachJson_Click); + // // FormMain // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(523, 69); + this.Controls.Add(this.lblUpdatePachJson); this.Controls.Add(this.btnRestore); this.Controls.Add(this.linkLabel1); this.Controls.Add(this.label1); @@ -125,6 +138,7 @@ this.Name = "FormMain"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "微信防撤回补丁"; + this.Load += new System.EventHandler(this.FormMain_Load); this.ResumeLayout(false); this.PerformLayout(); @@ -138,6 +152,7 @@ private System.Windows.Forms.Label label1; private System.Windows.Forms.LinkLabel linkLabel1; private System.Windows.Forms.Button btnRestore; + private System.Windows.Forms.Label lblUpdatePachJson; } } diff --git a/RevokeMsgPatcher/FormMain.cs b/RevokeMsgPatcher/FormMain.cs index 012c1c3..a7a9649 100644 --- a/RevokeMsgPatcher/FormMain.cs +++ b/RevokeMsgPatcher/FormMain.cs @@ -1,5 +1,7 @@ using System; using System.IO; +using System.Net; +using System.Threading.Tasks; using System.Windows.Forms; namespace RevokeMsgPatcher @@ -125,5 +127,36 @@ namespace RevokeMsgPatcher { System.Diagnostics.Process.Start("https://github.com/huiyadanli/RevokeMsgPatcher"); } + + private async void FormMain_Load(object sender, EventArgs e) + { + // 异步获取最新的补丁信息 + Task t = new Task(() => + { + return new WebClient().DownloadString("https://huiyadanli.coding.me/i/patch.json"); + }); + t.Start(); + string json = await t; + if(string.IsNullOrEmpty(json)) + { + lblUpdatePachJson.Text = "获取失败"; + + } else + { + patcher.SetNewPatchJson(json); + lblUpdatePachJson.Text = "获取成功"; + } + + } + + private void lblUpdatePachJson_Click(object sender, EventArgs e) + { + string versions = ""; + patcher.TargetFiles.ForEach(t => + { + versions += t.Version + Environment.NewLine; + }); + MessageBox.Show("当前所支持的微信版本:" + Environment.NewLine + versions); + } } } diff --git a/RevokeMsgPatcher/Patcher.cs b/RevokeMsgPatcher/Patcher.cs index 5154494..8e69281 100644 --- a/RevokeMsgPatcher/Patcher.cs +++ b/RevokeMsgPatcher/Patcher.cs @@ -1,5 +1,4 @@ using RevokeMsgPatcher.Model; -using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; @@ -9,7 +8,6 @@ namespace RevokeMsgPatcher { public class Patcher { - private string intallPath; public string IntallPath { @@ -40,12 +38,20 @@ namespace RevokeMsgPatcher private List targetFiles; private TargetFile currentFile; + public List TargetFiles { get => targetFiles; } + public Patcher() { JavaScriptSerializer serializer = new JavaScriptSerializer(); targetFiles = serializer.Deserialize>(Properties.Resources.PatchJson); } + public void SetNewPatchJson(string json) + { + JavaScriptSerializer serializer = new JavaScriptSerializer(); + targetFiles = serializer.Deserialize>(json); + } + public string JudgeVersion() { string sha1 = Util.ComputeFileSHA1(dllPath); @@ -63,7 +69,6 @@ namespace RevokeMsgPatcher return t.Version; } } - return null; } diff --git a/RevokeMsgPatcher/Properties/AssemblyInfo.cs b/RevokeMsgPatcher/Properties/AssemblyInfo.cs index 158fc48..8154376 100644 --- a/RevokeMsgPatcher/Properties/AssemblyInfo.cs +++ b/RevokeMsgPatcher/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 // 方法是按如下所示使用“*”: : //[assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.3")] -[assembly: AssemblyFileVersion("0.3")] +[assembly: AssemblyVersion("0.4")] +[assembly: AssemblyFileVersion("0.4")]