feat: 框架搭建基本完成
geffzhang authored at 2023-02-28 20:06:05
1.12 KiB
NewLife.CubeBlazor
@namespace NewLife.CubeBlazor.Razor.Shared.Layouts
@inherits CubeComponentBase

<MDialog @bind-Value="Visible"
         Persistent
         MaxWidth="320">
    <ChildContent>
        <MCard>
            <MCardTitle>
                @T("UserException")
            </MCardTitle>
            <MCardText>
                @T("UserExceptionMsg")
            </MCardText>
            <MCardActions>
                <MSpacer></MSpacer>
                <MButton Color="red darken-1" Text OnClick="Logout">
                    @T("Confirm")
                </MButton>
            </MCardActions>
        </MCard>
    </ChildContent>
</MDialog>

@code {
    [Parameter]
    public bool Visible { get; set; }

    [Parameter]
    public EventCallback<bool> VisibleChanged { get; set; }

    private async Task Logout()
    {
        await Hiden();
        NavigationManager.NavigateTo($"/Account/Logout?redirectToLogin={true}", true);
    }

    private async Task Hiden()
    {
        if (VisibleChanged.HasDelegate)
        {
            await VisibleChanged.InvokeAsync(false);
        }
        else
        {
            Visible = false;
        }
    }
}