mirror of
https://github.com/huiyadanli/RevokeMsgPatcher.git
synced 2025-05-23 13:56:07 +08:00
[+] 修改补丁获取方式,添加补丁版本信息
This commit is contained in:
parent
37bab09a7d
commit
c83e12f9f7
File diff suppressed because one or more lines are too long
|
@ -17,6 +17,7 @@ namespace RevokeMsgPatcher
|
|||
{
|
||||
Apps = AppConfig(),
|
||||
LatestVersion = "1.2",
|
||||
PatchVersion = 20220325,
|
||||
Notice = ""
|
||||
};
|
||||
}
|
||||
|
|
|
@ -28,11 +28,13 @@ namespace RevokeMsgPatcher
|
|||
|
||||
private readonly GAHelper ga = GAHelper.Instance; // Google Analytics 记录
|
||||
|
||||
Bag bag = null;
|
||||
|
||||
public void InitModifier()
|
||||
{
|
||||
// 从配置文件中读取配置
|
||||
JavaScriptSerializer serializer = new JavaScriptSerializer();
|
||||
Bag bag = serializer.Deserialize<Bag>(Properties.Resources.PatchJson);
|
||||
bag = serializer.Deserialize<Bag>(Properties.Resources.PatchJson);
|
||||
|
||||
// 初始化每个应用对应的修改者
|
||||
wechatModifier = new WechatModifier(bag.Apps["Wechat"]);
|
||||
|
@ -275,27 +277,35 @@ namespace RevokeMsgPatcher
|
|||
try
|
||||
{
|
||||
JavaScriptSerializer serializer = new JavaScriptSerializer();
|
||||
Bag bag = serializer.Deserialize<Bag>(json);
|
||||
Bag newBag = serializer.Deserialize<Bag>(json);
|
||||
|
||||
wechatModifier.Config = bag.Apps["Wechat"];
|
||||
qqModifier.Config = bag.Apps["QQ"];
|
||||
timModifier.Config = bag.Apps["TIM"];
|
||||
qqLiteModifier.Config = bag.Apps["QQLite"];
|
||||
|
||||
if (Convert.ToDecimal(bag.LatestVersion) > Convert.ToDecimal(thisVersion))
|
||||
if (Convert.ToDecimal(newBag.LatestVersion) > Convert.ToDecimal(thisVersion))
|
||||
{
|
||||
needUpdate = true;
|
||||
lblUpdatePachJson.Text = $"[ 存在最新版本 {bag.LatestVersion} ]";
|
||||
lblUpdatePachJson.Text = $"[ 存在最新版本 {newBag.LatestVersion} ]";
|
||||
lblUpdatePachJson.ForeColor = Color.Red;
|
||||
}
|
||||
else
|
||||
else if(bag.PatchVersion == 0 || newBag.PatchVersion > bag.PatchVersion)
|
||||
{
|
||||
needUpdate = false;
|
||||
lblUpdatePachJson.Text = "[ 获取成功,点击查看更多信息 ]";
|
||||
lblUpdatePachJson.ForeColor = Color.RoyalBlue;
|
||||
|
||||
wechatModifier.Config = newBag.Apps["Wechat"];
|
||||
qqModifier.Config = newBag.Apps["QQ"];
|
||||
timModifier.Config = newBag.Apps["TIM"];
|
||||
qqLiteModifier.Config = newBag.Apps["QQLite"];
|
||||
|
||||
getPatchJsonStatus = "SUCCESS";
|
||||
InitControls();
|
||||
}
|
||||
getPatchJsonStatus = "SUCCESS";
|
||||
InitControls();
|
||||
else if (newBag.PatchVersion < bag.PatchVersion)
|
||||
{
|
||||
needUpdate = false;
|
||||
lblUpdatePachJson.Text = "[ 软件内置补丁信息已经是最新 ]";
|
||||
lblUpdatePachJson.ForeColor = Color.RoyalBlue;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
@ -13,5 +13,7 @@ namespace RevokeMsgPatcher.Model
|
|||
public string LatestVersion { get; set; }
|
||||
|
||||
public string Notice { get; set; }
|
||||
|
||||
public int PatchVersion { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -23,33 +23,37 @@ namespace RevokeMsgPatcher.Utils
|
|||
/// </summary>
|
||||
private static readonly string[] urls = new string[]
|
||||
{
|
||||
"https://gitee.com/huiyadanli/RevokeMsgPatcher/raw/master/RevokeMsgPatcher.Assistant/Data/1.2/patch.json",
|
||||
"https://huiyadanli.coding.net/p/RevokeMsgPatcher/d/RevokeMsgPatcher/git/raw/master/RevokeMsgPatcher.Assistant/Data/1.2/patch.json",
|
||||
"https://raw.githubusercontent.com/huiyadanli/RevokeMsgPatcher/master/RevokeMsgPatcher.Assistant/Data/1.2/patch.json"
|
||||
};
|
||||
|
||||
private static int i = 0;
|
||||
|
||||
public static async Task<string> GetPatchJsonAsync()
|
||||
{
|
||||
try
|
||||
int i = 0;
|
||||
while (i < urls.Length)
|
||||
{
|
||||
return await Client.GetStringAsync(urls[i]);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("第" + (i + 1) + "次请求异常:[" + ex.Message + "]\nURL:" + urls[i]);
|
||||
GAHelper.Instance.RequestPageView($"/main/json/request_ex/{i + 1}/{ex.Message}", "第" + (i + 1) + "次请求异常:[" + ex.Message + "]");
|
||||
try
|
||||
{
|
||||
string json = await Client.GetStringAsync(urls[i]);
|
||||
if (!string.IsNullOrEmpty(json) && json.Contains("LatestVersion"))
|
||||
{
|
||||
return json;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("第" + (i + 1) + "次请求获得的数据并非期望数据\nURL:" + urls[i]);
|
||||
GAHelper.Instance.RequestPageView($"/main/json/request_ex/{i + 1}/not_my_json", "第" + (i + 1) + "次请求获得的数据并非期望数据");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("第" + (i + 1) + "次请求异常:[" + ex.Message + "]\nURL:" + urls[i]);
|
||||
GAHelper.Instance.RequestPageView($"/main/json/request_ex/{i + 1}/{ex.Message}", "第" + (i + 1) + "次请求异常:[" + ex.Message + "]");
|
||||
}
|
||||
i++;
|
||||
if (i >= urls.Length)
|
||||
{
|
||||
i = 0;
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return await GetPatchJsonAsync();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user