自定义 Blazor Wasm 应用的 'Authorizing...' 消息(左上角)
Customizing the 'Authorizing...' message (top left corner) of a Blazor Wasm app
加载 Blazor WebAssembly 应用程序时,它首先下载 blazor.webassembly.js 和该应用程序的所有 .NET 程序集。在加载所有内容之前,它会显示一条加载消息。我们可以在 wwwroot/index.html
中轻松更改此消息
<body>
<!-- Here -->
<app>Loading...</app>
<div id="blazor-error-ui">
An unhandled error has occurred.
<a href="" class="reload">Reload</a>
<a class="dismiss"></a>
</div>
<script src="_framework/blazor.webassembly.js"></script>
而且,如果我们通过身份验证保护您的应用程序(CascadingAuthenticationState
、AuthorizeRouteView
、...),我们还会在左上角看到 'Authorizing...'。
我的问题是:如何定制这条消息?我什么都没看到。
在App.razor
中您可以:
...
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
<Authorizing>
Some other authorizing message...
</Authorizing>
<NotAuthorized>
@if (!context.User.Identity.IsAuthenticated)
{
<RedirectToLogin />
}
else
{
<p>You are not authorized to access this resource.</p>
}
</NotAuthorized>
</AuthorizeRouteView>
...
加载 Blazor WebAssembly 应用程序时,它首先下载 blazor.webassembly.js 和该应用程序的所有 .NET 程序集。在加载所有内容之前,它会显示一条加载消息。我们可以在 wwwroot/index.html
<body>
<!-- Here -->
<app>Loading...</app>
<div id="blazor-error-ui">
An unhandled error has occurred.
<a href="" class="reload">Reload</a>
<a class="dismiss"></a>
</div>
<script src="_framework/blazor.webassembly.js"></script>
而且,如果我们通过身份验证保护您的应用程序(CascadingAuthenticationState
、AuthorizeRouteView
、...),我们还会在左上角看到 'Authorizing...'。
我的问题是:如何定制这条消息?我什么都没看到。
在App.razor
中您可以:
...
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
<Authorizing>
Some other authorizing message...
</Authorizing>
<NotAuthorized>
@if (!context.User.Identity.IsAuthenticated)
{
<RedirectToLogin />
}
else
{
<p>You are not authorized to access this resource.</p>
}
</NotAuthorized>
</AuthorizeRouteView>
...