diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/BasicTheme.cs b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/BasicTheme.cs index fe75b38695..a9aeedd167 100644 --- a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/BasicTheme.cs +++ b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/BasicTheme.cs @@ -8,11 +8,19 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic { public const string Name = "Basic"; - public string DefaultLayout => "~/Themes/Basic/Layouts/App.cshtml"; - - public string GetLayoutOrNull(string name) + public string GetLayout(string name, bool fallbackToDefault = true) { - return DefaultLayout; + switch (name) + { + case StandardLayouts.Application: + return "~/Themes/Basic/Layouts/Application.cshtml"; + case StandardLayouts.Account: + return "~/Themes/Basic/Layouts/Application.cshtml"; + case StandardLayouts.Empty: + return "~/Themes/Basic/Layouts/Empty.cshtml"; + default: + return fallbackToDefault ? "~/Themes/Basic/Layouts/Application.cshtml" : null; + } } } } diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Pages/_ViewStart.cshtml b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Pages/_ViewStart.cshtml deleted file mode 100644 index 17679d1702..0000000000 --- a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Pages/_ViewStart.cshtml +++ /dev/null @@ -1,6 +0,0 @@ -@using Volo.Abp.AspNetCore.Mvc.UI.Theming -@inject IThemeManager ThemeManager -@{ - //TODO: Move this to a lower layer... to Shared? - Layout = ThemeManager.CurrentTheme.DefaultLayout; -} \ No newline at end of file diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/App.cshtml b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Application.cshtml similarity index 100% rename from src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/App.cshtml rename to src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Application.cshtml diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Empty.cshtml b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Empty.cshtml new file mode 100644 index 0000000000..556e3d71ee --- /dev/null +++ b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Empty.cshtml @@ -0,0 +1,38 @@ +@using Volo.Abp.AspNetCore.Mvc.AntiForgery +@using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Themes.Basic.Components.MainNavbar +@inject IAbpAntiForgeryManager AbpAntiForgeryManager +@{ + Layout = null; + AbpAntiForgeryManager.SetCookie(); +} + + + + + + + + + ABP Web Application + + + + + + @RenderSection("styles", false) + + + +
+ @RenderBody() +
+ + + + + + + @RenderSection("scripts", false) + + + \ No newline at end of file diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Views/_ViewStart.cshtml b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Views/_ViewStart.cshtml deleted file mode 100644 index 17679d1702..0000000000 --- a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Views/_ViewStart.cshtml +++ /dev/null @@ -1,6 +0,0 @@ -@using Volo.Abp.AspNetCore.Mvc.UI.Theming -@inject IThemeManager ThemeManager -@{ - //TODO: Move this to a lower layer... to Shared? - Layout = ThemeManager.CurrentTheme.DefaultLayout; -} \ No newline at end of file diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.csproj b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.csproj index b45b007f5a..59e3de5651 100644 --- a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.csproj +++ b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.csproj @@ -21,10 +21,6 @@ - - - - diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Areas/_ViewStart.cshtml b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Areas/_ViewStart.cshtml new file mode 100644 index 0000000000..08960f0314 --- /dev/null +++ b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Areas/_ViewStart.cshtml @@ -0,0 +1,5 @@ +@using Volo.Abp.AspNetCore.Mvc.UI.Theming +@inject IThemeManager ThemeManager +@{ + Layout = ThemeManager.CurrentTheme.GetApplicationLayout(); +} \ No newline at end of file diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/_ViewStart.cshtml b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/_ViewStart.cshtml new file mode 100644 index 0000000000..08960f0314 --- /dev/null +++ b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/_ViewStart.cshtml @@ -0,0 +1,5 @@ +@using Volo.Abp.AspNetCore.Mvc.UI.Theming +@inject IThemeManager ThemeManager +@{ + Layout = ThemeManager.CurrentTheme.GetApplicationLayout(); +} \ No newline at end of file diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Views/_ViewStart.cshtml b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Views/_ViewStart.cshtml new file mode 100644 index 0000000000..08960f0314 --- /dev/null +++ b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Views/_ViewStart.cshtml @@ -0,0 +1,5 @@ +@using Volo.Abp.AspNetCore.Mvc.UI.Theming +@inject IThemeManager ThemeManager +@{ + Layout = ThemeManager.CurrentTheme.GetApplicationLayout(); +} \ No newline at end of file diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.csproj b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.csproj index f5c7df6a68..3bcd1bd4b1 100644 --- a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.csproj +++ b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.csproj @@ -1,4 +1,4 @@ - + @@ -16,6 +16,9 @@ + + + diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Theming/ITheme.cs b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Theming/ITheme.cs index 563010c7f2..79fe001458 100644 --- a/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Theming/ITheme.cs +++ b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Theming/ITheme.cs @@ -2,8 +2,6 @@ { public interface ITheme { - string DefaultLayout { get; } - - string GetLayoutOrNull(string name); + string GetLayout(string name, bool fallbackToDefault = true); } } \ No newline at end of file diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Theming/StandardLayouts.cs b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Theming/StandardLayouts.cs new file mode 100644 index 0000000000..3e1b751262 --- /dev/null +++ b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Theming/StandardLayouts.cs @@ -0,0 +1,9 @@ +namespace Volo.Abp.AspNetCore.Mvc.UI.Theming +{ + public static class StandardLayouts + { + public const string Application = "Application"; + public const string Account = "Account"; + public const string Empty = "Empty"; + } +} diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Theming/ThemeExtensions.cs b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Theming/ThemeExtensions.cs new file mode 100644 index 0000000000..ad6e5f49d1 --- /dev/null +++ b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Theming/ThemeExtensions.cs @@ -0,0 +1,20 @@ +namespace Volo.Abp.AspNetCore.Mvc.UI.Theming +{ + public static class ThemeExtensions + { + public static string GetApplicationLayout(this ITheme theme, bool fallbackToDefault = true) + { + return theme.GetLayout(StandardLayouts.Application, fallbackToDefault); + } + + public static string GetAccountLayout(this ITheme theme, bool fallbackToDefault = true) + { + return theme.GetLayout(StandardLayouts.Account, fallbackToDefault); + } + + public static string GetEmptyLayout(this ITheme theme, bool fallbackToDefault = true) + { + return theme.GetLayout(StandardLayouts.Empty, fallbackToDefault); + } + } +} \ No newline at end of file