mirror of https://github.com/abpframework/abp.git
16 changed files with 410 additions and 18 deletions
@ -0,0 +1,36 @@ |
|||||
|
using Volo.Abp.AspNetCore.Components.MauiBlazor.Theming.Bundling; |
||||
|
using Volo.Abp.AspNetCore.Components.MauiBlazor.Theming.MudBlazor.Bundling; |
||||
|
using Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor; |
||||
|
using Volo.Abp.AspNetCore.Components.MauiBlazor; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Components.MauiBlazor.Theming.MudBlazor; |
||||
|
|
||||
|
[DependsOn( |
||||
|
typeof(AbpAspNetCoreComponentsMauiBlazorThemingBundlingModule), |
||||
|
typeof(AbpAspNetCoreComponentsWebThemingMudBlazorModule), |
||||
|
typeof(AbpAspNetCoreComponentsMauiBlazorModule) |
||||
|
)] |
||||
|
public class AbpAspNetCoreComponentsMauiBlazorThemingMudBlazorModule : AbpModule |
||||
|
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
Configure<AbpBundlingOptions>(options => |
||||
|
{ |
||||
|
options |
||||
|
.StyleBundles |
||||
|
.Add(MauiBlazorStandardBundles.Styles.Global, bundle => |
||||
|
{ |
||||
|
bundle.AddContributors(typeof(MauiBlazorMudBlazorStyleContributor)); |
||||
|
}); |
||||
|
|
||||
|
options |
||||
|
.ScriptBundles |
||||
|
.Add(MauiBlazorStandardBundles.Scripts.Global, bundle => |
||||
|
{ |
||||
|
bundle.AddContributors(typeof(MauiBlazorMudBlazorScriptContributor)); |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,15 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Components.MauiBlazor.Theming.MudBlazor.Bundling; |
||||
|
|
||||
|
public class MauiBlazorMudBlazorScriptContributor : BundleContributor |
||||
|
{ |
||||
|
public override void ConfigureBundle(BundleConfigurationContext context) |
||||
|
{ |
||||
|
//TODO@MudBlazor: Do we need this script, check ?
|
||||
|
context.Files.AddIfNotContains("_content/MudBlazor/MudBlazor.min.js"); |
||||
|
context.Files.AddIfNotContains("_content/Volo.Abp.AspNetCore.Components.Web/libs/abp/js/abp.js"); |
||||
|
context.Files.AddIfNotContains("_content/Volo.Abp.AspNetCore.Components.Web/libs/abp/js/lang-utils.js"); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Components.MauiBlazor.Theming.MudBlazor.Bundling; |
||||
|
|
||||
|
public class MauiBlazorMudBlazorStyleContributor : BundleContributor |
||||
|
{ |
||||
|
public override void ConfigureBundle(BundleConfigurationContext context) |
||||
|
{ |
||||
|
//TODO@MudBlazor: Do we need this public font ?
|
||||
|
context.Files.AddIfNotContains("https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"); |
||||
|
context.Files.AddIfNotContains("_content/MudBlazor/MudBlazor.min.css"); |
||||
|
context.Files.AddIfNotContains("_content/Volo.Abp.AspNetCore.Components.Web/libs/abp/css/abp.css"); |
||||
|
context.Files.AddIfNotContains("_content/Volo.Abp.MudBlazorUI/volo.abp.mudblazorui.css"); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,18 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk.Razor"> |
||||
|
|
||||
|
<Import Project="..\..\..\configureawait.props" /> |
||||
|
<Import Project="..\..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>net10.0</TargetFramework> |
||||
|
<Nullable>enable</Nullable> |
||||
|
<WarningsAsErrors>Nullable</WarningsAsErrors> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\Volo.Abp.AspNetCore.Components.MauiBlazor.Theming.Bundling\Volo.Abp.AspNetCore.Components.MauiBlazor.Theming.Bundling.csproj" /> |
||||
|
<ProjectReference Include="..\Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor\Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor.csproj" /> |
||||
|
<ProjectReference Include="..\Volo.Abp.AspNetCore.Components.MauiBlazor\Volo.Abp.AspNetCore.Components.MauiBlazor.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,35 @@ |
|||||
|
using Volo.Abp.AspNetCore.Components.Server.Theming.MudBlazor.Bundling; |
||||
|
using Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Components.Server.Theming.MudBlazor; |
||||
|
|
||||
|
[DependsOn( |
||||
|
typeof(AbpAspNetCoreComponentsServerModule), |
||||
|
typeof(AbpAspNetCoreMvcUiPackagesModule), |
||||
|
typeof(AbpAspNetCoreComponentsWebThemingMudBlazorModule), |
||||
|
typeof(AbpAspNetCoreMvcUiBundlingModule) |
||||
|
)] |
||||
|
public class AbpAspNetCoreComponentsServerThemingMudBlazorModule : AbpModule |
||||
|
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
Configure<AbpBundlingOptions>(options => |
||||
|
{ |
||||
|
options |
||||
|
.StyleBundles |
||||
|
.Add(BlazorStandardBundles.Styles.Global, bundle => |
||||
|
{ |
||||
|
bundle.AddContributors(typeof(BlazorServerMudBlazorStyleContributor)); |
||||
|
}); |
||||
|
|
||||
|
options |
||||
|
.ScriptBundles |
||||
|
.Add(BlazorStandardBundles.Scripts.Global, bundle => |
||||
|
{ |
||||
|
bundle.AddContributors(typeof(BlazorServerMudBlazorScriptContributor)); |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,23 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Options; |
||||
|
using Volo.Abp.AspNetCore.Components.Web; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Components.Server.Theming.MudBlazor.Bundling; |
||||
|
|
||||
|
public class BlazorServerMudBlazorScriptContributor : BundleContributor |
||||
|
{ |
||||
|
public override void ConfigureBundle(BundleConfigurationContext context) |
||||
|
{ |
||||
|
var options = context.ServiceProvider.GetRequiredService<IOptions<AbpAspNetCoreComponentsWebOptions>>().Value; |
||||
|
if (!options.IsBlazorWebApp) |
||||
|
{ |
||||
|
context.Files.AddIfNotContains("/_framework/blazor.server.js"); |
||||
|
} |
||||
|
//TODO@MudBlazor: Do we need this script, check ?
|
||||
|
context.Files.AddIfNotContains("/_content/MudBlazor/MudBlazor.min.js"); |
||||
|
context.Files.AddIfNotContains("/_content/Volo.Abp.AspNetCore.Components.Web/libs/abp/js/abp.js"); |
||||
|
context.Files.AddIfNotContains("/_content/Volo.Abp.AspNetCore.Components.Web/libs/abp/js/authentication-state-listener.js"); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Components.Server.Theming.MudBlazor.Bundling; |
||||
|
|
||||
|
public class BlazorServerMudBlazorStyleContributor : BundleContributor |
||||
|
{ |
||||
|
public override void ConfigureBundle(BundleConfigurationContext context) |
||||
|
{ |
||||
|
//TODO@MudBlazor: Do we need this public font ?
|
||||
|
context.Files.AddIfNotContains("https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"); |
||||
|
context.Files.AddIfNotContains("/_content/MudBlazor/MudBlazor.min.css"); |
||||
|
context.Files.AddIfNotContains("/_content/Volo.Abp.AspNetCore.Components.Web/libs/abp/css/abp.css"); |
||||
|
context.Files.AddIfNotContains("/_content/Volo.Abp.MudBlazorUI/volo.abp.mudblazorui.css"); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
namespace Volo.Abp.AspNetCore.Components.Server.Theming.MudBlazor.Bundling; |
||||
|
|
||||
|
public class BlazorStandardBundles |
||||
|
{ |
||||
|
public static class Styles |
||||
|
{ |
||||
|
public static string Global = "Blazor.Global"; |
||||
|
} |
||||
|
|
||||
|
public static class Scripts |
||||
|
{ |
||||
|
public static string Global = "Blazor.Global"; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk.Web"> |
||||
|
|
||||
|
<Import Project="..\..\..\configureawait.props" /> |
||||
|
<Import Project="..\..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>net10.0</TargetFramework> |
||||
|
<Nullable>enable</Nullable> |
||||
|
<WarningsAsErrors>Nullable</WarningsAsErrors> |
||||
|
<IsPackable>true</IsPackable> |
||||
|
<OutputType>Library</OutputType> |
||||
|
<NoDefaultLaunchSettingsFile>true</NoDefaultLaunchSettingsFile> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\Volo.Abp.AspNetCore.Components.Server\Volo.Abp.AspNetCore.Components.Server.csproj" /> |
||||
|
<ProjectReference Include="..\Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor\Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor.csproj" /> |
||||
|
<ProjectReference Include="..\Volo.Abp.AspNetCore.Mvc.UI.Bundling\Volo.Abp.AspNetCore.Mvc.UI.Bundling.csproj" /> |
||||
|
<ProjectReference Include="..\Volo.Abp.AspNetCore.Mvc.UI.Packages\Volo.Abp.AspNetCore.Mvc.UI.Packages.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,127 @@ |
|||||
|
using Microsoft.AspNetCore.Components; |
||||
|
using Microsoft.Extensions.Options; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.AspNetCore.Components.Web.Theming; |
||||
|
using Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars; |
||||
|
using Volo.Abp.BlazoriseUI; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor.Components; |
||||
|
|
||||
|
public partial class PageHeader : ComponentBase, IDisposable |
||||
|
{ |
||||
|
protected List<RenderFragment> ToolbarItemRenders { get; set; } |
||||
|
|
||||
|
[Inject] |
||||
|
public IPageToolbarManager PageToolbarManager { get; set; } = default!; |
||||
|
|
||||
|
[Inject] |
||||
|
public PageLayout PageLayout { get; private set; } = default!; |
||||
|
|
||||
|
[Inject] |
||||
|
public IOptions<PageHeaderOptions> Options { get; set; } = default!; |
||||
|
|
||||
|
[Parameter] |
||||
|
public string? Title { get => PageLayout.Title; set => PageLayout.Title = value; } |
||||
|
|
||||
|
[Parameter] |
||||
|
public bool BreadcrumbShowHome { get; set; } = true; |
||||
|
|
||||
|
[Parameter] |
||||
|
public bool BreadcrumbShowCurrent { get; set; } = true; |
||||
|
|
||||
|
[Parameter] |
||||
|
public RenderFragment ChildContent { get; set; } = default!; |
||||
|
|
||||
|
[Parameter] |
||||
|
public List<BreadcrumbItem> BreadcrumbItems |
||||
|
{ |
||||
|
get => PageLayout.BreadcrumbItems.ToList(); |
||||
|
set |
||||
|
{ |
||||
|
PageLayout.BreadcrumbItems.Clear(); |
||||
|
if (value != null) |
||||
|
{ |
||||
|
foreach (var item in value) |
||||
|
{ |
||||
|
PageLayout.BreadcrumbItems.Add(item); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
[Parameter] |
||||
|
public PageToolbar? Toolbar { get; set; } |
||||
|
|
||||
|
public PageHeader() |
||||
|
{ |
||||
|
ToolbarItemRenders = new List<RenderFragment>(); |
||||
|
} |
||||
|
|
||||
|
protected async override Task OnParametersSetAsync() |
||||
|
{ |
||||
|
await base.OnParametersSetAsync(); |
||||
|
if (Toolbar != null) |
||||
|
{ |
||||
|
var toolbarItems = await PageToolbarManager.GetItemsAsync(Toolbar); |
||||
|
|
||||
|
if (!ShouldRenderToolbarItems(toolbarItems)) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
ToolbarItemRenders.Clear(); |
||||
|
|
||||
|
if (!Options.Value.RenderToolbar) |
||||
|
{ |
||||
|
PageLayout.ToolbarItems.Clear(); |
||||
|
foreach (var item in toolbarItems) |
||||
|
{ |
||||
|
PageLayout.ToolbarItems.Add(item); |
||||
|
} |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
foreach (var item in toolbarItems) |
||||
|
{ |
||||
|
var sequence = 0; |
||||
|
ToolbarItemRenders.Add(builder => |
||||
|
{ |
||||
|
builder.OpenComponent(sequence, item.ComponentType); |
||||
|
if (item.Arguments != null) |
||||
|
{ |
||||
|
foreach (var argument in item.Arguments) |
||||
|
{ |
||||
|
sequence++; |
||||
|
builder.AddAttribute(sequence, argument.Key, argument.Value); |
||||
|
} |
||||
|
} |
||||
|
builder.CloseComponent(); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
protected virtual bool ShouldRenderToolbarItems(PageToolbarItem[] items) |
||||
|
{ |
||||
|
if (items.Length != PageLayout.ToolbarItems.Count) |
||||
|
{ |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
return items.Where((t, i) => t.ComponentType != PageLayout.ToolbarItems[i].ComponentType).Any(); |
||||
|
} |
||||
|
|
||||
|
protected async override Task OnInitializedAsync() |
||||
|
{ |
||||
|
await base.OnInitializedAsync(); |
||||
|
} |
||||
|
|
||||
|
public void Dispose() |
||||
|
{ |
||||
|
PageLayout.Reset(); |
||||
|
ToolbarItemRenders.Clear(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,36 @@ |
|||||
|
using Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor; |
||||
|
using Volo.Abp.AspNetCore.Components.WebAssembly.Theming.Bundling; |
||||
|
using Volo.Abp.AspNetCore.Components.WebAssembly.Theming.MudBlazor.Bundling; |
||||
|
using Volo.Abp.AspNetCore.Components.WebAssembly; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Components.WebAssembly.Theming.MudBlazor; |
||||
|
|
||||
|
[DependsOn( |
||||
|
typeof(AbpAspNetCoreComponentsWebAssemblyThemingBundlingModule), |
||||
|
typeof(AbpAspNetCoreComponentsWebThemingMudBlazorModule), |
||||
|
typeof(AbpAspNetCoreComponentsWebAssemblyModule) |
||||
|
)] |
||||
|
public class AbpAspNetCoreComponentsWebAssemblyThemingMudBlazorModule : AbpModule |
||||
|
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
Configure<AbpBundlingOptions>(options => |
||||
|
{ |
||||
|
options |
||||
|
.StyleBundles |
||||
|
.Add(BlazorWebAssemblyStandardBundles.Styles.Global, bundle => |
||||
|
{ |
||||
|
bundle.AddContributors(typeof(BlazorWebAssemblyMudBlazorStyleContributor)); |
||||
|
}); |
||||
|
|
||||
|
options |
||||
|
.ScriptBundles |
||||
|
.Add(BlazorWebAssemblyStandardBundles.Scripts.Global, bundle => |
||||
|
{ |
||||
|
bundle.AddContributors(typeof(BlazorWebAssemblyMudBlazorScriptContributor)); |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,17 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Components.WebAssembly.Theming.MudBlazor.Bundling; |
||||
|
|
||||
|
public class BlazorWebAssemblyMudBlazorScriptContributor : BundleContributor |
||||
|
{ |
||||
|
public override void ConfigureBundle(BundleConfigurationContext context) |
||||
|
{ |
||||
|
context.Files.AddIfNotContains("_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js"); |
||||
|
//TODO@MudBlazor: Do we need this script, check ?
|
||||
|
context.Files.AddIfNotContains("_content/MudBlazor/MudBlazor.min.js"); |
||||
|
context.Files.AddIfNotContains("_content/Volo.Abp.AspNetCore.Components.Web/libs/abp/js/abp.js"); |
||||
|
context.Files.AddIfNotContains("_content/Volo.Abp.AspNetCore.Components.Web/libs/abp/js/lang-utils.js"); |
||||
|
context.Files.AddIfNotContains("_content/Volo.Abp.AspNetCore.Components.Web/libs/abp/js/authentication-state-listener.js"); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Components.WebAssembly.Theming.MudBlazor.Bundling; |
||||
|
|
||||
|
public class BlazorWebAssemblyMudBlazorStyleContributor : BundleContributor |
||||
|
{ |
||||
|
public override void ConfigureBundle(BundleConfigurationContext context) |
||||
|
{ |
||||
|
//TODO@MudBlazor: Do we need this public font ?
|
||||
|
context.Files.AddIfNotContains("https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"); |
||||
|
context.Files.AddIfNotContains("_content/MudBlazor/MudBlazor.min.css"); |
||||
|
context.Files.AddIfNotContains("_content/Volo.Abp.AspNetCore.Components.Web/libs/abp/css/abp.css"); |
||||
|
context.Files.AddIfNotContains("_content/Volo.Abp.MudBlazorUI/volo.abp.mudblazorui.css"); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,18 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk.Razor"> |
||||
|
|
||||
|
<Import Project="..\..\..\configureawait.props" /> |
||||
|
<Import Project="..\..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>net10.0</TargetFramework> |
||||
|
<Nullable>enable</Nullable> |
||||
|
<WarningsAsErrors>Nullable</WarningsAsErrors> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\Volo.Abp.AspNetCore.Components.WebAssembly.Theming.Bundling\Volo.Abp.AspNetCore.Components.WebAssembly.Theming.Bundling.csproj" /> |
||||
|
<ProjectReference Include="..\Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor\Volo.Abp.AspNetCore.Components.Web.Theming.MudBlazor.csproj" /> |
||||
|
<ProjectReference Include="..\Volo.Abp.AspNetCore.Components.WebAssembly\Volo.Abp.AspNetCore.Components.WebAssembly.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
Loading…
Reference in new issue