实现多语言切换
This commit is contained in:
@@ -1,13 +1,36 @@
|
||||
<Router AppAssembly="typeof(Program).Assembly">
|
||||
@using Microsoft.AspNetCore.Components.Routing
|
||||
@inject Atomx.Admin.Client.Services.ILocalizationProvider LocalizationProvider
|
||||
|
||||
<Router AppAssembly="typeof(Program).Assembly">
|
||||
<Found Context="routeData">
|
||||
<CascadingValue Value="routeData">
|
||||
<AuthorizeRouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)">
|
||||
<NotAuthorized>
|
||||
<RedirectToLogin />
|
||||
</NotAuthorized>
|
||||
</AuthorizeRouteView>
|
||||
</CascadingValue>
|
||||
<FocusOnNavigate RouteData="routeData" Selector="h1" />
|
||||
<AuthorizeRouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)">
|
||||
<NotAuthorized>
|
||||
<RedirectToLogin />
|
||||
</NotAuthorized>
|
||||
</AuthorizeRouteView>
|
||||
</CascadingValue>
|
||||
<FocusOnNavigate RouteData="routeData" Selector="h1" />
|
||||
</Found>
|
||||
</Router>
|
||||
<AntContainer />
|
||||
<AntContainer />
|
||||
|
||||
@code {
|
||||
private bool _initialized;
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender && !_initialized)
|
||||
{
|
||||
_initialized = true;
|
||||
try
|
||||
{
|
||||
if (LocalizationProvider != null)
|
||||
{
|
||||
await LocalizationProvider.InitializeAsync();
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user