2024-05-27 00:06:51 +02:00
|
|
|
|
namespace TaikoWebUI.Pages;
|
2024-03-10 04:48:26 +01:00
|
|
|
|
|
2024-05-27 00:06:51 +02:00
|
|
|
|
public partial class Song
|
2024-03-10 04:48:26 +01:00
|
|
|
|
{
|
2024-05-27 00:06:51 +02:00
|
|
|
|
[Parameter]
|
|
|
|
|
public int SongId { get; set; }
|
2024-03-10 04:48:26 +01:00
|
|
|
|
|
2024-05-27 00:06:51 +02:00
|
|
|
|
[Parameter]
|
|
|
|
|
public int Baid { get; set; }
|
2024-03-10 04:48:26 +01:00
|
|
|
|
|
2024-05-27 00:06:51 +02:00
|
|
|
|
private UserSetting? userSetting;
|
|
|
|
|
private SongHistoryResponse? response;
|
|
|
|
|
private List<SongHistoryData>? songHistoryData;
|
|
|
|
|
private readonly List<BreadcrumbItem> breadcrumbs = new();
|
2024-03-10 04:48:26 +01:00
|
|
|
|
|
2024-05-27 00:06:51 +02:00
|
|
|
|
private string songTitle = string.Empty;
|
|
|
|
|
private string songArtist = string.Empty;
|
2024-03-10 04:48:26 +01:00
|
|
|
|
|
2024-05-27 00:06:51 +02:00
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
|
|
{
|
|
|
|
|
await base.OnInitializedAsync();
|
2024-05-25 19:12:30 +02:00
|
|
|
|
|
2024-05-27 00:06:51 +02:00
|
|
|
|
if (AuthService.LoginRequired && !AuthService.IsLoggedIn)
|
|
|
|
|
{
|
|
|
|
|
await AuthService.LoginWithAuthToken();
|
|
|
|
|
}
|
2024-03-10 04:48:26 +01:00
|
|
|
|
|
2024-05-27 00:06:51 +02:00
|
|
|
|
response = await Client.GetFromJsonAsync<SongHistoryResponse>($"api/PlayHistory/{(uint)Baid}");
|
|
|
|
|
response.ThrowIfNull();
|
|
|
|
|
// Get all song best data with SongId
|
|
|
|
|
songHistoryData = response.SongHistoryData.Where(data => data.SongId == (uint)SongId).ToList();
|
2024-03-10 04:48:26 +01:00
|
|
|
|
|
2024-05-27 00:06:51 +02:00
|
|
|
|
// Get user settings
|
|
|
|
|
userSetting = await Client.GetFromJsonAsync<UserSetting>($"api/UserSettings/{Baid}");
|
2024-05-25 19:12:30 +02:00
|
|
|
|
|
2024-05-27 00:06:51 +02:00
|
|
|
|
var musicDetailDictionary = await GameDataService.GetMusicDetailDictionary();
|
2024-03-10 04:48:26 +01:00
|
|
|
|
|
2024-05-27 00:06:51 +02:00
|
|
|
|
// Get song title and artist
|
|
|
|
|
var songNameLanguage = await LocalStorage.GetItemAsync<string>("songNameLanguage");
|
|
|
|
|
songTitle = GameDataService.GetMusicNameBySongId(musicDetailDictionary, (uint)SongId, string.IsNullOrEmpty(songNameLanguage) ? "ja" : songNameLanguage);
|
|
|
|
|
songArtist = GameDataService.GetMusicArtistBySongId(musicDetailDictionary, (uint)SongId, string.IsNullOrEmpty(songNameLanguage) ? "ja" : songNameLanguage);
|
2024-03-10 04:48:26 +01:00
|
|
|
|
|
2024-05-27 00:06:51 +02:00
|
|
|
|
// Breadcrumbs
|
|
|
|
|
var formattedSongTitle = songTitle;
|
|
|
|
|
if (formattedSongTitle.Length > 20)
|
|
|
|
|
{
|
|
|
|
|
formattedSongTitle = string.Concat(formattedSongTitle.AsSpan(0, 20), "...");
|
|
|
|
|
}
|
2024-03-10 04:48:26 +01:00
|
|
|
|
|
2024-05-27 00:06:51 +02:00
|
|
|
|
if (AuthService.IsLoggedIn && !AuthService.IsAdmin)
|
|
|
|
|
{
|
|
|
|
|
breadcrumbs.Add(new BreadcrumbItem(Localizer["Dashboard"], href: "/"));
|
2024-03-10 04:48:26 +01:00
|
|
|
|
}
|
2024-05-27 00:06:51 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
breadcrumbs.Add(new BreadcrumbItem(Localizer["Users"], href: "/Users"));
|
|
|
|
|
};
|
|
|
|
|
breadcrumbs.Add(new BreadcrumbItem($"{userSetting?.MyDonName}", href: null, disabled: true));
|
|
|
|
|
breadcrumbs.Add(new BreadcrumbItem(Localizer["Song List"], href: $"/Users/{Baid}/Songs", disabled: false));
|
|
|
|
|
breadcrumbs.Add(new BreadcrumbItem(formattedSongTitle, href: $"/Users/{Baid}/Songs/{SongId}", disabled: false));
|
2024-03-10 04:48:26 +01:00
|
|
|
|
}
|
2024-05-27 00:06:51 +02:00
|
|
|
|
}
|