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"> + +