mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-18 02:10:21 +08:00
feat.更新日志显示支持 Markdown 渲染
This commit is contained in:
@@ -258,6 +258,9 @@
|
||||
<PackageReference Include="Microsoft.Win32.Primitives">
|
||||
<Version>4.3.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Neo.Markdig.Xaml">
|
||||
<Version>1.0.10</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="NETStandard.Library">
|
||||
<Version>2.0.3</Version>
|
||||
</PackageReference>
|
||||
|
||||
@@ -18,6 +18,9 @@ using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows;
|
||||
using System.Windows.Documents;
|
||||
using Markdig;
|
||||
using Neo.Markdig.Xaml;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Stylet;
|
||||
@@ -58,6 +61,8 @@ namespace MeoAsstGui
|
||||
|
||||
private string _updateInfo = ViewStatusStorage.Get("VersionUpdate.body", string.Empty);
|
||||
|
||||
private static readonly MarkdownPipeline s_markdownPipeline = new MarkdownPipelineBuilder().UseXamlSupportedExtensions().Build();
|
||||
|
||||
public string UpdateInfo
|
||||
{
|
||||
get
|
||||
@@ -71,6 +76,14 @@ namespace MeoAsstGui
|
||||
}
|
||||
}
|
||||
|
||||
public FlowDocument UpdateInfoDocument
|
||||
{
|
||||
get
|
||||
{
|
||||
return MarkdownXaml.ToFlowDocument(UpdateInfo, s_markdownPipeline);
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isFirstBootAfterUpdate = Convert.ToBoolean(ViewStatusStorage.Get("VersionUpdate.firstboot", Boolean.FalseString));
|
||||
|
||||
public bool IsFirstBootAfterUpdate
|
||||
@@ -735,5 +748,10 @@ namespace MeoAsstGui
|
||||
UpdateTag = string.Empty;
|
||||
UpdateInfo = string.Empty;
|
||||
}
|
||||
|
||||
public void OpenHyperlink(object sender, System.Windows.Input.ExecutedRoutedEventArgs e)
|
||||
{
|
||||
Process.Start(e.Parameter.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:md="clr-namespace:Neo.Markdig.Xaml;assembly=Neo.Markdig.Xaml"
|
||||
mc:Ignorable="d"
|
||||
Title="版本已更新" Height="500" Width="600">
|
||||
<Grid>
|
||||
@@ -17,9 +18,20 @@
|
||||
<TextBlock Style="{StaticResource TextBlockDefaultBold}" Text="已更新:" TextWrapping="Wrap" FontSize="24" Margin="0, 20" />
|
||||
<TextBlock Style="{StaticResource TextBlockDefaultBold}" Text="{Binding UpdateTag}" TextWrapping="Wrap" FontSize="24" Margin="0, 20" />
|
||||
</StackPanel>
|
||||
<ScrollViewer HorizontalAlignment="Center" VerticalAlignment="Top" Grid.Row="1">
|
||||
<TextBlock Style="{StaticResource TextBlockDefault}" Text="{Binding UpdateInfo}" TextWrapping="Wrap" FontSize="16" Margin="0, 20" />
|
||||
</ScrollViewer>
|
||||
|
||||
<FlowDocumentScrollViewer x:Name="flowDocumentScrollViewer"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Top"
|
||||
Grid.Row="1"
|
||||
Document="{Binding UpdateInfoDocument}"
|
||||
Margin="16, 0"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
MaxZoom="200"
|
||||
MinZoom="60" >
|
||||
<FlowDocumentScrollViewer.CommandBindings>
|
||||
<CommandBinding Command="{x:Static md:MarkdownXaml.Hyperlink}" Executed="{s:Action OpenHyperlink}" />
|
||||
</FlowDocumentScrollViewer.CommandBindings>
|
||||
</FlowDocumentScrollViewer>
|
||||
|
||||
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal" Grid.Row="2">
|
||||
<!--<Button Command="{s:Action Download}" Content="前往下载" Margin="20" Width="120" Height="60" />-->
|
||||
|
||||
Reference in New Issue
Block a user