BrowseView.razor.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using FNZCM.BlazorWasm.Models;
  2. using Microsoft.AspNetCore.Components;
  3. using Microsoft.JSInterop;
  4. namespace FNZCM.BlazorWasm.UI.Views.Browse
  5. {
  6. public partial class BrowseView
  7. {
  8. [Inject]
  9. private IJSRuntime Js { get; set; }
  10. private List<FeLibrary> SelectedLibs { get; set; } = new();
  11. private FeLibrary CurrentLibrary { get; set; }
  12. private FeDisc CurrentDisc { get; set; }
  13. protected override async Task OnInitializedAsync()
  14. {
  15. await base.OnInitializedAsync();
  16. if (FnzDataSet.AllLibrary?.Any() == true)
  17. {
  18. if (CurrentLibrary == null)
  19. {
  20. var f = FnzDataSet.AllLibrary.First();
  21. CurrentLibrary = f;
  22. SelectedLibs.Clear();
  23. SelectedLibs.Add(f);
  24. }
  25. StateHasChanged();
  26. }
  27. }
  28. public void SelectedLibraryChanged()
  29. {
  30. if (SelectedLibs.Count > 0)
  31. {
  32. CurrentLibrary = SelectedLibs.First();
  33. StateHasChanged();
  34. }
  35. }
  36. private void SelectDisc(FeDisc disc)
  37. {
  38. CurrentDisc = disc;
  39. StateHasChanged();
  40. Js.InvokeVoidAsync("ModalDiscShow");
  41. }
  42. }
  43. }