diff --git a/docs/en/framework/ui/mvc-razor-pages/customization-user-interface.md b/docs/en/framework/ui/mvc-razor-pages/customization-user-interface.md index bc3b7d8fc2..976b3add87 100644 --- a/docs/en/framework/ui/mvc-razor-pages/customization-user-interface.md +++ b/docs/en/framework/ui/mvc-razor-pages/customization-user-interface.md @@ -468,10 +468,10 @@ ABP uses the `ITheme` service to get the layout location by the layout name. You @using Volo.Abp.AspNetCore.Mvc.UI.Theming @inject IThemeManager ThemeManager @{ - Layout = ThemeManager.CurrentTheme.GetLayout(StandardLayouts.Empty); + Layout = await ThemeManager.GetCurrentEmptyLayoutAsync(); } ```` -This page will use the empty layout. You use `ThemeManager.CurrentTheme.GetEmptyLayout();` extension method as a shortcut. +This page will use the empty layout. You use `ThemeManager.GetCurrentEmptyLayoutAsync` extension method as a shortcut. If you want to set the layout for all the pages under a specific folder, then write the code above in a `_ViewStart.cshtml` file under that folder. diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/DefaultThemeManager.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/DefaultThemeManager.cs index 5abd114f83..ac153f4776 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/DefaultThemeManager.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/DefaultThemeManager.cs @@ -1,16 +1,14 @@ using System; +using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.DependencyInjection; namespace Volo.Abp.AspNetCore.Components.Web.Theming.Theming; public class DefaultThemeManager : IThemeManager, IScopedDependency, IServiceProviderAccessor -{ +{ public IServiceProvider ServiceProvider { get; } - public ITheme CurrentTheme => GetCurrentTheme(); - private ITheme? _currentTheme; - protected IThemeSelector ThemeSelector { get; } public DefaultThemeManager( @@ -21,14 +19,28 @@ public class DefaultThemeManager : IThemeManager, IScopedDependency, IServicePro ThemeSelector = themeSelector; } + [Obsolete("Use GetCurrentThemeAsync instead.")] + public ITheme CurrentTheme => GetCurrentTheme(); + protected virtual ITheme GetCurrentTheme() { if (_currentTheme != null) { return _currentTheme; } - + _currentTheme = (ITheme)ServiceProvider.GetRequiredService(ThemeSelector.GetCurrentThemeInfo().ThemeType); - return CurrentTheme; + return _currentTheme; + } + + public virtual async Task GetCurrentThemeAsync() + { + if (_currentTheme != null) + { + return _currentTheme; + } + + _currentTheme = (ITheme)ServiceProvider.GetRequiredService((await ThemeSelector.GetCurrentThemeInfoAsync()).ThemeType); + return _currentTheme; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/DefaultThemeSelector.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/DefaultThemeSelector.cs index 7e08ed1d97..226c3b94b4 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/DefaultThemeSelector.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/DefaultThemeSelector.cs @@ -1,4 +1,6 @@ -using System.Linq; +using System; +using System.Linq; +using System.Threading.Tasks; using Microsoft.Extensions.Options; using Volo.Abp.DependencyInjection; @@ -13,6 +15,7 @@ public class DefaultThemeSelector : IThemeSelector, ITransientDependency Options = options.Value; } + [Obsolete("Use GetCurrentThemeInfoAsync instead.")] public virtual ThemeInfo GetCurrentThemeInfo() { if (!Options.Themes.Any()) @@ -33,4 +36,25 @@ public class DefaultThemeSelector : IThemeSelector, ITransientDependency return themeInfo; } + + public virtual Task GetCurrentThemeInfoAsync() + { + if (!Options.Themes.Any()) + { + throw new AbpException($"No theme registered! Use {nameof(AbpThemingOptions)} to register themes."); + } + + if (Options.DefaultThemeName == null) + { + return Task.FromResult(Options.Themes.Values.First()); + } + + var themeInfo = Options.Themes.Values.FirstOrDefault(t => t.Name == Options.DefaultThemeName); + if (themeInfo == null) + { + throw new AbpException("Default theme is configured but it's not found in the registered themes: " + Options.DefaultThemeName); + } + + return Task.FromResult(themeInfo); + } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/ITheme.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/ITheme.cs index f379252f52..e635094594 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/ITheme.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/ITheme.cs @@ -1,8 +1,12 @@ using System; +using System.Threading.Tasks; namespace Volo.Abp.AspNetCore.Components.Web.Theming.Theming; public interface ITheme { + [Obsolete("Use GetLayoutAsync instead.")] Type GetLayout(string name, bool fallbackToDefault = true); + + Task GetLayoutAsync(string name, bool fallbackToDefault = true); } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/IThemeManager.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/IThemeManager.cs index 75bb35e8d8..b7d58eef37 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/IThemeManager.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/IThemeManager.cs @@ -1,6 +1,12 @@ -namespace Volo.Abp.AspNetCore.Components.Web.Theming.Theming; +using System; +using System.Threading.Tasks; + +namespace Volo.Abp.AspNetCore.Components.Web.Theming.Theming; public interface IThemeManager { + [Obsolete("Use GetCurrentThemeAsync instead.")] ITheme CurrentTheme { get; } + + Task GetCurrentThemeAsync(); } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/IThemeSelector.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/IThemeSelector.cs index 6cf92c4cfa..bba3dc4cf3 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/IThemeSelector.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/IThemeSelector.cs @@ -1,6 +1,12 @@ -namespace Volo.Abp.AspNetCore.Components.Web.Theming.Theming; +using System; +using System.Threading.Tasks; + +namespace Volo.Abp.AspNetCore.Components.Web.Theming.Theming; public interface IThemeSelector { + [Obsolete("Use GetCurrentThemeInfoAsync instead.")] ThemeInfo GetCurrentThemeInfo(); + + Task GetCurrentThemeInfoAsync(); } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/ThemeExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/ThemeExtensions.cs index 3236f491fe..4814e4e41d 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/ThemeExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/ThemeExtensions.cs @@ -1,27 +1,72 @@ using System; +using System.Threading.Tasks; using Volo.Abp.AspNetCore.Components.Web.Theming.Layout; namespace Volo.Abp.AspNetCore.Components.Web.Theming.Theming; public static class ThemeExtensions { + [Obsolete("Use GetApplicationLayoutAsync instead.")] public static Type GetApplicationLayout(this ITheme theme, bool fallbackToDefault = true) { return theme.GetLayout(StandardLayouts.Application, fallbackToDefault); } + [Obsolete("Use GetAccountLayoutAsync instead.")] public static Type GetAccountLayout(this ITheme theme, bool fallbackToDefault = true) { return theme.GetLayout(StandardLayouts.Account, fallbackToDefault); } + [Obsolete("Use GetPublicLayoutAsync instead.")] public static Type GetPublicLayout(this ITheme theme, bool fallbackToDefault = true) { return theme.GetLayout(StandardLayouts.Public, fallbackToDefault); } + [Obsolete("Use GetEmptyLayoutAsync instead.")] public static Type GetEmptyLayout(this ITheme theme, bool fallbackToDefault = true) { return theme.GetLayout(StandardLayouts.Empty, fallbackToDefault); } + + public async static Task GetApplicationLayoutAsync(this ITheme theme, bool fallbackToDefault = true) + { + return await theme.GetLayoutAsync(StandardLayouts.Application, fallbackToDefault); + } + + public async static Task GetAccountLayoutAsync(this ITheme theme, bool fallbackToDefault = true) + { + return await theme.GetLayoutAsync(StandardLayouts.Account, fallbackToDefault); + } + + public async static Task GetPublicLayoutAsync(this ITheme theme, bool fallbackToDefault = true) + { + return await theme.GetLayoutAsync(StandardLayouts.Public, fallbackToDefault); + } + + public async static Task GetEmptyLayoutAsync(this ITheme theme, bool fallbackToDefault = true) + { + return await theme.GetLayoutAsync(StandardLayouts.Empty, fallbackToDefault); + } + + public async static Task GetCurrentApplicationLayoutAsync(this IThemeManager themeManager, bool fallbackToDefault = true) + { + return await (await themeManager.GetCurrentThemeAsync()).GetLayoutAsync(StandardLayouts.Application, fallbackToDefault); + } + + public async static Task GetCurrentAccountLayoutAsync(this IThemeManager themeManager, bool fallbackToDefault = true) + { + return await (await themeManager.GetCurrentThemeAsync()).GetLayoutAsync(StandardLayouts.Account, fallbackToDefault); + } + + public async static Task GetCurrentPublicLayoutAsync(this IThemeManager themeManager, bool fallbackToDefault = true) + { + return await (await themeManager.GetCurrentThemeAsync()).GetLayoutAsync(StandardLayouts.Public, fallbackToDefault); + } + + public async static Task GetCurrentEmptyLayoutAsync(this IThemeManager themeManager, bool fallbackToDefault = true) + { + return await (await themeManager.GetCurrentThemeAsync()).GetLayoutAsync(StandardLayouts.Empty, fallbackToDefault); + } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Areas/_ViewStart.cshtml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Areas/_ViewStart.cshtml index 08960f0314..036947bf38 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Areas/_ViewStart.cshtml +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Areas/_ViewStart.cshtml @@ -1,5 +1,5 @@ @using Volo.Abp.AspNetCore.Mvc.UI.Theming @inject IThemeManager ThemeManager @{ - Layout = ThemeManager.CurrentTheme.GetApplicationLayout(); -} \ No newline at end of file + Layout = await ThemeManager.GetCurrentApplicationLayoutAsync(); +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Account/_ViewStart.cshtml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Account/_ViewStart.cshtml index 08960f0314..036947bf38 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Account/_ViewStart.cshtml +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Account/_ViewStart.cshtml @@ -1,5 +1,5 @@ @using Volo.Abp.AspNetCore.Mvc.UI.Theming @inject IThemeManager ThemeManager @{ - Layout = ThemeManager.CurrentTheme.GetApplicationLayout(); -} \ No newline at end of file + Layout = await ThemeManager.GetCurrentApplicationLayoutAsync(); +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/_ViewStart.cshtml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/_ViewStart.cshtml index 08960f0314..036947bf38 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/_ViewStart.cshtml +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/_ViewStart.cshtml @@ -1,5 +1,5 @@ @using Volo.Abp.AspNetCore.Mvc.UI.Theming @inject IThemeManager ThemeManager @{ - Layout = ThemeManager.CurrentTheme.GetApplicationLayout(); -} \ No newline at end of file + Layout = await ThemeManager.GetCurrentApplicationLayoutAsync(); +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Views/_ViewStart.cshtml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Views/_ViewStart.cshtml index 08960f0314..036947bf38 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Views/_ViewStart.cshtml +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Views/_ViewStart.cshtml @@ -1,5 +1,5 @@ @using Volo.Abp.AspNetCore.Mvc.UI.Theming @inject IThemeManager ThemeManager @{ - Layout = ThemeManager.CurrentTheme.GetApplicationLayout(); -} \ No newline at end of file + Layout = await ThemeManager.GetCurrentApplicationLayoutAsync(); +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Theming/DefaultThemeManager.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Theming/DefaultThemeManager.cs index 39e97bc518..78537e06bf 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Theming/DefaultThemeManager.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Theming/DefaultThemeManager.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.DependencyInjection; @@ -10,8 +11,6 @@ public class DefaultThemeManager : IThemeManager, IScopedDependency, IServicePro private const string CurrentThemeHttpContextKey = "__AbpCurrentTheme"; public IServiceProvider ServiceProvider { get; } - public ITheme CurrentTheme => GetCurrentTheme(); - protected IThemeSelector ThemeSelector { get; } protected IHttpContextAccessor HttpContextAccessor { get; } @@ -25,6 +24,10 @@ public class DefaultThemeManager : IThemeManager, IScopedDependency, IServicePro ThemeSelector = themeSelector; } + [Obsolete("Use GetCurrentThemeAsync instead.")] + public ITheme CurrentTheme => GetCurrentTheme(); + + [Obsolete("Use GetCurrentThemeInfoAsync instead.")] protected virtual ITheme GetCurrentTheme() { var preSelectedTheme = HttpContextAccessor.HttpContext!.Items[CurrentThemeHttpContextKey] as ITheme; @@ -37,4 +40,17 @@ public class DefaultThemeManager : IThemeManager, IScopedDependency, IServicePro return preSelectedTheme; } + + public virtual async Task GetCurrentThemeAsync() + { + var preSelectedTheme = HttpContextAccessor.HttpContext!.Items[CurrentThemeHttpContextKey] as ITheme; + + if (preSelectedTheme == null) + { + preSelectedTheme = (ITheme)ServiceProvider.GetRequiredService((await ThemeSelector.GetCurrentThemeInfoAsync()).ThemeType); + HttpContextAccessor.HttpContext.Items[CurrentThemeHttpContextKey] = preSelectedTheme; + } + + return preSelectedTheme; + } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Theming/DefaultThemeSelector.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Theming/DefaultThemeSelector.cs index 994f22b84b..83cbef402d 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Theming/DefaultThemeSelector.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Theming/DefaultThemeSelector.cs @@ -1,4 +1,6 @@ -using System.Linq; +using System; +using System.Linq; +using System.Threading.Tasks; using Microsoft.Extensions.Options; using Volo.Abp.DependencyInjection; @@ -13,6 +15,7 @@ public class DefaultThemeSelector : IThemeSelector, ITransientDependency Options = options.Value; } + [Obsolete("Use GetCurrentThemeInfoAsync instead.")] public virtual ThemeInfo GetCurrentThemeInfo() { if (!Options.Themes.Any()) @@ -33,4 +36,25 @@ public class DefaultThemeSelector : IThemeSelector, ITransientDependency return themeInfo; } + + public virtual Task GetCurrentThemeInfoAsync() + { + if (!Options.Themes.Any()) + { + throw new AbpException($"No theme registered! Use {nameof(AbpThemingOptions)} to register themes."); + } + + if (Options.DefaultThemeName == null) + { + return Task.FromResult(Options.Themes.Values.First()); + } + + var themeInfo = Options.Themes.Values.FirstOrDefault(t => t.Name == Options.DefaultThemeName); + if (themeInfo == null) + { + throw new AbpException("Default theme is configured but it's not found in the registered themes: " + Options.DefaultThemeName); + } + + return Task.FromResult(themeInfo); + } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Theming/ITheme.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Theming/ITheme.cs index 1d43cd7783..2201c7dc1b 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Theming/ITheme.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Theming/ITheme.cs @@ -1,6 +1,12 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Theming; +using System; +using System.Threading.Tasks; + +namespace Volo.Abp.AspNetCore.Mvc.UI.Theming; public interface ITheme { + [Obsolete("Use GetLayoutAsync instead.")] string GetLayout(string name, bool fallbackToDefault = true); + + Task GetLayoutAsync(string name, bool fallbackToDefault = true); } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Theming/IThemeManager.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Theming/IThemeManager.cs index 2a09e21a39..6d56462866 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Theming/IThemeManager.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Theming/IThemeManager.cs @@ -1,6 +1,12 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Theming; +using System; +using System.Threading.Tasks; + +namespace Volo.Abp.AspNetCore.Mvc.UI.Theming; public interface IThemeManager { + [Obsolete("Use GetCurrentThemeAsync instead.")] ITheme CurrentTheme { get; } + + Task GetCurrentThemeAsync(); } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Theming/IThemeSelector.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Theming/IThemeSelector.cs index 590e178012..4b0697f7a5 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Theming/IThemeSelector.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Theming/IThemeSelector.cs @@ -1,6 +1,12 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Theming; +using System; +using System.Threading.Tasks; + +namespace Volo.Abp.AspNetCore.Mvc.UI.Theming; public interface IThemeSelector { + [Obsolete("Use GetCurrentThemeInfoAsync instead.")] ThemeInfo GetCurrentThemeInfo(); + + Task GetCurrentThemeInfoAsync(); } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Theming/ThemeExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Theming/ThemeExtensions.cs index b0e1a82d57..dae52da796 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Theming/ThemeExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Theming/ThemeExtensions.cs @@ -1,24 +1,71 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Theming; +using System; +using System.Threading.Tasks; + +namespace Volo.Abp.AspNetCore.Mvc.UI.Theming; public static class ThemeExtensions { + [Obsolete("Use GetApplicationLayoutAsync instead.")] public static string GetApplicationLayout(this ITheme theme, bool fallbackToDefault = true) { return theme.GetLayout(StandardLayouts.Application, fallbackToDefault); } + [Obsolete("Use GetAccountLayoutAsync instead.")] public static string GetAccountLayout(this ITheme theme, bool fallbackToDefault = true) { return theme.GetLayout(StandardLayouts.Account, fallbackToDefault); } + [Obsolete("Use GetPublicLayoutAsync instead.")] public static string GetPublicLayout(this ITheme theme, bool fallbackToDefault = true) { return theme.GetLayout(StandardLayouts.Public, fallbackToDefault); } + [Obsolete("Use GetEmptyLayoutAsync instead.")] public static string GetEmptyLayout(this ITheme theme, bool fallbackToDefault = true) { return theme.GetLayout(StandardLayouts.Empty, fallbackToDefault); } + + public async static Task GetApplicationLayoutAsync(this ITheme theme, bool fallbackToDefault = true) + { + return await theme.GetLayoutAsync(StandardLayouts.Application, fallbackToDefault); + } + + public async static Task GetAccountLayoutAsync(this ITheme theme, bool fallbackToDefault = true) + { + return await theme.GetLayoutAsync(StandardLayouts.Account, fallbackToDefault); + } + + public async static Task GetPublicLayoutAsync(this ITheme theme, bool fallbackToDefault = true) + { + return await theme.GetLayoutAsync(StandardLayouts.Public, fallbackToDefault); + } + + public async static Task GetEmptyLayoutAsync(this ITheme theme, bool fallbackToDefault = true) + { + return await theme.GetLayoutAsync(StandardLayouts.Empty, fallbackToDefault); + } + + public async static Task GetCurrentApplicationLayoutAsync(this IThemeManager themeManager, bool fallbackToDefault = true) + { + return await (await themeManager.GetCurrentThemeAsync()).GetLayoutAsync(StandardLayouts.Application, fallbackToDefault); + } + + public async static Task GetCurrentAccountLayoutAsync(this IThemeManager themeManager, bool fallbackToDefault = true) + { + return await (await themeManager.GetCurrentThemeAsync()).GetLayoutAsync(StandardLayouts.Account, fallbackToDefault); + } + + public async static Task GetCurrentPublicLayoutAsync(this IThemeManager themeManager, bool fallbackToDefault = true) + { + return await (await themeManager.GetCurrentThemeAsync()).GetLayoutAsync(StandardLayouts.Public, fallbackToDefault); + } + + public async static Task GetCurrentEmptyLayoutAsync(this IThemeManager themeManager, bool fallbackToDefault = true) + { + return await (await themeManager.GetCurrentThemeAsync()).GetLayoutAsync(StandardLayouts.Empty, fallbackToDefault); + } } diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/LoggedOut.cshtml b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/LoggedOut.cshtml index b862e3ceef..e6433d4d4b 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/LoggedOut.cshtml +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/LoggedOut.cshtml @@ -7,7 +7,7 @@ @inject IThemeManager ThemeManager @inject IHtmlLocalizer L @{ - Layout = ThemeManager.CurrentTheme.GetApplicationLayout(); + Layout = await ThemeManager.GetCurrentApplicationLayoutAsync(); } @section scripts { diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml index 1c883936b4..8f88066c46 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml @@ -12,7 +12,7 @@ @inject Volo.Abp.Settings.ISettingProvider SettingProvider @{ - Layout = ThemeManager.CurrentTheme.GetAccountLayout(); + Layout = await ThemeManager.GetCurrentAccountLayoutAsync(); } @section scripts diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.cshtml b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.cshtml index 145fd82d0d..4475a05c07 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.cshtml +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.cshtml @@ -7,7 +7,7 @@ @inject IHtmlLocalizer L @model ManageModel @{ - Layout = ThemeManager.CurrentTheme.GetApplicationLayout(); + Layout = await ThemeManager.GetCurrentApplicationLayoutAsync(); } @section scripts { diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/_Layout.cshtml b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/_Layout.cshtml index a648fa61d1..e14bc14126 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/_Layout.cshtml +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/_Layout.cshtml @@ -1,7 +1,7 @@ @using Volo.Abp.AspNetCore.Mvc.UI.Theming @inject IThemeManager ThemeManager @{ - Layout = ThemeManager.CurrentTheme.GetAccountLayout(); + Layout = await ThemeManager.GetCurrentAccountLayoutAsync(); }