Use a better method to share common page layout

This commit is contained in:
2025-10-15 16:57:09 +09:00
parent b90001a89c
commit 4821d73b11
2 changed files with 42 additions and 50 deletions

View File

@ -11,8 +11,6 @@
@attribute [Authorize]
@layout AuthorizedLayout
@implements IDisposable
@inject NavigationManager NavigationManager
@ -21,7 +19,9 @@
<PageTitle>Тестирование экспорта</PageTitle>
<RadzenSplitter Orientation="Orientation.Vertical" Style="height: 100%; border: 1px solid rgba(0,0,0,.08);">
<AuthorizedContent Roles="@AppRole.OPERATOR_TYPE">
<Content>
<RadzenSplitter Orientation="Orientation.Vertical" Style="height: 100%; border: 1px solid rgba(0,0,0,.08);">
<RadzenSplitterPane Size="200px">
<div style="height: 100%;overflow: auto;">
<RadzenCardGroup Responsive="true">
@ -51,7 +51,9 @@
<RadzenSplitterPane Size="auto" Resizable="false">
<EventConsole @ref=@console />
</RadzenSplitterPane>
</RadzenSplitter>
</RadzenSplitter>
</Content>
</AuthorizedContent>
@code {
EventConsole console = default!;
@ -66,16 +68,6 @@
FileMessageCapturer messageCapturer;
bool catchMessageBody;
[CascadingParameter]
public AuthorizedLayout Layout { get; set; }
protected override void OnInitialized()
{
base.OnInitialized();
Layout.Roles = AppRole.ADMINISTRATOR_TYPE;
}
public void Dispose()
{
if (messageCapturer != null)

View File

@ -1,13 +1,9 @@
@inherits LayoutComponentBase
@using Microsoft.AspNetCore.Authorization
@layout MainLayout
@using Microsoft.AspNetCore.Authorization
<AuthorizeView Roles="@Roles">
<Authorized>
<CascadingValue Value="this">
@Body
@Content
</CascadingValue>
</Authorized>
<NotAuthorized>
@ -18,5 +14,9 @@
</AuthorizeView>
@code {
public string Roles { get; set; }
[Parameter]
public required string Roles { get; set; }
[Parameter]
public required RenderFragment Content { get; set; }
}