diff --git a/src/App.xaml.cs b/src/App.xaml.cs index 267d5e98..1528ae9b 100644 --- a/src/App.xaml.cs +++ b/src/App.xaml.cs @@ -73,12 +73,6 @@ namespace SourceGit { // 主界面显示 MainWindow = launcher; MainWindow.Show(); - - // 检测版本更新 - Models.Version.Check(ver => Dispatcher.Invoke(() => { - var dialog = new Views.Upgrade(ver) { Owner = MainWindow }; - dialog.ShowDialog(); - })); } /// diff --git a/src/Models/Preference.cs b/src/Models/Preference.cs index 7e4141b6..4907796c 100644 --- a/src/Models/Preference.cs +++ b/src/Models/Preference.cs @@ -63,16 +63,6 @@ namespace SourceGit.Models { /// public bool UseDarkTheme { get; set; } = true; - /// - /// 启用更新检测 - /// - public bool CheckForUpdate { get; set; } = true; - - /// - /// 上一次检测的时间(用于控制每天仅第一次启动软件时,检测) - /// - public int LastCheckDay { get; set; } = 0; - /// /// 起始页仓库列表排序规则 /// diff --git a/src/Models/Version.cs b/src/Models/Version.cs deleted file mode 100644 index a6cf963a..00000000 --- a/src/Models/Version.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System; -using System.Reflection; -using System.Text.Json; -using System.Text.Json.Serialization; -using System.Text.RegularExpressions; -using System.Threading.Tasks; -using System.Net.Http; - -namespace SourceGit.Models { - - /// - /// Github开放API中Release信息格式 - /// - public class Version { - [JsonPropertyName("id")] - public ulong Id { get; set; } - [JsonPropertyName("tag_name")] - public string TagName { get; set; } - [JsonPropertyName("target_commitish")] - public string CommitSHA { get; set; } - [JsonPropertyName("prerelease")] - public bool PreRelease { get; set; } - [JsonPropertyName("name")] - public string Name { get; set; } - [JsonPropertyName("body")] - public string Body { get; set; } - [JsonPropertyName("created_at")] - public DateTime CreatedAt { get; set; } - - public string PublishTime { - get { return CreatedAt.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"); } - } - - public string IsPrerelease { - get { return PreRelease ? "YES" : "NO"; } - } - - public static void Check(Action onUpgradable) { - if (!Preference.Instance.General.CheckForUpdate) return; - - var curDayOfYear = DateTime.Now.DayOfYear; - var lastDayOfYear = Preference.Instance.General.LastCheckDay; - if (lastDayOfYear != curDayOfYear) { - Preference.Instance.General.LastCheckDay = curDayOfYear; - Task.Run(async () => { - try { - var req = new HttpClient(); - var rsp = await req.GetAsync("https://api.github.com/repos/sourcegit-scm/sourcegit/releases/latest"); - rsp.EnsureSuccessStatusCode(); - - var raw = await rsp.Content.ReadAsStringAsync(); - var ver = JsonSerializer.Deserialize(raw); - var cur = Assembly.GetExecutingAssembly().GetName().Version; - - var matches = Regex.Match(ver.TagName, @"^v(\d+)\.(\d+).*"); - if (!matches.Success) return; - - var major = int.Parse(matches.Groups[1].Value); - var minor = int.Parse(matches.Groups[2].Value); - if (major > cur.Major || (major == cur.Major && minor > cur.Minor)) { - onUpgradable?.Invoke(ver); - } - } catch { - } - }); - } - } - } -} diff --git a/src/Resources/Locales/en_US.xaml b/src/Resources/Locales/en_US.xaml index e880d98a..16d81cf0 100644 --- a/src/Resources/Locales/en_US.xaml +++ b/src/Resources/Locales/en_US.xaml @@ -396,13 +396,6 @@ COMMIT : {0} -> {1} - UPDATE AVAILABLE - {0} is available! - Publish Time - Base On Commit - Is Pre-release - DOWNLOAD - Changes UNSTAGED STAGE diff --git a/src/Resources/Locales/zh_CN.xaml b/src/Resources/Locales/zh_CN.xaml index 41e34d21..fe03f456 100644 --- a/src/Resources/Locales/zh_CN.xaml +++ b/src/Resources/Locales/zh_CN.xaml @@ -395,13 +395,6 @@ 对比提交 : {0} -> {1} - 检测更新 - {0}已发布! - 发布时间 - GIT版本 - 预览版 - 下 载 - 本地更改 未暂存 暂存选中 diff --git a/src/Views/Upgrade.xaml b/src/Views/Upgrade.xaml deleted file mode 100644 index 8626fae1..00000000 --- a/src/Views/Upgrade.xaml +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -