feat: 优化标题栏显示效果

This commit is contained in:
uye
2025-08-14 14:21:55 +08:00
parent 427b6e59f2
commit f31aecd5f0
4 changed files with 88 additions and 62 deletions

View File

@@ -201,22 +201,22 @@ namespace MaaWpfGui.Models
return (CheckUpdateRetT.UnknownError, null, null);
}
if (!DateTime.TryParse(data["data"]?["version_name"]?.ToString(), out var version))
if (!DateTime.TryParse(data["data"]?["version_name"]?.ToString(), out var versionTime))
{
ToastNotification.ShowDirect(LocalizationHelper.GetString("GameResourceFailed"));
return (CheckUpdateRetT.UnknownError, null, null);
}
if (DateTime.Compare(currentVersionDateTime, version) >= 0)
if (DateTime.Compare(currentVersionDateTime, versionTime) >= 0)
{
return (CheckUpdateRetT.AlreadyLatest, null, null);
}
// 到这里已经确定有新版本了
var releaseNote = data["data"]?["release_note"]?.ToString();
_logger.Information("New version found: {DateTime:yyyy-MM-dd+HH:mm:ss.fff}, {ReleaseNote}", version, releaseNote);
_logger.Information("New version found: {DateTime:yyyy-MM-dd+HH:mm:ss.fff}, {ReleaseNote}", versionTime, releaseNote);
releaseNote = LocalizationHelper.FormatVersion(releaseNote, version);
releaseNote = LocalizationHelper.FormatVersion(releaseNote, versionTime);
SettingsViewModel.VersionUpdateSettings.NewResourceFoundInfo = string.Format(LocalizationHelper.GetString("MirrorChyanResourceUpdateShortTip"), releaseNote);

View File

@@ -111,15 +111,26 @@ namespace MaaWpfGui.ViewModels.UI
set => SetAndNotify(ref _windowTitle, value);
}
private string _windowUpdateInfo = string.Empty;
private string _windowVersionUpdateInfo = string.Empty;
/// <summary>
/// Gets or sets the window title.
/// Gets or sets the version update info.
/// </summary>
public string WindowUpdateInfo
public string WindowVersionUpdateInfo
{
get => _windowUpdateInfo;
set => SetAndNotify(ref _windowUpdateInfo, value);
get => _windowVersionUpdateInfo;
set => SetAndNotify(ref _windowVersionUpdateInfo, value);
}
private string _windowResourceUpdateInfo = string.Empty;
/// <summary>
/// Gets or sets the resource update info.
/// </summary>
public string WindowResourceUpdateInfo
{
get => _windowResourceUpdateInfo;
set => SetAndNotify(ref _windowResourceUpdateInfo, value);
}
private (int Current, int Max)? _taskProgress;

View File

@@ -719,21 +719,17 @@ namespace MaaWpfGui.ViewModels.UI
{
var rvm = (RootViewModel)this.Parent;
string updateTip = string.Empty;
var newVersionFoundInfo = VersionUpdateSettings.NewVersionFoundInfo;
var uiVersion = VersionUpdateSettingsUserControlModel.UiVersion;
var startupUpdateCheck = VersionUpdateSettings.StartupUpdateCheck;
var isDebug = Instances.VersionUpdateViewModel.IsDebugVersion();
if (newVersionFoundInfo != uiVersion && !isDebug && !string.IsNullOrEmpty(newVersionFoundInfo) && startupUpdateCheck)
{
updateTip = $"{newVersionFoundInfo}";
rvm.WindowVersionUpdateInfo = $"{newVersionFoundInfo}".Trim();
}
var newResourceFoundInfo = VersionUpdateSettings.NewResourceFoundInfo;
if (!string.IsNullOrEmpty(newResourceFoundInfo))
{
updateTip += $" {newResourceFoundInfo}";
}
rvm.WindowResourceUpdateInfo = VersionUpdateSettings.NewResourceFoundInfo;
string prefix = ConfigurationHelper.GetValue(ConfigurationKeys.WindowTitlePrefix, string.Empty);
if (!string.IsNullOrEmpty(prefix))
@@ -780,7 +776,6 @@ namespace MaaWpfGui.ViewModels.UI
? $" - {LocalizationHelper.FormatVersion(VersionUpdateSettings.ResourceVersion, VersionUpdateSettings.ResourceDateTime)}"
: string.Empty;
string uiVersionDisplay = LocalizationHelper.FormatVersion(uiVersion, VersionUpdateSettingsUserControlModel.BuildDateTime);
rvm.WindowUpdateInfo = updateTip.Trim();
rvm.WindowTitle = $"{prefix}MAA{currentConfiguration} - {uiVersionDisplay}{resourceVersionDisplay}{connectConfigName}{connectAddress}{clientName}";
}

View File

@@ -33,55 +33,71 @@
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<controls:TextBlock
<Grid.Resources>
<Storyboard x:Key="SmoothColorCycle" RepeatBehavior="Forever">
<ColorAnimation
Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"
From="#FF4285F4"
To="#FFEA4335"
Duration="0:0:1" />
<ColorAnimation
BeginTime="0:0:1"
Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"
From="#FFEA4335"
To="#FFFBBC05"
Duration="0:0:1" />
<ColorAnimation
BeginTime="0:0:2"
Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"
From="#FFFBBC05"
To="#FF34A853"
Duration="0:0:1" />
<ColorAnimation
BeginTime="0:0:3"
Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"
From="#FF34A853"
To="#FF4285F4"
Duration="0:0:1" />
</Storyboard>
<Style x:Key="RainbowTextBlockStyle" TargetType="TextBlock">
<Setter Property="Foreground" Value="Red" />
<Setter Property="IsHitTestVisible" Value="False" />
<Style.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard Storyboard="{StaticResource SmoothColorCycle}" />
</EventTrigger>
</Style.Triggers>
</Style>
</Grid.Resources>
<Grid
Grid.Column="0"
Margin="10,0,-5,0"
HorizontalAlignment="Left"
IsHitTestVisible="False"
Text="{Binding WindowUpdateInfo}">
<controls:TextBlock.Foreground>
<SolidColorBrush Color="Red" />
</controls:TextBlock.Foreground>
<controls:TextBlock.Resources>
<Storyboard x:Key="SmoothColorCycle" RepeatBehavior="Forever">
<ColorAnimation
AutoReverse="False"
Storyboard.TargetProperty="Foreground.Color"
From="#FF4285F4"
To="#FFEA4335"
Duration="0:0:1" />
<ColorAnimation
AutoReverse="False"
BeginTime="0:0:1"
Storyboard.TargetProperty="Foreground.Color"
From="#FFEA4335"
To="#FFFBBC05"
Duration="0:0:1" />
<ColorAnimation
AutoReverse="False"
BeginTime="0:0:2"
Storyboard.TargetProperty="Foreground.Color"
From="#FFFBBC05"
To="#FF34A853"
Duration="0:0:1" />
<ColorAnimation
AutoReverse="False"
BeginTime="0:0:3"
Storyboard.TargetProperty="Foreground.Color"
From="#FF34A853"
To="#FF4285F4"
Duration="0:0:1" />
</Storyboard>
</controls:TextBlock.Resources>
<controls:TextBlock.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard Storyboard="{StaticResource SmoothColorCycle}" />
</EventTrigger>
</controls:TextBlock.Triggers>
</controls:TextBlock>
VerticalAlignment="Center">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<controls:TextBlock
Grid.Row="0"
Margin="10,0,-5,0"
HorizontalAlignment="Left"
Style="{StaticResource RainbowTextBlockStyle}"
Text="{Binding WindowVersionUpdateInfo}"
Visibility="{c:Binding 'WindowVersionUpdateInfo.Length > 0'}" />
<controls:TextBlock
Grid.Row="1"
Margin="10,0,-5,0"
HorizontalAlignment="Left"
Style="{StaticResource RainbowTextBlockStyle}"
Text="{Binding WindowResourceUpdateInfo}"
Visibility="{c:Binding 'WindowResourceUpdateInfo.Length > 0'}" />
</Grid>
<hc:RunningBlock
Grid.Column="1"
Margin="10,0"
Margin="10,-2.5"
HorizontalAlignment="Left"
BorderThickness="0"
Content="{Binding WindowTitle}"
@@ -95,12 +111,14 @@
HorizontalAlignment="Left"
IsHitTestVisible="False"
Text="{Binding WindowTitle}"
TextWrapping="Wrap"
Visibility="{c:Binding !WindowTitleScrollable}" />
</Grid>
<Button
Grid.Column="1"
Width="46"
Height="29"
VerticalAlignment="Top"
hc:BorderElement.CornerRadius="0"
BorderThickness="0"
Command="{s:Action ToggleTopMostCommand}"
@@ -168,6 +186,8 @@
Padding="0,-2,0,0"
HorizontalAlignment="Right"
VerticalAlignment="Top"
d:Height="200"
d:Width="100"
VerticalScrollBarVisibility="Hidden">
<StackPanel Margin="0,0,0,5" hc:Growl.GrowlParent="True" />
</ScrollViewer>