mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-15 17:30:27 +08:00
feat: 优化更新时的 Changelog 弹窗样式 (#1373)
* feat: 优化贡献者名字显示 但是好丑 * feat: 换了个玛丽说好看的 Markdown
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
@@ -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" />
|
||||
</StackPanel>
|
||||
|
||||
<FlowDocumentScrollViewer
|
||||
x:Name="flowDocumentScrollViewer"
|
||||
|
||||
<mdxam:MarkdownScrollViewer
|
||||
x:Name="UpdateInfoMarkdownDocument"
|
||||
Grid.Row="1"
|
||||
Margin="16,0"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Top"
|
||||
Document="{Binding UpdateInfoDocument}"
|
||||
MaxZoom="100"
|
||||
MinZoom="100"
|
||||
VerticalScrollBarVisibility="Auto">
|
||||
<FlowDocumentScrollViewer.CommandBindings>
|
||||
<CommandBinding Command="{x:Static md:MarkdownXaml.Hyperlink}" Executed="{s:Action OpenHyperlink}" />
|
||||
</FlowDocumentScrollViewer.CommandBindings>
|
||||
</FlowDocumentScrollViewer>
|
||||
ClickAction="DisplayWithRelativePath"
|
||||
Markdown="{Binding UpdateInfo}"
|
||||
MarkdownStyleName="GithubLike">
|
||||
</mdxam:MarkdownScrollViewer>
|
||||
|
||||
|
||||
<StackPanel
|
||||
Grid.Row="2"
|
||||
|
||||
Reference in New Issue
Block a user