mirror of https://github.com/abpframework/abp.git
52 changed files with 309 additions and 329 deletions
@ -0,0 +1,32 @@ |
|||||
|
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Components; |
||||
|
using Microsoft.AspNetCore.Components.Routing; |
||||
|
using Volo.Abp.UI.Navigation; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Components.Server.MudBlazorBasicTheme.Themes.Basic; |
||||
|
|
||||
|
public partial class LoginDisplay : IDisposable |
||||
|
{ |
||||
|
[Inject] |
||||
|
protected IMenuManager MenuManager { get; set; } |
||||
|
|
||||
|
protected ApplicationMenu Menu { get; set; } |
||||
|
|
||||
|
protected override async Task OnInitializedAsync() |
||||
|
{ |
||||
|
Menu = await MenuManager.GetAsync(StandardMenus.User); |
||||
|
|
||||
|
Navigation.LocationChanged += OnLocationChanged; |
||||
|
} |
||||
|
|
||||
|
protected virtual void OnLocationChanged(object sender, LocationChangedEventArgs e) |
||||
|
{ |
||||
|
InvokeAsync(StateHasChanged); |
||||
|
} |
||||
|
|
||||
|
public void Dispose() |
||||
|
{ |
||||
|
Navigation.LocationChanged -= OnLocationChanged; |
||||
|
} |
||||
|
} |
||||
@ -1,30 +0,0 @@ |
|||||
@using Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor.Components |
|
||||
@using Volo.Abp.Users |
|
||||
@using MudBlazor |
|
||||
@using Microsoft.Extensions.Localization |
|
||||
@using global::Localization.Resources.AbpUi |
|
||||
@using Volo.Abp.DependencyInjection |
|
||||
@inject ICurrentUser CurrentUser |
|
||||
@inject IStringLocalizer<AbpUiResource> L |
|
||||
|
|
||||
@if (CurrentUser.IsAuthenticated) |
|
||||
{ |
|
||||
<MudMenu Icon="@Icons.Material.Filled.AccountCircle"> |
|
||||
<MudMenuItem Href="/Account/Manage">@L["MyAccount"]</MudMenuItem> |
|
||||
<MudDivider /> |
|
||||
<MudMenuItem OnClick="@Logout">@L["Logout"]</MudMenuItem> |
|
||||
</MudMenu> |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
<MudButton Variant="Variant.Text" Href="/Account/Login">@L["Login"]</MudButton> |
|
||||
} |
|
||||
|
|
||||
@code { |
|
||||
[Inject] protected NavigationManager NavigationManager { get; set; } = default!; |
|
||||
|
|
||||
protected void Logout() |
|
||||
{ |
|
||||
NavigationManager.NavigateTo("/Account/Logout", forceLoad: true); |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,71 @@ |
|||||
|
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Components; |
||||
|
using Microsoft.AspNetCore.Components.Routing; |
||||
|
using Microsoft.AspNetCore.Components.WebAssembly.Authentication; |
||||
|
using Microsoft.JSInterop; |
||||
|
using Volo.Abp.AspNetCore.Components.Web.Security; |
||||
|
using Volo.Abp.UI.Navigation; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Components.WebAssembly.MudBlazorBasicTheme.Themes.Basic; |
||||
|
|
||||
|
public partial class LoginDisplay : IDisposable |
||||
|
{ |
||||
|
[Inject] |
||||
|
protected IMenuManager MenuManager { get; set; } |
||||
|
|
||||
|
[Inject] |
||||
|
protected ApplicationConfigurationChangedService ApplicationConfigurationChangedService { get; set; } |
||||
|
|
||||
|
protected ApplicationMenu Menu { get; set; } |
||||
|
|
||||
|
protected async override Task OnInitializedAsync() |
||||
|
{ |
||||
|
Menu = await MenuManager.GetAsync(StandardMenus.User); |
||||
|
|
||||
|
Navigation.LocationChanged += OnLocationChanged; |
||||
|
|
||||
|
ApplicationConfigurationChangedService.Changed += ApplicationConfigurationChanged; |
||||
|
} |
||||
|
|
||||
|
protected virtual void OnLocationChanged(object sender, LocationChangedEventArgs e) |
||||
|
{ |
||||
|
InvokeAsync(StateHasChanged); |
||||
|
} |
||||
|
|
||||
|
private async void ApplicationConfigurationChanged() |
||||
|
{ |
||||
|
Menu = await MenuManager.GetAsync(StandardMenus.User); |
||||
|
await InvokeAsync(StateHasChanged); |
||||
|
} |
||||
|
|
||||
|
public void Dispose() |
||||
|
{ |
||||
|
Navigation.LocationChanged -= OnLocationChanged; |
||||
|
ApplicationConfigurationChangedService.Changed -= ApplicationConfigurationChanged; |
||||
|
} |
||||
|
|
||||
|
private async Task NavigateToAsync(string uri, string target = null) |
||||
|
{ |
||||
|
if (target == "_blank") |
||||
|
{ |
||||
|
await JsRuntime.InvokeVoidAsync("open", uri, target); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
Navigation.NavigateTo(uri); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void BeginSignOut() |
||||
|
{ |
||||
|
if (AbpAspNetCoreComponentsWebOptions.Value.IsBlazorWebApp) |
||||
|
{ |
||||
|
Navigation.NavigateTo(AuthenticationOptions.Value.LogoutUrl, forceLoad: true); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
Navigation.NavigateToLogout(AuthenticationOptions.Value.LogoutUrl); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,5 +1,4 @@ |
|||||
@using Microsoft.AspNetCore.Components.Web |
@using Microsoft.AspNetCore.Components.Web |
||||
@using Volo.Abp.AspNetCore.Components.Web |
@using Volo.Abp.AspNetCore.Components.Web |
||||
@using Volo.Abp.BlazoriseUI |
@using Volo.Abp.MudBlazorUI |
||||
@using Blazorise |
@using global::MudBlazor |
||||
@using Blazorise.DataGrid |
|
||||
Loading…
Reference in new issue