From 79b26af92cb361159eb937b7b82e8fcdfa4e994f Mon Sep 17 00:00:00 2001
From: zzyyyl <74587068+zzyyyl@users.noreply.github.com>
Date: Sat, 30 Jul 2022 02:31:14 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E6=9B=B4=E6=96=B0?=
=?UTF-8?q?=E6=97=B6=E7=9A=84=20Changelog=20=E5=BC=B9=E7=AA=97=E6=A0=B7?=
=?UTF-8?q?=E5=BC=8F=20(#1373)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* feat: 优化贡献者名字显示
但是好丑
* feat: 换了个玛丽说好看的 Markdown
---
.../ViewModels/VersionUpdateViewModel.cs | 70 +++++++++++--------
src/MeoAsstGui/Views/VersionUpdateView.xaml | 22 +++---
2 files changed, 50 insertions(+), 42 deletions(-)
diff --git a/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs b/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs
index d73055d4d9..e9983610f5 100644
--- a/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs
+++ b/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs
@@ -20,10 +20,6 @@ using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows;
-using System.Windows.Documents;
-using Markdig;
-using MdXaml;
-using Neo.Markdig.Xaml;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Stylet;
@@ -45,6 +41,15 @@ namespace MeoAsstGui
[DllImport("MeoAssistant.dll")]
private static extern IntPtr AsstGetVersion();
+ private static string AddContributorLink(string text)
+ {
+ // "@ " -> "@ "
+ // "`@`" -> "`@`"
+ // "@MistEO" -> "[@MistEO](https://github.com/MistEO)"
+ // "[@MistEO]" -> "[@MistEO]"
+ return Regex.Replace(text, @"([^\[`]|^)@([^\s]+)", "$1[@$2](https://github.com/$2)");
+ }
+
private readonly string _curVersion = Marshal.PtrToStringAnsi(AsstGetVersion());
private string _latestVersion;
@@ -66,13 +71,20 @@ namespace MeoAsstGui
private string _updateInfo = ViewStatusStorage.Get("VersionUpdate.body", string.Empty);
- private static readonly MarkdownPipeline s_markdownPipeline = new MarkdownPipelineBuilder().UseXamlSupportedExtensions().Build();
+ // private static readonly MarkdownPipeline s_markdownPipeline = new MarkdownPipelineBuilder().UseXamlSupportedExtensions().Build();
public string UpdateInfo
{
get
{
- return _updateInfo;
+ try
+ {
+ return AddContributorLink(_updateInfo);
+ }
+ catch
+ {
+ return _updateInfo;
+ }
}
set
@@ -97,29 +109,29 @@ namespace MeoAsstGui
}
}
- public FlowDocument UpdateInfoDocument
- {
- get
- {
- try
- {
- return MarkdownXaml.ToFlowDocument(UpdateInfo, s_markdownPipeline);
- }
- catch (Exception)
- {
- // 不知道为什么有一部分用户的电脑上,用 MarkdownXaml 解析直接就会 crash
- // 换另一个库再试一遍
- try
- {
- return new MdXaml.Markdown().Transform(UpdateInfo);
- }
- catch (Exception)
- {
- return new FlowDocument();
- }
- }
- }
- }
+ // public FlowDocument UpdateInfoDocument
+ // {
+ // get
+ // {
+ // try
+ // {
+ // return MarkdownXaml.ToFlowDocument(UpdateInfo, s_markdownPipeline);
+ // }
+ // catch (Exception)
+ // {
+ // // 不知道为什么有一部分用户的电脑上,用 MarkdownXaml 解析直接就会 crash
+ // // 换另一个库再试一遍
+ // try
+ // {
+ // return new MdXaml.Markdown().Transform(UpdateInfo);
+ // }
+ // catch (Exception)
+ // {
+ // return new FlowDocument();
+ // }
+ // }
+ // }
+ // }
public bool IsFirstBootAfterUpdate
{
diff --git a/src/MeoAsstGui/Views/VersionUpdateView.xaml b/src/MeoAsstGui/Views/VersionUpdateView.xaml
index 339c51a1ea..1780664708 100644
--- a/src/MeoAsstGui/Views/VersionUpdateView.xaml
+++ b/src/MeoAsstGui/Views/VersionUpdateView.xaml
@@ -4,8 +4,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:md="clr-namespace:Neo.Markdig.Xaml;assembly=Neo.Markdig.Xaml"
xmlns:s="https://github.com/canton7/Stylet"
+ xmlns:mdxam="clr-namespace:MdXaml;assembly=MdXaml"
xmlns:vm="clr-namespace:MeoAsstGui;assembly=MeoAsstGui"
Title="版本已更新"
Width="600"
@@ -37,20 +37,16 @@
TextWrapping="Wrap" />
-
-
-
-
-
+ ClickAction="DisplayWithRelativePath"
+ Markdown="{Binding UpdateInfo}"
+ MarkdownStyleName="GithubLike">
+
+