mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
Add animation to hutao cloud gacha statistics view
This commit is contained in:
@@ -47,7 +47,7 @@ internal static class IocConfiguration
|
||||
if (context.Database.GetPendingMigrations().Any())
|
||||
{
|
||||
#if DEBUG
|
||||
Debug.WriteLine("[Database] Performing AppDbContext Migrations");
|
||||
System.Diagnostics.Debug.WriteLine("[Database] Performing AppDbContext Migrations");
|
||||
#endif
|
||||
context.Database.Migrate();
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2038,10 +2038,10 @@
|
||||
<value>原粹树脂已完全恢复</value>
|
||||
</data>
|
||||
<data name="ServiceHutaoUserGachaLogExpiredAt" xml:space="preserve">
|
||||
<value>祈愿记录上传服务将于 {0:yyyy-MM-dd HH:mm:ss} 到期</value>
|
||||
<value>祈愿记录上传服务有效期至\n{0:yyyy-MM-dd HH:mm:ss}</value>
|
||||
</data>
|
||||
<data name="ViewPageGachaLogHutaoCloudDeveloperHint" xml:space="preserve">
|
||||
<value>已注册为开发者,即使服务过期依旧能使用</value>
|
||||
<value>开发者账号无视服务到期时间</value>
|
||||
</data>
|
||||
<data name="ViewPageGahcaLogPivotStatistics" xml:space="preserve">
|
||||
<value>统计</value>
|
||||
|
||||
@@ -45,6 +45,7 @@ internal sealed class HutaoStatisticsFactory
|
||||
|
||||
private HutaoWishSummary CreateWishSummary(GachaEvent gachaEvent, List<ItemCount> items)
|
||||
{
|
||||
List<StatisticsItem> upItems = new();
|
||||
List<StatisticsItem> orangeItems = new();
|
||||
List<StatisticsItem> purpleItems = new();
|
||||
List<StatisticsItem> blueItems = new();
|
||||
@@ -59,19 +60,27 @@ internal sealed class HutaoStatisticsFactory
|
||||
};
|
||||
StatisticsItem statisticsItem = source.ToStatisticsItem(unchecked((int)item.Count));
|
||||
|
||||
List<StatisticsItem> list = statisticsItem.Quality switch
|
||||
if (gachaEvent.UpOrangeList.Contains(item.Item) || gachaEvent.UpPurpleList.Contains(item.Item))
|
||||
{
|
||||
QualityType.QUALITY_ORANGE => orangeItems,
|
||||
QualityType.QUALITY_PURPLE => purpleItems,
|
||||
QualityType.QUALITY_BLUE => blueItems,
|
||||
_ => throw Must.NeverHappen("意外的物品等级"),
|
||||
};
|
||||
list.Add(statisticsItem);
|
||||
upItems.Add(statisticsItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
List<StatisticsItem> list = statisticsItem.Quality switch
|
||||
{
|
||||
QualityType.QUALITY_ORANGE => orangeItems,
|
||||
QualityType.QUALITY_PURPLE => purpleItems,
|
||||
QualityType.QUALITY_BLUE => blueItems,
|
||||
_ => throw Must.NeverHappen("意外的物品等级"),
|
||||
};
|
||||
list.Add(statisticsItem);
|
||||
}
|
||||
}
|
||||
|
||||
return new()
|
||||
{
|
||||
Event = gachaEvent,
|
||||
UpItems = upItems.OrderByDescending(i => i.Quality).ThenByDescending(i => i.Count).ToList(),
|
||||
OrangeItems = orangeItems.OrderByDescending(i => i.Count).ToList(),
|
||||
PurpleItems = purpleItems.OrderByDescending(i => i.Count).ToList(),
|
||||
BlueItems = blueItems.OrderByDescending(i => i.Count).ToList(),
|
||||
|
||||
@@ -5,6 +5,7 @@ using Snap.Hutao.Core.IO;
|
||||
using Snap.Hutao.Service.Game;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Snap.Hutao.Service.GachaLog.QueryProvider;
|
||||
|
||||
@@ -50,7 +51,7 @@ internal sealed partial class GachaLogQueryWebCacheProvider : IGachaLogQueryProv
|
||||
{
|
||||
if (tempFile == null)
|
||||
{
|
||||
return new(false, string.Format(SH.ServiceGachaLogUrlProviderCachePathNotFound, cacheFile));
|
||||
return new(false, string.Format(Regex.Unescape(SH.ServiceGachaLogUrlProviderCachePathNotFound), cacheFile));
|
||||
}
|
||||
|
||||
using (FileStream fileStream = new(tempFile.Path, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Snap.Hutao.Web.Hutao.Model;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Snap.Hutao.Service.Hutao;
|
||||
|
||||
@@ -86,6 +87,6 @@ internal sealed class HutaoUserOptions : ObservableObject, IOptions<HutaoUserOpt
|
||||
{
|
||||
IsLicensedDeveloper = userInfo.IsLicensedDeveloper;
|
||||
IsCloudServiceAllowed = userInfo.GachaLogExpireAt > DateTimeOffset.Now;
|
||||
GachaLogExpireAt = string.Format(SH.ServiceHutaoUserGachaLogExpiredAt, userInfo.GachaLogExpireAt);
|
||||
GachaLogExpireAt = string.Format(Regex.Unescape(SH.ServiceHutaoUserGachaLogExpiredAt), userInfo.GachaLogExpireAt);
|
||||
}
|
||||
}
|
||||
@@ -35,70 +35,92 @@
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Border Margin="0,0,0,0" Style="{StaticResource BorderCardStyle}">
|
||||
<Grid>
|
||||
<shcp:AspectRatio TargetHeight="320" TargetWidth="690"/>
|
||||
<shci:CachedImage Source="{Binding Event.Banner}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
<ScrollViewer Grid.Row="1">
|
||||
<StackPanel Margin="0,0,0,16">
|
||||
<TextBlock
|
||||
Margin="0,16,0,8"
|
||||
Style="{StaticResource BaseTextBlockStyle}"
|
||||
Text="{shcm:ResourceString Name=ViewControlStatisticsCardOrangeText}"/>
|
||||
<ItemsControl ItemTemplate="{StaticResource GridTemplate}" ItemsSource="{Binding OrangeItems}">
|
||||
<ItemsControl.Transitions>
|
||||
<TransitionCollection>
|
||||
<ReorderThemeTransition/>
|
||||
</TransitionCollection>
|
||||
</ItemsControl.Transitions>
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<cwucont:WrapPanel/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
</ItemsControl>
|
||||
<Border Style="{StaticResource BorderCardStyle}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Border
|
||||
Margin="0,0,0,0"
|
||||
CornerRadius="{StaticResource CompatCornerRadiusTop}"
|
||||
Style="{StaticResource BorderCardStyle}">
|
||||
<Grid>
|
||||
<shcp:AspectRatio TargetHeight="320" TargetWidth="690"/>
|
||||
<shci:CachedImage Source="{Binding Event.Banner}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
<ScrollViewer Grid.Row="1">
|
||||
<StackPanel Margin="16,0,16,16">
|
||||
<TextBlock
|
||||
Margin="0,16,0,8"
|
||||
Style="{StaticResource BaseTextBlockStyle}"
|
||||
Text="{shcm:ResourceString Name=ViewControlStatisticsCardUpText}"/>
|
||||
<ItemsControl ItemTemplate="{StaticResource GridTemplate}" ItemsSource="{Binding UpItems}">
|
||||
<ItemsControl.Transitions>
|
||||
<TransitionCollection>
|
||||
<ReorderThemeTransition/>
|
||||
</TransitionCollection>
|
||||
</ItemsControl.Transitions>
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<cwucont:WrapPanel/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
</ItemsControl>
|
||||
|
||||
<TextBlock
|
||||
Margin="0,16,0,8"
|
||||
Style="{StaticResource BaseTextBlockStyle}"
|
||||
Text="{shcm:ResourceString Name=ViewControlStatisticsCardPurpleText}"/>
|
||||
<ItemsControl ItemTemplate="{StaticResource GridTemplate}" ItemsSource="{Binding PurpleItems}">
|
||||
<ItemsControl.Transitions>
|
||||
<TransitionCollection>
|
||||
<ReorderThemeTransition/>
|
||||
</TransitionCollection>
|
||||
</ItemsControl.Transitions>
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<cwucont:WrapPanel/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
</ItemsControl>
|
||||
<TextBlock
|
||||
Margin="0,16,0,8"
|
||||
Style="{StaticResource BaseTextBlockStyle}"
|
||||
Text="{shcm:ResourceString Name=ViewControlStatisticsCardOrangeText}"/>
|
||||
<ItemsControl ItemTemplate="{StaticResource GridTemplate}" ItemsSource="{Binding OrangeItems}">
|
||||
<ItemsControl.Transitions>
|
||||
<TransitionCollection>
|
||||
<ReorderThemeTransition/>
|
||||
</TransitionCollection>
|
||||
</ItemsControl.Transitions>
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<cwucont:WrapPanel/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
</ItemsControl>
|
||||
|
||||
<TextBlock
|
||||
Margin="0,16,0,8"
|
||||
Style="{StaticResource BaseTextBlockStyle}"
|
||||
Text="{shcm:ResourceString Name=ViewControlStatisticsCardBlueText}"/>
|
||||
<ItemsControl ItemTemplate="{StaticResource GridTemplate}" ItemsSource="{Binding BlueItems}">
|
||||
<ItemsControl.Transitions>
|
||||
<TransitionCollection>
|
||||
<ReorderThemeTransition/>
|
||||
</TransitionCollection>
|
||||
</ItemsControl.Transitions>
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<cwucont:WrapPanel/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
</ItemsControl>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
<TextBlock
|
||||
Margin="0,16,0,8"
|
||||
Style="{StaticResource BaseTextBlockStyle}"
|
||||
Text="{shcm:ResourceString Name=ViewControlStatisticsCardPurpleText}"/>
|
||||
<ItemsControl ItemTemplate="{StaticResource GridTemplate}" ItemsSource="{Binding PurpleItems}">
|
||||
<ItemsControl.Transitions>
|
||||
<TransitionCollection>
|
||||
<ReorderThemeTransition/>
|
||||
</TransitionCollection>
|
||||
</ItemsControl.Transitions>
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<cwucont:WrapPanel/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
</ItemsControl>
|
||||
|
||||
<TextBlock
|
||||
Margin="0,16,0,8"
|
||||
Style="{StaticResource BaseTextBlockStyle}"
|
||||
Text="{shcm:ResourceString Name=ViewControlStatisticsCardBlueText}"/>
|
||||
<ItemsControl ItemTemplate="{StaticResource GridTemplate}" ItemsSource="{Binding BlueItems}">
|
||||
<ItemsControl.Transitions>
|
||||
<TransitionCollection>
|
||||
<ReorderThemeTransition/>
|
||||
</TransitionCollection>
|
||||
</ItemsControl.Transitions>
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<cwucont:WrapPanel/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
</ItemsControl>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Border>
|
||||
</UserControl>
|
||||
|
||||
@@ -87,7 +87,10 @@
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<StackPanel Margin="0,0,0,12">
|
||||
<TextBlock HorizontalTextAlignment="Center" Text="{Binding HutaoCloudViewModel.Options.GachaLogExpireAt}"/>
|
||||
<TextBlock
|
||||
HorizontalTextAlignment="Center"
|
||||
Text="{Binding HutaoCloudViewModel.Options.GachaLogExpireAt}"
|
||||
TextAlignment="Center"/>
|
||||
<TextBlock
|
||||
Margin="0,6,0,0"
|
||||
HorizontalTextAlignment="Center"
|
||||
@@ -173,7 +176,10 @@
|
||||
IsClickEnabled="True"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<shvc:LoadingView Margin="8" IsLoading="{Binding HutaoCloudViewModel.IsInitialized, Converter={StaticResource BoolNegationConverter}}"/>
|
||||
<shvc:LoadingViewSlim
|
||||
MinWidth="240"
|
||||
Margin="-16"
|
||||
IsLoading="{Binding HutaoCloudViewModel.IsInitialized, Converter={StaticResource BoolNegationConverter}}"/>
|
||||
</Grid>
|
||||
</Flyout>
|
||||
</AppBarButton.Flyout>
|
||||
@@ -584,28 +590,25 @@
|
||||
</PivotItem>
|
||||
<PivotItem Header="{shcm:ResourceString Name=ViewPageGahcaLogPivotStatistics}">
|
||||
<Grid>
|
||||
<mxi:Interaction.Behaviors>
|
||||
<shcb:InvokeCommandOnLoadedBehavior Command="{Binding HutaoCloudStatisticsViewModel.OpenUICommand}"/>
|
||||
</mxi:Interaction.Behaviors>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="auto" MinWidth="16"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<shvc:HutaoStatisticsCard
|
||||
Grid.Column="0"
|
||||
Margin="16,16,0,16"
|
||||
DataContext="{Binding HutaoCloudStatisticsViewModel.Statistics.AvatarEvent}"/>
|
||||
<shvc:HutaoStatisticsCard
|
||||
Grid.Column="1"
|
||||
Margin="16,16,0,16"
|
||||
DataContext="{Binding HutaoCloudStatisticsViewModel.Statistics.AvatarEvent2}"/>
|
||||
<shvc:HutaoStatisticsCard
|
||||
Grid.Column="2"
|
||||
Margin="16,16,0,16"
|
||||
DataContext="{Binding HutaoCloudStatisticsViewModel.Statistics.WeaponWish}"/>
|
||||
<shvc:LoadingView IsLoading="{Binding HutaoCloudStatisticsViewModel.IsInitialized, Converter={StaticResource BoolNegationConverter}}"/>
|
||||
<Grid
|
||||
Margin="16"
|
||||
ColumnSpacing="16"
|
||||
Visibility="{Binding HutaoCloudStatisticsViewModel.IsInitialized, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||
<mxi:Interaction.Behaviors>
|
||||
<shcb:InvokeCommandOnLoadedBehavior Command="{Binding HutaoCloudStatisticsViewModel.OpenUICommand}"/>
|
||||
</mxi:Interaction.Behaviors>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<shvc:HutaoStatisticsCard Grid.Column="0" DataContext="{Binding HutaoCloudStatisticsViewModel.Statistics.AvatarEvent}"/>
|
||||
<shvc:HutaoStatisticsCard Grid.Column="1" DataContext="{Binding HutaoCloudStatisticsViewModel.Statistics.AvatarEvent2}"/>
|
||||
<shvc:HutaoStatisticsCard Grid.Column="2" DataContext="{Binding HutaoCloudStatisticsViewModel.Statistics.WeaponWish}"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
</PivotItem>
|
||||
</Pivot>
|
||||
</Grid>
|
||||
|
||||
@@ -30,12 +30,15 @@ internal sealed class HutaoCloudStatisticsViewModel : Abstraction.ViewModelSlim
|
||||
|
||||
protected override async Task OpenUIAsync()
|
||||
{
|
||||
ITaskContext taskContext = ServiceProvider.GetRequiredService<ITaskContext>();
|
||||
await taskContext.SwitchToBackgroundAsync();
|
||||
IHutaoCloudService hutaoCloudService = ServiceProvider.GetRequiredService<IHutaoCloudService>();
|
||||
(bool isOk, HutaoStatistics statistics) = await hutaoCloudService.GetCurrentEventStatisticsAsync().ConfigureAwait(false);
|
||||
if (isOk)
|
||||
{
|
||||
await ServiceProvider.GetRequiredService<ITaskContext>().SwitchToMainThreadAsync();
|
||||
await taskContext.SwitchToMainThreadAsync();
|
||||
Statistics = statistics;
|
||||
IsInitialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,11 @@ internal sealed class HutaoWishSummary
|
||||
/// </summary>
|
||||
public GachaEvent Event { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Up 物品
|
||||
/// </summary>
|
||||
public List<StatisticsItem> UpItems { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 五星物品
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user