1
0
mirror of synced 2024-11-24 06:50:15 +01:00

Merge from LoginRefactor branch

This commit is contained in:
S-Sebb 2024-08-14 16:01:56 +01:00
commit 4a7502218b
28 changed files with 966 additions and 786 deletions

View File

@ -1,9 +1,13 @@
@inherits LayoutComponentBase
@inject Blazored.LocalStorage.ILocalStorageService LocalStorage
@inject AuthService AuthService
@inject BreadcrumbsStateContainer BreadcrumbsStateContainer
@using Microsoft.Extensions.Options;
@using TaikoWebUI.Settings;
<MudThemeProvider IsDarkMode="@isDarkMode" Theme="@taikoWebUiTheme" />
<MudDialogProvider />
<MudSnackbarProvider />
@ -11,6 +15,7 @@
<MudLayout>
<MudAppBar Elevation="0">
<MudIconButton Icon="@Icons.Material.Filled.Menu" Color="Color.Inherit" Edge="Edge.Start" OnClick="DrawerToggle" Size="Size.Small" />
<MudBreadcrumbs Items="BreadcrumbsStateContainer.breadcrumbs" Class="p-0"></MudBreadcrumbs>
<MudSpacer />
<MudStack Spacing="3" Row="true">
<LanguageToggle />
@ -46,11 +51,14 @@
{
title = UiSettings.Value.Title;
}
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
BreadcrumbsStateContainer.OnChange += StateHasChanged;
var hasDrawerOpenEntry = await LocalStorage.ContainKeyAsync("drawerOpen");
if (hasDrawerOpenEntry)
@ -73,16 +81,16 @@
}
private async Task DrawerToggle()
{
drawerOpen = !drawerOpen;
await LocalStorage.SetItemAsync("drawerOpen", drawerOpen);
}
{
drawerOpen = !drawerOpen;
await LocalStorage.SetItemAsync("drawerOpen", drawerOpen);
}
private async Task ToggleDarkMode()
{
isDarkMode = !isDarkMode;
await LocalStorage.SetItemAsync("isDarkMode", isDarkMode);
}
{
isDarkMode = !isDarkMode;
await LocalStorage.SetItemAsync("isDarkMode", isDarkMode);
}
private string DarkModeIcon => isDarkMode ? Icons.Material.Filled.BrightnessLow : Icons.Material.Filled.Brightness2;
@ -102,4 +110,9 @@
PrimaryDarken = Colors.Indigo.Accent1,
},
};
public void Dispose()
{
BreadcrumbsStateContainer.OnChange -= StateHasChanged;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,7 @@
@inject IDialogService DialogService
@inject AuthService AuthService
@inject NavigationManager NavigationManager
@inject BreadcrumbsStateContainer BreadcrumbsStateContainer
@inject Utilities.StringUtil StringUtil;
@if (AuthService.LoginRequired && (!AuthService.IsLoggedIn || (AuthService.GetLoggedInBaid() != Baid && !AuthService.IsAdmin))) {
@ -13,8 +14,6 @@
<MudProgressCircular Indeterminate="true" Size="Size.Large" Color="Color.Primary" />
</MudContainer>
} else {
<MudBreadcrumbs Items="breadcrumbs" Class="p-0 mb-2"></MudBreadcrumbs>
<MudText Typo="Typo.h4">@Localizer["Access Codes"]</MudText>
<MudGrid Class="my-4 pb-10">
<MudItem xs="12">
<MudCard Outlined="true" Class="mb-6">

View File

@ -14,8 +14,6 @@ public partial class AccessCode
private UserSetting? userSetting;
private readonly List<BreadcrumbItem> breadcrumbs = new();
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
@ -29,16 +27,12 @@ public partial class AccessCode
userSetting = await Client.GetFromJsonAsync<UserSetting>($"api/UserSettings/{Baid}");
if (AuthService.IsLoggedIn && !AuthService.IsAdmin)
{
breadcrumbs.Add(new BreadcrumbItem(Localizer["Dashboard"], href: "/"));
}
else
{
breadcrumbs.Add(new BreadcrumbItem(Localizer["Users"], href: "/Users"));
}
breadcrumbs.Add(new BreadcrumbItem($"{userSetting?.MyDonName}", href: null, disabled: true));
breadcrumbs.Add(new BreadcrumbItem(Localizer["Access Codes"], href: $"/Users/{Baid}/AccessCode", disabled: false));
BreadcrumbsStateContainer.breadcrumbs.Clear();
if (AuthService.IsLoggedIn && !AuthService.IsAdmin) BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem(Localizer["Dashboard"], href: "/"));
else BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem(Localizer["Users"], href: "/Users"));
BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem($"{userSetting?.MyDonName}", href: null, disabled: true));
BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem(Localizer["Access Codes"], href: $"/Users/{Baid}/AccessCode", disabled: false));
BreadcrumbsStateContainer.NotifyStateChanged();
}
private async Task InitializeUser()

View File

@ -2,6 +2,7 @@
@inject IDialogService DialogService
@inject AuthService AuthService
@inject NavigationManager NavigationManager
@inject BreadcrumbsStateContainer BreadcrumbsStateContainer
@page "/ChangePassword"

View File

@ -16,6 +16,10 @@ public partial class ChangePassword
{
await AuthService.LoginWithAuthToken();
}
BreadcrumbsStateContainer.breadcrumbs.Clear();
BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem(Localizer["Change Password"], href: "/"));
BreadcrumbsStateContainer.NotifyStateChanged();
}
private async Task OnChangePassword()

View File

@ -6,6 +6,7 @@
@inject AuthService AuthService
@inject NavigationManager NavigationManager
@inject ILocalStorageService LocalStorage
@inject BreadcrumbsStateContainer BreadcrumbsStateContainer
@page "/Users/{baid:int}/DaniDojo"
@ -22,8 +23,7 @@
}
else
{
<MudBreadcrumbs Items="breadcrumbs" Class="p-0 mb-2"></MudBreadcrumbs>
<MudText Typo="Typo.h4">@Localizer["Dani Dojo"]</MudText>
<MudGrid Class="my-4 pb-10">
<MudItem xs="12">
<MudPaper Elevation="0" Outlined="true">

View File

@ -17,12 +17,10 @@ public partial class DaniDojo
private Dictionary<uint, MusicDetail> musicDetailDictionary = new();
private ImmutableDictionary<uint, DanData> danMap = ImmutableDictionary<uint, DanData>.Empty;
private readonly List<BreadcrumbItem> breadcrumbs = new();
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
if (AuthService.LoginRequired && !AuthService.IsLoggedIn)
{
await AuthService.LoginWithAuthToken();
@ -39,19 +37,16 @@ public partial class DaniDojo
SongNameLanguage = await LocalStorage.GetItemAsync<string>("songNameLanguage");
userSetting = await Client.GetFromJsonAsync<UserSetting>($"api/UserSettings/{Baid}");
musicDetailDictionary = await GameDataService.GetMusicDetailDictionary();
if (AuthService.IsLoggedIn && !AuthService.IsAdmin)
{
breadcrumbs.Add(new BreadcrumbItem(Localizer["Dashboard"], href: "/"));
}
else
{
breadcrumbs.Add(new BreadcrumbItem(Localizer["Users"], href: "/Users"));
};
breadcrumbs.Add(new BreadcrumbItem($"{userSetting?.MyDonName}", href: null, disabled: true));
breadcrumbs.Add(new BreadcrumbItem(Localizer["Dani Dojo"], href: $"/Users/{Baid}/DaniDojo", disabled: false));
// Breadcrumbs
BreadcrumbsStateContainer.breadcrumbs.Clear();
if (AuthService.IsLoggedIn && !AuthService.IsAdmin) BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem(Localizer["Dashboard"], href: "/"));
else BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem(Localizer["Users"], href: "/Users"));
BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem($"{userSetting?.MyDonName}", href: null, disabled: true));
BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem(Localizer["Dani Dojo"], href: $"/Users/{Baid}/DaniDojo", disabled: false));
BreadcrumbsStateContainer.NotifyStateChanged();
}
private string GetDanClearStateString(DanClearState danClearState)
@ -111,7 +106,7 @@ public partial class DaniDojo
private static uint GetSongBestFromData(DanConditionType type, DanBestData data, int songNumber)
{
songNumber.Throw().IfOutOfRange(0, 2);
return type switch
{
DanConditionType.SoulGauge => throw new ArgumentException("Soul gauge should not be here"),

View File

@ -1,15 +1,15 @@
@page "/"
@inject HttpClient Http
@using Markdig
@inject HttpClient Http
@inject BreadcrumbsStateContainer BreadcrumbsStateContainer
<MudText Typo="Typo.h4">@Localizer["Dashboard"]</MudText>
<MudGrid Class="my-8">
<MudItem xs="12">
<MudPaper Elevation="0" Outlined="true">
<div class="markdown-container">
@if (isLoading)
{
<MudCircularProgress />
<MudProgressCircular/>
}
else
{
@ -48,5 +48,9 @@
}
isLoading = false;
BreadcrumbsStateContainer.breadcrumbs.Clear();
BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem(Localizer["Dashboard"], href: "/"));
BreadcrumbsStateContainer.NotifyStateChanged();
}
}

View File

@ -4,13 +4,11 @@
@inject HttpClient Client
@inject AuthService AuthService
@inject NavigationManager NavigationManager
@inject BreadcrumbsStateContainer BreadcrumbsStateContainer
@inject Blazored.LocalStorage.ILocalStorageService LocalStorage
@page "/Users/{baid:int}/HighScores"
<MudBreadcrumbs Items="breadcrumbs" Class="p-0 mb-2"></MudBreadcrumbs>
<MudText Typo="Typo.h4">@Localizer["High Scores"]</MudText>
<MudGrid Class="my-8">
@if (response is null)
{

View File

@ -8,8 +8,6 @@ public partial class HighScores
private SongBestResponse? response;
private UserSetting? userSetting;
private Dictionary<Difficulty, List<SongBestData>> songBestDataMap = new();
private readonly List<BreadcrumbItem> breadcrumbs = new();
private int selectedDifficultyTab;
private Dictionary<uint, MusicDetail> musicDetailDictionary = new();
@ -51,16 +49,18 @@ public partial class HighScores
selectedDifficultyTab = await LocalStorage.GetItemAsync<int>($"highScoresTab");
// Breadcrumbs
BreadcrumbsStateContainer.breadcrumbs.Clear();
if (AuthService.IsLoggedIn && !AuthService.IsAdmin)
{
breadcrumbs.Add(new BreadcrumbItem(Localizer["Dashboard"], href: "/"));
BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem(Localizer["Dashboard"], href: "/"));
}
else
{
breadcrumbs.Add(new BreadcrumbItem(Localizer["Users"], href: "/Users"));
BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem(Localizer["Users"], href: "/Users"));
};
breadcrumbs.Add(new BreadcrumbItem($"{userSetting?.MyDonName}", href: null, disabled: true));
breadcrumbs.Add(new BreadcrumbItem(Localizer["High Scores"], href: $"/Users/{Baid}/HighScores", disabled: false));
BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem($"{userSetting?.MyDonName}", href: null, disabled: true));
BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem(Localizer["High Scores"], href: $"/Users/{Baid}/HighScores", disabled: false));
BreadcrumbsStateContainer.NotifyStateChanged();
}
private async Task OnFavoriteToggled(SongBestData data)

View File

@ -2,6 +2,7 @@
@inject IDialogService DialogService
@inject AuthService AuthService
@inject NavigationManager NavigationManager
@inject BreadcrumbsStateContainer BreadcrumbsStateContainer
@page "/Login"

View File

@ -14,6 +14,10 @@ public partial class Login
{
await AuthService.LoginWithAuthToken();
}
BreadcrumbsStateContainer.breadcrumbs.Clear();
BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem(Localizer["Log In"], href: "/Login"));
BreadcrumbsStateContainer.NotifyStateChanged();
}
private async Task OnLogin()

View File

@ -6,12 +6,10 @@
@inject IJSRuntime JsRuntime
@inject NavigationManager NavigationManager
@inject ILocalStorageService LocalStorage
@inject BreadcrumbsStateContainer BreadcrumbsStateContainer
@page "/Users/{baid:int}/PlayHistory"
<MudBreadcrumbs Items="breadcrumbs" Class="p-0 mb-2"></MudBreadcrumbs>
<MudText Typo="Typo.h4">@Localizer["Play History"]</MudText>
<MudGrid Class="my-8">
@if (response is null)
{
@ -62,7 +60,7 @@
</MudTh>
</HeaderContent>
<RowTemplate>
<div class="mt-4 mb-1">
<div class="mt-4 mb-1 ml-4">
<MudText Typo="Typo.subtitle2">
@CultureInfo.CurrentCulture.TextInfo.ToTitleCase(context[0].PlayTime.ToString(Localizer["DateFormat"]))
</MudText>
@ -104,7 +102,7 @@
<MudText Typo="Typo.caption">@songHistoryData.MusicArtist</MudText>
</a>
</div>
<div>
@* <div>
<MudToggleIconButton Toggled="@songHistoryData.IsFavorite"
ToggledChanged="@(async () => await OnFavoriteToggled(songHistoryData))"
Icon="@Icons.Material.Filled.FavoriteBorder" Color="@Color.Secondary"
@ -112,7 +110,7 @@
Size="Size.Small"
ToggledSize="Size.Small"
Title="Add to favorites" ToggledTitle="Remove from favorites" />
</div>
</div> *@
</MudStack>
</MudTd>

View File

@ -1,5 +1,6 @@
using System.Globalization;
using Microsoft.JSInterop;
using SharedProject.Models;
namespace TaikoWebUI.Pages;
@ -15,10 +16,9 @@ public partial class PlayHistory
private string? songNameLanguage;
private SongHistoryResponse? response;
private UserSetting? userSetting;
private Dictionary<DateTime, List<SongHistoryData>> songHistoryDataMap = new();
private readonly List<BreadcrumbItem> breadcrumbs = new();
private Dictionary<uint, MusicDetail> musicDetailDictionary = new();
@ -34,7 +34,9 @@ public partial class PlayHistory
response = await Client.GetFromJsonAsync<SongHistoryResponse>($"api/PlayHistory/{(uint)Baid}");
response.ThrowIfNull();
userSetting = await Client.GetFromJsonAsync<UserSetting>($"api/UserSettings/{Baid}");
songNameLanguage = await LocalStorage.GetItemAsync<string>("songNameLanguage");
musicDetailDictionary = await GameDataService.GetMusicDetailDictionary();
@ -54,6 +56,14 @@ public partial class PlayHistory
{
songHistoryDataList.Sort((data1, data2) => data1.SongNumber.CompareTo(data2.SongNumber));
}
//breadcrumbs
BreadcrumbsStateContainer.breadcrumbs.Clear();
if (AuthService.IsLoggedIn && !AuthService.IsAdmin) BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem(Localizer["Dashboard"], href: "/"));
else BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem(Localizer["Users"], href: "/Users"));
BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem($"{userSetting?.MyDonName}", href: null, disabled: true));
BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem(Localizer["Play History"], href: $"/Users/{Baid}/PlayHistory", disabled: false));
BreadcrumbsStateContainer.NotifyStateChanged();
}
private static string GetCrownText(CrownType crown)

View File

@ -5,6 +5,7 @@
@inject AuthService AuthService
@inject IJSRuntime JsRuntime
@inject NavigationManager NavigationManager
@inject BreadcrumbsStateContainer BreadcrumbsStateContainer
@if (response is not null)
{
@ -21,8 +22,6 @@
}
else
{
<MudBreadcrumbs Items="breadcrumbs" Class="p-0 mb-2"></MudBreadcrumbs>
<MudText Typo="Typo.h4">@Localizer["Profile"]</MudText>
<MudGrid Class="my-4 pb-10">
<MudItem xs="12" md="8">
<MudPaper Elevation="0" Outlined="true">

View File

@ -169,8 +169,6 @@ public partial class Profile
"Not Cleared", "Not Full Combo", "Not Donderful Combo"
};
private readonly List<BreadcrumbItem> breadcrumbs = new();
private Dictionary<Difficulty, List<SongBestData>> songBestDataMap = new();
private Difficulty highestDifficulty = Difficulty.Easy;
@ -208,17 +206,19 @@ public partial class Profile
musicDetailDictionary = await GameDataService.GetMusicDetailDictionary();
BreadcrumbsStateContainer.breadcrumbs.Clear();
if (AuthService.IsLoggedIn && !AuthService.IsAdmin)
{
breadcrumbs.Add(new BreadcrumbItem(Localizer["Dashboard"], href: "/"));
BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem(Localizer["Dashboard"], href: "/"));
}
else
{
breadcrumbs.Add(new BreadcrumbItem(Localizer["Users"], href: "/Users"));
BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem(Localizer["Users"], href: "/Users"));
}
breadcrumbs.Add(new BreadcrumbItem($"{response.MyDonName}", href: null, disabled: true));
breadcrumbs.Add(new BreadcrumbItem(Localizer["Profile"], href: $"/Users/{Baid}/Profile", disabled: false));
BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem($"{response.MyDonName}", href: null, disabled: true));
BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem(Localizer["Profile"], href: $"/Users/{Baid}/Profile", disabled: false));
BreadcrumbsStateContainer.NotifyStateChanged();
costumeList = await GameDataService.GetCostumeList();
titleDictionary = await GameDataService.GetTitleDictionary();
lockedCostumeDataDictionary = await GameDataService.GetLockedCostumeDataDictionary();
@ -374,7 +374,7 @@ public partial class Profile
// Adjust breadcrumb if name is changed
if (response != null)
{
breadcrumbs[^2] = new BreadcrumbItem($"{response.MyDonName}", href: null, disabled: true);
BreadcrumbsStateContainer.breadcrumbs[^2] = new BreadcrumbItem($"{response.MyDonName}", href: null, disabled: true);
}
}

View File

@ -1,6 +1,7 @@
@inject IDialogService DialogService
@inject AuthService AuthService
@inject NavigationManager NavigationManager
@inject BreadcrumbsStateContainer BreadcrumbsStateContainer
@page "/Register"

View File

@ -16,6 +16,10 @@ public partial class Register
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
BreadcrumbsStateContainer.breadcrumbs.Clear();
BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem(Localizer["Register"], href: "/Register"));
BreadcrumbsStateContainer.NotifyStateChanged();
}
private async Task OnRegister()

View File

@ -7,16 +7,22 @@
@inject AuthService AuthService
@inject NavigationManager NavigationManager
@inject ILocalStorageService LocalStorage
@inject BreadcrumbsStateContainer BreadcrumbsStateContainer
@if (AuthService.LoginRequired && (!AuthService.IsLoggedIn || (AuthService.GetLoggedInBaid() != Baid && !AuthService.IsAdmin)))
@if (response is null)
{
NavigationManager.NavigateTo(AuthService.IsLoggedIn ? "/" : "/Login");
<MudContainer Style="display:flex;margin:50px 0;align-items:center;justify-content:center;">
<MudProgressCircular Indeterminate="true" Size="Size.Large" Color="Color.Primary" />
</MudContainer>
}
else
{
if (response is not null)
@if (AuthService.LoginRequired && (!AuthService.IsLoggedIn || (AuthService.GetLoggedInBaid() != Baid && !AuthService.IsAdmin)))
{
NavigationManager.NavigateTo(AuthService.IsLoggedIn ? "/" : "/Login");
}
else
{
<MudBreadcrumbs Items="breadcrumbs" Class="p-0 mb-3"></MudBreadcrumbs>
<MudText Typo="Typo.h5">@songTitle</MudText>
<MudText Typo="Typo.body2">@songArtist</MudText>
<MudGrid Class="my-4 pb-10">

View File

@ -11,7 +11,6 @@ public partial class Song
private UserSetting? userSetting;
private SongHistoryResponse? response;
private List<SongHistoryData>? songHistoryData;
private readonly List<BreadcrumbItem> breadcrumbs = new();
private string songTitle = string.Empty;
private string songArtist = string.Empty;
@ -19,7 +18,7 @@ public partial class Song
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
if (AuthService.LoginRequired && !AuthService.IsLoggedIn)
{
await AuthService.LoginWithAuthToken();
@ -32,7 +31,7 @@ public partial class Song
// Get user settings
userSetting = await Client.GetFromJsonAsync<UserSetting>($"api/UserSettings/{Baid}");
var musicDetailDictionary = await GameDataService.GetMusicDetailDictionary();
// Get song title and artist
@ -42,21 +41,14 @@ public partial class Song
// Breadcrumbs
var formattedSongTitle = songTitle;
if (formattedSongTitle.Length > 20)
{
formattedSongTitle = string.Concat(formattedSongTitle.AsSpan(0, 20), "...");
}
if (formattedSongTitle.Length > 20) formattedSongTitle = string.Concat(formattedSongTitle.AsSpan(0, 20), "...");
if (AuthService.IsLoggedIn && !AuthService.IsAdmin)
{
breadcrumbs.Add(new BreadcrumbItem(Localizer["Dashboard"], href: "/"));
}
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));
BreadcrumbsStateContainer.breadcrumbs.Clear();
if (AuthService.IsLoggedIn && !AuthService.IsAdmin) BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem(Localizer["Dashboard"], href: "/"));
else BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem(Localizer["Users"], href: "/Users"));
BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem($"{userSetting?.MyDonName}", href: null, disabled: true));
BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem(Localizer["Song List"], href: $"/Users/{Baid}/Songs", disabled: false));
BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem(formattedSongTitle, href: $"/Users/{Baid}/Songs/{SongId}", disabled: false));
BreadcrumbsStateContainer.NotifyStateChanged();
}
}

View File

@ -6,12 +6,10 @@
@inject AuthService AuthService
@inject ILocalStorageService LocalStorage
@inject NavigationManager NavigationManager
@inject BreadcrumbsStateContainer BreadcrumbsStateContainer
@page "/Users/{baid:int}/Songs"
<MudBreadcrumbs Items="breadcrumbs" Class="p-0 mb-2"></MudBreadcrumbs>
<MudText Typo="Typo.h4">@Localizer["Song List"]</MudText>
<MudGrid Class="my-8">
@if (response is null)
{

View File

@ -11,8 +11,6 @@ public partial class SongList
private SongBestResponse? response;
private UserSetting? userSetting;
private readonly List<BreadcrumbItem> breadcrumbs = new();
private Dictionary<uint, MusicDetail> musicDetailDictionary = new();
@ -38,16 +36,18 @@ public partial class SongList
if (best.SongId == song.Value.SongId)
song.Value.IsFavorite = best.IsFavorite;
BreadcrumbsStateContainer.breadcrumbs.Clear();
if (AuthService.IsLoggedIn && !AuthService.IsAdmin)
{
breadcrumbs.Add(new BreadcrumbItem(Localizer["Dashboard"], href: "/"));
BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem(Localizer["Dashboard"], href: "/"));
}
else
{
breadcrumbs.Add(new BreadcrumbItem(Localizer["Users"], href: "/Users"));
BreadcrumbsStateContainer.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));
BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem($"{userSetting?.MyDonName}", href: null, disabled: true));
BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem(Localizer["Song List"], href: $"/Users/{Baid}/Songs", disabled: false));
BreadcrumbsStateContainer.NotifyStateChanged();
}
private bool FilterSongs(MusicDetail musicDetail)

View File

@ -1,12 +1,12 @@
@inject HttpClient Client
@inject AuthService AuthService
@inject NavigationManager NavigationManager
@inject BreadcrumbsStateContainer BreadcrumbsStateContainer
@using TaikoWebUI.Components;
@page "/Users"
<MudText Typo="Typo.h4">@Localizer["Users"]</MudText>
<MudGrid Class="my-8">
@if (!AuthService.LoginRequired || (AuthService.LoginRequired && AuthService.IsAdmin)) {
<MudItem xs="12">

View File

@ -32,6 +32,10 @@ public partial class Users
{
await GetUsersData();
}
BreadcrumbsStateContainer.breadcrumbs.Clear();
BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem(Localizer["Users"], href: "/Users"));
BreadcrumbsStateContainer.NotifyStateChanged();
}
private async Task OnPageChange(int page)

View File

@ -35,6 +35,7 @@ builder.Services.AddLocalization();
builder.Services.AddSingleton<MudLocalizer, ResXMudLocalizer>();
builder.Services.AddSingleton<ScoreUtils>();
builder.Services.AddSingleton<StringUtil>();
builder.Services.AddSingleton<BreadcrumbsStateContainer>();
builder.Services.AddBlazoredLocalStorage();
var host = builder.Build();

View File

@ -0,0 +1,17 @@
namespace TaikoWebUI.Services
{
public class BreadcrumbsStateContainer
{
public List<BreadcrumbItem> breadcrumbs = new();
public event Action? OnChange;
public void SetBreadcrumbs(List<BreadcrumbItem> _breadcrumbs)
{
breadcrumbs = _breadcrumbs;
NotifyStateChanged();
}
public void NotifyStateChanged() => OnChange?.Invoke();
}
}