Добавлен пункт "мои плейлисты"
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
<MudCard>
|
||||
<MudCardContent Class="text-center">
|
||||
<MudText Typo="Typo.h5" Class="mb-4">Вход в PlaylistShared</MudText>
|
||||
|
||||
@*
|
||||
<MudText Typo="Typo.body2" Class="mb-6">
|
||||
Войдите через учётную запись Keycloak или используйте локальный аккаунт.
|
||||
</MudText>
|
||||
@@ -22,7 +22,7 @@
|
||||
</MudButton>
|
||||
|
||||
<MudDivider Class="my-4">или</MudDivider>
|
||||
|
||||
*@
|
||||
<!-- Локальная форма входа -->
|
||||
<MudTextField @bind-Value="_loginModel.Username" Label="Имя пользователя" Variant="Variant.Outlined" FullWidth="true" Class="mb-3" />
|
||||
<MudTextField @bind-Value="_loginModel.Password" Label="Пароль" Variant="Variant.Outlined" FullWidth="true" InputType="InputType.Password" @bind-Value:after="LocalLogin" />
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
@using PlaylistShared.Shared.DTO
|
||||
@using PlaylistShared.Shared.Enums
|
||||
@using PlaylistShared.Pwa.Services
|
||||
@using PlaylistShared.Shared.Profile
|
||||
@using PlaylistShared.Shared.SharedPlaylist
|
||||
@using PlaylistShared.Shared.Yandex
|
||||
@inject HttpClient Http
|
||||
@@ -17,7 +18,6 @@
|
||||
@inject IDialogService DialogService
|
||||
@inject IAudioPlayerService AudioPlayerService
|
||||
@inject IJSRuntime JS
|
||||
@inject IDialogService DialogService
|
||||
@implements IDisposable
|
||||
|
||||
<MudContainer MaxWidth="MaxWidth.ExtraLarge" Class="py-1 px-1" Style="height: 100%;">
|
||||
@@ -254,6 +254,7 @@
|
||||
<MudToggleItem Value="TrackSearchType.Album" Text="Альбомы" />
|
||||
<MudToggleItem Value="TrackSearchType.Playlist" Text="Плейлисты" />
|
||||
<MudToggleItem Value="TrackSearchType.Artist" Text="Исполнители" />
|
||||
<MudToggleItem Value="TrackSearchType.MyPlaylists" Text="Мои плейлисты" />
|
||||
</MudToggleGroup>
|
||||
</MudStack>
|
||||
</MudCardHeader>
|
||||
@@ -328,6 +329,34 @@
|
||||
</div>
|
||||
}
|
||||
|
||||
@* Секция персональных плейлистов *@
|
||||
@if (_searchResult?.PersonalPlaylists?.Any() == true)
|
||||
{
|
||||
<MudText Typo="Typo.h6" Class="mt-4 mb-2 ml-2">Плейлисты (персональные)</MudText>
|
||||
<div class="horizontal-scroll-container px-2">
|
||||
@foreach (var playlist in _searchResult.PersonalPlaylists)
|
||||
{
|
||||
<div style="width: 70px;">
|
||||
<PlaylistCard Item="playlist" OnClick="() => SearchTracksByEntity(playlist.Uuid, playlist.Title, TrackSearchType.Playlist)" />
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@* Секция лайкнутых плейлистов *@
|
||||
@if (_searchResult?.LikedPlaylists?.Any() == true)
|
||||
{
|
||||
<MudText Typo="Typo.h6" Class="mt-4 mb-2 ml-2">Плейлисты (лайки)</MudText>
|
||||
<div class="horizontal-scroll-container px-2">
|
||||
@foreach (var playlist in _searchResult.LikedPlaylists)
|
||||
{
|
||||
<div style="width: 70px;">
|
||||
<PlaylistCard Item="playlist" OnClick="() => SearchTracksByEntity(playlist.Uuid, playlist.Title, TrackSearchType.Playlist)" />
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@* Секция треков *@
|
||||
@if (_searchResult?.Tracks != null)
|
||||
{
|
||||
@@ -640,13 +669,50 @@
|
||||
private async Task SearchTracks(bool byId = false, string? forcedQuery = null)
|
||||
{
|
||||
var query = forcedQuery ?? _searchQuery;
|
||||
if (string.IsNullOrWhiteSpace(query))
|
||||
var type = _searchType;
|
||||
|
||||
|
||||
//Если поиск в моих плейлистах
|
||||
if (type == TrackSearchType.MyPlaylists)
|
||||
{
|
||||
var showMessage = true;
|
||||
|
||||
if (_isAuthenticated)
|
||||
{
|
||||
var response = await Http.GetFromJsonAsync<ApiResponse<YandexTokenStatus>>("/api/yandexaccount/status");
|
||||
if (response?.Success == true)
|
||||
{
|
||||
var hasToken = response?.Data?.HasToken ?? false;
|
||||
|
||||
if (hasToken) showMessage = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (showMessage)
|
||||
{
|
||||
var response = await DialogService.ShowMessageBoxAsync(new()
|
||||
{
|
||||
Title = "Необходимо авторизация",
|
||||
Message = "Для использования \"Мои плейлисты\" необходима авторизация в яндекс музыке.",
|
||||
YesText = "Авторизоваться",
|
||||
CancelText = "Отмена",
|
||||
});
|
||||
|
||||
if (response == true)
|
||||
{
|
||||
Navigation.NavigateTo("/login");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
//Если обычный поиск, нужен текст
|
||||
else if (string.IsNullOrWhiteSpace(query))
|
||||
{
|
||||
_searchResult = null;
|
||||
return;
|
||||
}
|
||||
|
||||
var type = _searchType;
|
||||
|
||||
// Распознавание ссылки Яндекс.Музыки
|
||||
if (!byId && Uri.TryCreate(query, UriKind.Absolute, out var uri) && uri.Host == "music.yandex.ru")
|
||||
@@ -671,7 +737,7 @@
|
||||
|
||||
try
|
||||
{
|
||||
var url = $"/api/yandexsearch/search?query={Uri.EscapeDataString(query)}&searchType={Uri.EscapeDataString(type.ToString())}&limit=20";
|
||||
var url = $"/api/yandexsearch/search?query={Uri.EscapeDataString(query)}&searchType={Uri.EscapeDataString(type.ToString())}";
|
||||
if (byId)
|
||||
url += "&byId=true";
|
||||
if (!string.IsNullOrEmpty(Token))
|
||||
|
||||
Reference in New Issue
Block a user