From 1ffbae61357f471a310dd5592620ce004435d805 Mon Sep 17 00:00:00 2001 From: ChsBuffer <33744752+chsbuffer@users.noreply.github.com> Date: Mon, 22 Mar 2021 11:09:16 +0800 Subject: [PATCH] Feat: Show Release Note when confirm --- Netch/Controllers/UpdateChecker.cs | 15 +++++++++++++++ Netch/Forms/MainForm.cs | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Netch/Controllers/UpdateChecker.cs b/Netch/Controllers/UpdateChecker.cs index 871a8208..00998083 100644 --- a/Netch/Controllers/UpdateChecker.cs +++ b/Netch/Controllers/UpdateChecker.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Net; +using System.Text; using System.Text.Json; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -89,5 +90,19 @@ namespace Netch.Controllers fileName = match.Groups["filename"].Value; sha256 = match.Groups["sha256"].Value; } + + public static string GetLatestReleaseContent() + { + var sb = new StringBuilder(); + foreach (string l in LatestRelease.body.GetLines(false).SkipWhile(l => l.FirstOrDefault() != '#')) + { + if (l.Contains("校验和")) + break; + + sb.AppendLine(l); + } + + return sb.ToString(); + } } } \ No newline at end of file diff --git a/Netch/Forms/MainForm.cs b/Netch/Forms/MainForm.cs index 767305bb..64801a4d 100644 --- a/Netch/Forms/MainForm.cs +++ b/Netch/Forms/MainForm.cs @@ -579,7 +579,8 @@ namespace Netch.Forms return; } - if (MessageBoxX.Show(i18N.Translate("Download and install now?"), confirm: true) != DialogResult.OK) + if (MessageBoxX.Show(i18N.Translate($"Download and install now?\n\n{UpdateChecker.GetLatestReleaseContent()}"), confirm: true) != + DialogResult.OK) return; NotifyTip(i18N.Translate("Start downloading new version"));