mirror of https://github.com/abpframework/abp.git
30 changed files with 287 additions and 56 deletions
@ -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<Type> GetLayoutAsync(string name, bool fallbackToDefault = true); |
|||
} |
|||
|
|||
@ -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<ITheme> GetCurrentThemeAsync(); |
|||
} |
|||
|
|||
@ -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<ThemeInfo> GetCurrentThemeInfoAsync(); |
|||
} |
|||
|
|||
@ -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<Type> GetApplicationLayoutAsync(this ITheme theme, bool fallbackToDefault = true) |
|||
{ |
|||
return await theme.GetLayoutAsync(StandardLayouts.Application, fallbackToDefault); |
|||
} |
|||
|
|||
public async static Task<Type> GetAccountLayoutAsync(this ITheme theme, bool fallbackToDefault = true) |
|||
{ |
|||
return await theme.GetLayoutAsync(StandardLayouts.Account, fallbackToDefault); |
|||
} |
|||
|
|||
public async static Task<Type> GetPublicLayoutAsync(this ITheme theme, bool fallbackToDefault = true) |
|||
{ |
|||
return await theme.GetLayoutAsync(StandardLayouts.Public, fallbackToDefault); |
|||
} |
|||
|
|||
public async static Task<Type> GetEmptyLayoutAsync(this ITheme theme, bool fallbackToDefault = true) |
|||
{ |
|||
return await theme.GetLayoutAsync(StandardLayouts.Empty, fallbackToDefault); |
|||
} |
|||
|
|||
public async static Task<Type> GetCurrentApplicationLayoutAsync(this IThemeManager themeManager, bool fallbackToDefault = true) |
|||
{ |
|||
return await (await themeManager.GetCurrentThemeAsync()).GetLayoutAsync(StandardLayouts.Application, fallbackToDefault); |
|||
} |
|||
|
|||
public async static Task<Type> GetCurrentAccountLayoutAsync(this IThemeManager themeManager, bool fallbackToDefault = true) |
|||
{ |
|||
return await (await themeManager.GetCurrentThemeAsync()).GetLayoutAsync(StandardLayouts.Account, fallbackToDefault); |
|||
} |
|||
|
|||
public async static Task<Type> GetCurrentPublicLayoutAsync(this IThemeManager themeManager, bool fallbackToDefault = true) |
|||
{ |
|||
return await (await themeManager.GetCurrentThemeAsync()).GetLayoutAsync(StandardLayouts.Public, fallbackToDefault); |
|||
} |
|||
|
|||
public async static Task<Type> GetCurrentEmptyLayoutAsync(this IThemeManager themeManager, bool fallbackToDefault = true) |
|||
{ |
|||
return await (await themeManager.GetCurrentThemeAsync()).GetLayoutAsync(StandardLayouts.Empty, fallbackToDefault); |
|||
} |
|||
} |
|||
|
|||
@ -1,5 +1,5 @@ |
|||
@using Volo.Abp.AspNetCore.Mvc.UI.Theming |
|||
@inject IThemeManager ThemeManager |
|||
@{ |
|||
Layout = ThemeManager.CurrentTheme.GetApplicationLayout(); |
|||
} |
|||
Layout = await ThemeManager.GetCurrentApplicationLayoutAsync(); |
|||
} |
|||
|
|||
@ -1,5 +1,5 @@ |
|||
@using Volo.Abp.AspNetCore.Mvc.UI.Theming |
|||
@inject IThemeManager ThemeManager |
|||
@{ |
|||
Layout = ThemeManager.CurrentTheme.GetApplicationLayout(); |
|||
} |
|||
Layout = await ThemeManager.GetCurrentApplicationLayoutAsync(); |
|||
} |
|||
|
|||
@ -1,5 +1,5 @@ |
|||
@using Volo.Abp.AspNetCore.Mvc.UI.Theming |
|||
@inject IThemeManager ThemeManager |
|||
@{ |
|||
Layout = ThemeManager.CurrentTheme.GetApplicationLayout(); |
|||
} |
|||
Layout = await ThemeManager.GetCurrentApplicationLayoutAsync(); |
|||
} |
|||
|
|||
@ -1,5 +1,5 @@ |
|||
@using Volo.Abp.AspNetCore.Mvc.UI.Theming |
|||
@inject IThemeManager ThemeManager |
|||
@{ |
|||
Layout = ThemeManager.CurrentTheme.GetApplicationLayout(); |
|||
} |
|||
Layout = await ThemeManager.GetCurrentApplicationLayoutAsync(); |
|||
} |
|||
|
|||
@ -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<string> GetLayoutAsync(string name, bool fallbackToDefault = true); |
|||
} |
|||
|
|||
@ -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<ITheme> GetCurrentThemeAsync(); |
|||
} |
|||
|
|||
@ -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<ThemeInfo> GetCurrentThemeInfoAsync(); |
|||
} |
|||
|
|||
@ -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<string> GetApplicationLayoutAsync(this ITheme theme, bool fallbackToDefault = true) |
|||
{ |
|||
return await theme.GetLayoutAsync(StandardLayouts.Application, fallbackToDefault); |
|||
} |
|||
|
|||
public async static Task<string> GetAccountLayoutAsync(this ITheme theme, bool fallbackToDefault = true) |
|||
{ |
|||
return await theme.GetLayoutAsync(StandardLayouts.Account, fallbackToDefault); |
|||
} |
|||
|
|||
public async static Task<string> GetPublicLayoutAsync(this ITheme theme, bool fallbackToDefault = true) |
|||
{ |
|||
return await theme.GetLayoutAsync(StandardLayouts.Public, fallbackToDefault); |
|||
} |
|||
|
|||
public async static Task<string> GetEmptyLayoutAsync(this ITheme theme, bool fallbackToDefault = true) |
|||
{ |
|||
return await theme.GetLayoutAsync(StandardLayouts.Empty, fallbackToDefault); |
|||
} |
|||
|
|||
public async static Task<string> GetCurrentApplicationLayoutAsync(this IThemeManager themeManager, bool fallbackToDefault = true) |
|||
{ |
|||
return await (await themeManager.GetCurrentThemeAsync()).GetLayoutAsync(StandardLayouts.Application, fallbackToDefault); |
|||
} |
|||
|
|||
public async static Task<string> GetCurrentAccountLayoutAsync(this IThemeManager themeManager, bool fallbackToDefault = true) |
|||
{ |
|||
return await (await themeManager.GetCurrentThemeAsync()).GetLayoutAsync(StandardLayouts.Account, fallbackToDefault); |
|||
} |
|||
|
|||
public async static Task<string> GetCurrentPublicLayoutAsync(this IThemeManager themeManager, bool fallbackToDefault = true) |
|||
{ |
|||
return await (await themeManager.GetCurrentThemeAsync()).GetLayoutAsync(StandardLayouts.Public, fallbackToDefault); |
|||
} |
|||
|
|||
public async static Task<string> GetCurrentEmptyLayoutAsync(this IThemeManager themeManager, bool fallbackToDefault = true) |
|||
{ |
|||
return await (await themeManager.GetCurrentThemeAsync()).GetLayoutAsync(StandardLayouts.Empty, fallbackToDefault); |
|||
} |
|||
} |
|||
|
|||
@ -1,7 +1,7 @@ |
|||
@using Volo.Abp.AspNetCore.Mvc.UI.Theming |
|||
@inject IThemeManager ThemeManager |
|||
@{ |
|||
Layout = ThemeManager.CurrentTheme.GetAccountLayout(); |
|||
Layout = await ThemeManager.GetCurrentAccountLayoutAsync(); |
|||
} |
|||
<div class="abp-account-container"> |
|||
@RenderBody() |
|||
|
|||
@ -1,22 +1,19 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Theming; |
|||
|
|||
namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Layouts; |
|||
|
|||
public static class LayoutExtensions |
|||
{ |
|||
private static readonly Dictionary<string, Func<ITheme, string>> LayoutFunctions = new() |
|||
public async static Task<string> GetLayoutByKeyAsync(this ITheme theme, string layoutKey) |
|||
{ |
|||
[StandardLayouts.Account] = theme => theme.GetAccountLayout(), |
|||
[StandardLayouts.Public] = theme => theme.GetPublicLayout(), |
|||
[StandardLayouts.Empty] = theme => theme.GetEmptyLayout(), |
|||
}; |
|||
|
|||
public static string GetLayoutByKey(this ITheme theme, string layoutKey) |
|||
{ |
|||
return !string.IsNullOrWhiteSpace(layoutKey) && LayoutFunctions.TryGetValue(layoutKey, out var layoutFunc) |
|||
? layoutFunc(theme) |
|||
: theme.GetApplicationLayout(); // Application layout is the default
|
|||
return layoutKey switch |
|||
{ |
|||
StandardLayouts.Application => await theme.GetApplicationLayoutAsync(), |
|||
StandardLayouts.Account => await theme.GetAccountLayoutAsync(), |
|||
StandardLayouts.Public => await theme.GetPublicLayoutAsync(), |
|||
StandardLayouts.Empty => await theme.GetEmptyLayoutAsync(), |
|||
_ => await theme.GetApplicationLayoutAsync() |
|||
}; |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -1,5 +1,5 @@ |
|||
@using Volo.Abp.AspNetCore.Mvc.UI.Theming |
|||
@inject IThemeManager ThemeManager |
|||
@{ |
|||
Layout = ThemeManager.CurrentTheme.GetPublicLayout(); |
|||
Layout = await ThemeManager.GetCurrentPublicLayoutAsync(); |
|||
} |
|||
|
|||
@ -1,5 +1,5 @@ |
|||
@using Volo.Abp.AspNetCore.Mvc.UI.Theming |
|||
@inject IThemeManager ThemeManager |
|||
@{ |
|||
Layout = ThemeManager.CurrentTheme.GetAccountLayout(); |
|||
Layout = await ThemeManager.GetCurrentAccountLayoutAsync(); |
|||
} |
|||
|
|||
Loading…
Reference in new issue