feat: 优化 changelog 弹窗 (#3882)

This commit is contained in:
MistEO
2023-03-05 23:51:24 +08:00
committed by GitHub
3 changed files with 49 additions and 40 deletions

View File

@@ -85,6 +85,7 @@ namespace MaaWpfGui
{
if (_versionUpdateViewModel.IsFirstBootAfterUpdate)
{
_versionUpdateViewModel.IsFirstBootAfterUpdate = false;
_windowManager.ShowWindow(_versionUpdateViewModel);
}
else
@@ -93,6 +94,7 @@ namespace MaaWpfGui
if (ret == VersionUpdateViewModel.CheckUpdateRetT.OK)
{
_versionUpdateViewModel.IsFirstBootAfterUpdate = true;
_versionUpdateViewModel.AskToRestart();
}
}

View File

@@ -22,7 +22,10 @@ using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Documents;
using MaaWpfGui.Helper;
using Markdig;
using Neo.Markdig.Xaml;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Stylet;
@@ -108,6 +111,9 @@ namespace MaaWpfGui
}
}
public FlowDocument UpdateInfoDoc => MarkdownXaml.ToFlowDocument(UpdateInfo,
new MarkdownPipelineBuilder().UseXamlSupportedExtensions().Build());
private string _updateUrl;
/// <summary>
@@ -119,10 +125,20 @@ namespace MaaWpfGui
set => SetAndNotify(ref _updateUrl, value);
}
private bool _isFirstBootAfterUpdate = Convert.ToBoolean(ViewStatusStorage.Get("VersionUpdate.isfirstboot", bool.FalseString));
/// <summary>
/// Gets a value indicating whether it is the first boot after updating.
/// Gets or sets a value indicating whether it is the first boot after updating.
/// </summary>
public bool IsFirstBootAfterUpdate => UpdateTag != string.Empty && UpdateTag == _curVersion;
public bool IsFirstBootAfterUpdate
{
get => _isFirstBootAfterUpdate;
set
{
SetAndNotify(ref _isFirstBootAfterUpdate, value);
ViewStatusStorage.Set("VersionUpdate.isfirstboot", value.ToString());
}
}
private string _updatePackageName = ViewStatusStorage.Get("VersionUpdate.package", string.Empty);
@@ -954,16 +970,6 @@ namespace MaaWpfGui
}
}
/// <summary>
/// Closes view model.
/// </summary>
public void Close()
{
RequestClose();
/* UpdateTag = string.Empty; */
/* UpdateInfo = string.Empty; */
}
/// <summary>
/// The event handler of opening hyperlink.
/// </summary>

View File

@@ -5,7 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:maa="clr-namespace:MaaWpfGui.Helper.CustomStyle"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mdxam="clr-namespace:MdXaml;assembly=MdXaml"
xmlns:mdg="clr-namespace:Neo.Markdig.Xaml;assembly=Neo.Markdig.Xaml"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:vm="clr-namespace:MaaWpfGui"
Title="{DynamicResource VersionUpdated}"
@@ -15,9 +15,9 @@
mc:Ignorable="d">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="80" />
<RowDefinition Height="50" />
<RowDefinition Height="*" />
<RowDefinition Height="120" />
<RowDefinition Height="20" />
</Grid.RowDefinitions>
<StackPanel
@@ -25,42 +25,43 @@
HorizontalAlignment="Center"
Orientation="Horizontal">
<maa:TextBlock
Margin="0,20"
FontSize="24"
Margin="0,10,0,5"
FontSize="20"
Style="{StaticResource TextBlockDefaultBold}"
Text="{DynamicResource VersionUpdatedTo}"
TextWrapping="Wrap" />
TextWrapping="Wrap" VerticalAlignment="Bottom" />
<maa:TextBlock
Margin="0,20"
FontSize="24"
Margin="0,10,0,5"
FontSize="20"
Style="{StaticResource TextBlockDefaultBold}"
Text="{Binding UpdateTag}"
TextWrapping="Wrap" />
TextWrapping="Wrap" VerticalAlignment="Bottom" />
</StackPanel>
<mdxam:MarkdownScrollViewer
<FlowDocumentScrollViewer
x:Name="UpdateInfoMarkdownDocument"
Document="{Binding UpdateInfoDoc}"
Grid.Row="1"
Margin="16,0"
ClickAction="DisplayWithRelativePath"
Language="zh-CN"
Markdown="{Binding UpdateInfo}"
MarkdownStyleName="GithubLike" />
Zoom="90"
IsSelectionEnabled="False">
<FlowDocumentScrollViewer.Template>
<ControlTemplate TargetType="FlowDocumentScrollViewer">
<Border
BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="{TemplateBinding BorderBrush}"
Focusable="False">
<ScrollViewer x:Name="PART_ContentHost" />
</Border>
</ControlTemplate>
</FlowDocumentScrollViewer.Template>
<StackPanel
Grid.Row="2"
HorizontalAlignment="Center"
Orientation="Horizontal">
<!--<Button Command="{s:Action Download}" Content="前往下载" Margin="20" Width="120" Height="60" />-->
<!--<Button Command="{s:Action Ignore}" Content="不再提示" Margin="20" Width="120" Height="60" />-->
<Button
Width="120"
Height="60"
Margin="20"
Command="{s:Action Close}"
Content="{DynamicResource UpdateNotificationOK}" />
</StackPanel>
<FlowDocumentScrollViewer.CommandBindings>
<CommandBinding
Command="{x:Static mdg:MarkdownXaml.Hyperlink}"
Executed="{s:Action OpenHyperlink}" />
</FlowDocumentScrollViewer.CommandBindings>
</FlowDocumentScrollViewer>
</Grid>
</Window>