refactor<Version>: check latest release from api.github.com instead

This commit is contained in:
leo 2021-11-15 14:23:45 +08:00
parent dcf53c31cc
commit 18f176a66b

View file

@ -52,13 +52,13 @@ namespace SourceGit.Models {
try {
#if NET6_0_OR_GREATER
var req = new HttpClient();
var rsp = await req.GetAsync("https://gitee.com/api/v5/repos/sourcegit/sourcegit/releases/latest");
var rsp = await req.GetAsync("https://api.github.com/repos/sourcegit-scm/sourcegit/releases/latest");
rsp.EnsureSuccessStatusCode();
var raw = await rsp.Content.ReadAsStringAsync();
#else
var web = new WebClient() { Encoding = Encoding.UTF8 };
var raw = await web.DownloadStringTaskAsync("https://gitee.com/api/v5/repos/sourcegit/sourcegit/releases/latest");
var raw = await web.DownloadStringTaskAsync("https://api.github.com/repos/sourcegit-scm/sourcegit/releases/latest");
#endif
var ver = JsonSerializer.Deserialize<Version>(raw);
var cur = Assembly.GetExecutingAssembly().GetName().Version;