1
0
mirror of synced 2024-11-23 22:41:01 +01:00

Cache more on song data

Remove unnecessary using
This commit is contained in:
asesidaa 2022-09-12 17:29:29 +08:00
parent 9ab12ba0cb
commit 7e43b44e24
10 changed files with 25 additions and 22 deletions

View File

@ -5,6 +5,12 @@ namespace SharedProject.Models;
public class SongBestData
{
public uint SongId { get; set; }
public SongGenre Genre { get; set; }
public string MusicName { get; set; } = string.Empty;
public string MusicArtist { get; set; } = string.Empty;
public Difficulty Difficulty { get; set; }

View File

@ -37,8 +37,8 @@
<MudGrid Justify="Justify.Center">
<MudItem xs="10">
<MudStack Spacing="0">
<MudText Typo="Typo.body2" Style="font-weight:bold">@GameDataService.GetMusicNameBySongId(context.Item.SongId)</MudText>
<MudText Typo="Typo.caption">@GameDataService.GetMusicArtistBySongId(context.Item.SongId)</MudText>
<MudText Typo="Typo.body2" Style="font-weight:bold">@context.Item.MusicName</MudText>
<MudText Typo="Typo.caption">@context.Item.MusicArtist</MudText>
</MudStack>
</MudItem>
<MudItem xs="2">
@ -56,12 +56,12 @@
</MudGrid>
</CellTemplate>
</Column>
<Column T="SongBestData" Field="@nameof(SongBestData.SongId)" Title="Genre"
<Column T="SongBestData" Field="@nameof(SongBestData.Genre)" Title="Genre"
Sortable="false" Filterable="true">
<CellTemplate>
<MudChip Style="@GetGenreStyle(GameDataService.GetMusicGenreBySongId(context.Item.SongId))"
<MudChip Style="@GetGenreStyle(context.Item.Genre)"
Size="Size.Small">
@GetGenreTitle(GameDataService.GetMusicGenreBySongId(context.Item.SongId))
@GetGenreTitle(context.Item.Genre)
</MudChip>
</CellTemplate>
</Column>

View File

@ -21,6 +21,15 @@ public partial class TaikoMode
await base.OnInitializedAsync();
response = await Client.GetFromJsonAsync<SongBestResponse>($"api/PlayData/{Baid}");
response.ThrowIfNull();
response.SongBestData.ForEach(data =>
{
var songId = data.SongId;
data.Genre = GameDataService.GetMusicGenreBySongId(songId);
data.MusicName = GameDataService.GetMusicNameBySongId(songId);
data.MusicArtist = GameDataService.GetMusicArtistBySongId(songId);
});
songBestDataMap = response.SongBestData.GroupBy(data => data.Difficulty)
.ToDictionary(data => data.Key,
data => data.ToList());

View File

@ -1,8 +1,5 @@
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using TaikoWebUI;
using MudBlazor.Services;
using TaikoWebUI.Services;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");

View File

@ -1,9 +1,5 @@
using System.Collections.Immutable;
using System.Net.Http.Json;
using SharedProject.Enums;
using SharedProject.Models;
using TaikoWebUI.Shared.Models;
using Throw;
namespace TaikoWebUI.Services;

View File

@ -1,8 +1,4 @@
using SharedProject.Enums;
using SharedProject.Models;
using TaikoWebUI.Shared.Models;
namespace TaikoWebUI.Services;
namespace TaikoWebUI.Services;
public interface IGameDataService
{

View File

@ -1,6 +1,4 @@
using SharedProject.Enums;
namespace TaikoWebUI.Shared.Models;
namespace TaikoWebUI.Shared.Models;
public class MusicDetail
{

View File

@ -1,5 +1,4 @@
using System.Text.Json.Serialization;
using SharedProject.Enums;
namespace TaikoWebUI.Shared.Models;

View File

@ -1,5 +1,4 @@
using System.Text.Json.Serialization;
using SharedProject.Enums;
namespace TaikoWebUI.Shared.Models;

View File

@ -26,6 +26,9 @@
<Content Update="wwwroot\data\wordlist.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\data\music_order.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>