diff --git a/modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/BasicThemeToolbarContributor.cs b/modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/BasicThemeToolbarContributor.cs index 39cc08ddd1..8888d36fb1 100644 --- a/modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/BasicThemeToolbarContributor.cs +++ b/modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/BasicThemeToolbarContributor.cs @@ -14,8 +14,6 @@ public class BasicThemeToolbarContributor : IToolbarContributor { if (context.Toolbar.Name == StandardToolbars.Main) { - context.Toolbar.Items.Add(new ToolbarItem(typeof(LanguageSwitch))); - //TODO: Can we find a different way to understand if authentication was configured or not? var authenticationStateProvider = context.ServiceProvider .GetService(); @@ -24,6 +22,8 @@ public class BasicThemeToolbarContributor : IToolbarContributor { context.Toolbar.Items.Add(new ToolbarItem(typeof(LoginDisplay))); } + + context.Toolbar.Items.Add(new ToolbarItem(typeof(LanguageSwitch))); } return Task.CompletedTask; diff --git a/modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor.cs b/modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor.cs index 5128141c47..f8be2fab25 100644 --- a/modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor.cs +++ b/modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor.cs @@ -28,22 +28,22 @@ public partial class LoginDisplay : IDisposable private ApplicationConfigurationDto _config; - protected string LoginUrl + protected string LoginUrl => PrependCulturePrefix(AuthenticationOptions.Value.LoginUrl); + + protected string LogoutUrl => PrependCulturePrefix(AuthenticationOptions.Value.LogoutUrl); + + protected string PrependCulturePrefix(string url) { - get + if (_config?.Localization.UseRouteBasedCulture != true) { - var loginUrl = AuthenticationOptions.Value.LoginUrl; - if (_config?.Localization.UseRouteBasedCulture != true) - { - return loginUrl; - } + return url; + } - var currentCulture = CultureInfo.CurrentCulture.Name; - var isKnownCulture = _config.Localization.Languages - .Any(l => string.Equals(l.CultureName, currentCulture, StringComparison.OrdinalIgnoreCase)); + var currentCulture = CultureInfo.CurrentCulture.Name; + var isKnownCulture = _config.Localization.Languages + .Any(l => string.Equals(l.CultureName, currentCulture, StringComparison.OrdinalIgnoreCase)); - return isKnownCulture ? $"{currentCulture}/{loginUrl}" : loginUrl; - } + return isKnownCulture ? $"{currentCulture}/{url}" : url; } protected async override Task OnInitializedAsync() @@ -76,13 +76,15 @@ public partial class LoginDisplay : IDisposable private async Task NavigateToAsync(string uri, string target = null) { + uri = uri?.TrimStart('~', '/') ?? uri; + if (target == "_blank") { - await JsRuntime.InvokeVoidAsync("open", uri, target); + await JsRuntime.InvokeVoidAsync("open", Navigation.ToAbsoluteUri(uri).ToString(), target); } else { - Navigation.NavigateTo(uri?.TrimStart('~', '/') ?? uri); + Navigation.NavigateTo(uri); } } @@ -90,11 +92,11 @@ public partial class LoginDisplay : IDisposable { if (AbpAspNetCoreComponentsWebOptions.Value.IsBlazorWebApp) { - Navigation.NavigateTo(AuthenticationOptions.Value.LogoutUrl, forceLoad: true); + Navigation.NavigateTo(LogoutUrl, forceLoad: true); } else { - Navigation.NavigateToLogout(AuthenticationOptions.Value.LogoutUrl); + Navigation.NavigateToLogout(LogoutUrl); } } }