1
0
mirror of synced 2025-01-30 03:47:28 +01:00
TaikoLocalServer/TaikoWebUI/Pages/SongList.razor.cs

74 lines
2.3 KiB
C#
Raw Normal View History

2024-05-16 23:32:46 +01:00
using System.Reflection.Emit;
using Microsoft.JSInterop;
2024-03-13 22:27:55 -04:00
using TaikoWebUI.Shared.Models;
2022-09-22 22:53:35 -04:00
2024-03-14 00:38:26 -04:00
2024-03-08 18:42:56 -05:00
namespace TaikoWebUI.Pages;
2022-09-12 00:28:12 +08:00
public partial class SongList
2022-09-12 00:28:12 +08:00
{
[Parameter]
public int Baid { get; set; }
2024-05-16 23:32:46 +01:00
2024-03-14 00:38:26 -04:00
private string Search { get; set; } = string.Empty;
private string GenreFilter { get; set; } = string.Empty;
private string CurrentLanguage { get; set; } = "ja";
2022-09-12 00:28:12 +08:00
private SongBestResponse? response;
private UserSetting? userSetting;
2022-09-12 00:28:12 +08:00
2024-03-09 11:59:21 -05:00
private readonly List<BreadcrumbItem> breadcrumbs = new();
2022-09-12 00:28:12 +08:00
2024-03-13 22:27:55 -04:00
private List<MusicDetail> musicMap = new();
2022-09-12 00:28:12 +08:00
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
response = await Client.GetFromJsonAsync<SongBestResponse>($"api/PlayData/{Baid}");
response.ThrowIfNull();
userSetting = await Client.GetFromJsonAsync<UserSetting>($"api/UserSettings/{Baid}");
2024-03-13 22:30:15 -04:00
musicMap = GameDataService.GetMusicList();
2024-03-13 22:27:55 -04:00
2024-05-16 23:32:46 +01:00
CurrentLanguage = await JsRuntime.InvokeAsync<string>("blazorCulture.get");
2024-03-08 18:42:56 -05:00
2024-05-16 23:32:46 +01:00
if (AuthService.IsLoggedIn && !AuthService.IsAdmin)
2024-03-09 11:59:21 -05:00
{
breadcrumbs.Add(new BreadcrumbItem(Localizer["Dashboard"], href: "/"));
2024-03-09 11:59:21 -05:00
}
else
{
breadcrumbs.Add(new BreadcrumbItem(Localizer["Users"], href: "/Users"));
2024-03-09 11:59:21 -05:00
};
breadcrumbs.Add(new BreadcrumbItem($"{userSetting?.MyDonName}", href: null, disabled: true));
breadcrumbs.Add(new BreadcrumbItem(Localizer["Song List"], href: $"/Users/{Baid}/Songs", disabled: false));
2022-09-12 00:28:12 +08:00
}
2024-03-14 00:38:26 -04:00
private bool FilterSongs(MusicDetail musicDetail)
2022-09-22 22:53:35 -04:00
{
2024-03-14 00:38:26 -04:00
var stringsToCheck = new List<string>
{
musicDetail.SongName,
musicDetail.SongNameEN,
musicDetail.SongNameCN,
musicDetail.SongNameKO,
musicDetail.ArtistName,
musicDetail.ArtistNameEN,
musicDetail.ArtistNameCN,
musicDetail.ArtistNameKO
};
if (!string.IsNullOrEmpty(Search) && !stringsToCheck.Any(s => s.Contains(Search, StringComparison.OrdinalIgnoreCase)))
{
return false;
}
if (!string.IsNullOrEmpty(GenreFilter) && musicDetail.Genre != Enum.Parse<SongGenre>(GenreFilter))
{
return false;
}
return true;
2022-09-12 00:28:12 +08:00
}
}