Skip to content

Commit

Permalink
Introduce AbpBlazorRouterOptions and move App.razor to the Volo.Abp.A…
Browse files Browse the repository at this point in the history
…spNetCore.Components.WebAssembly.BasicTheme
  • Loading branch information
hikalkan committed Sep 13, 2020
1 parent fde73f8 commit 7d1a705
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Volo.Abp.AspNetCore.Components.WebAssembly.Theming;
using Volo.Abp.AspNetCore.Components.WebAssembly.Theming.Routing;
using Volo.Abp.Modularity;

namespace Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme
Expand All @@ -8,6 +9,12 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme
)]
public class AbpAspNetCoreComponentsWebAssemblyBasicThemeModule : AbpModule
{

public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpRouterOptions>(options =>
{
options.AdditionalAssemblies.Add(typeof(AbpAspNetCoreComponentsWebAssemblyBasicThemeModule).Assembly);
});
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@using Volo.Abp.Identity.Blazor
@using Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme
@using Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme.Themes.Basic
@using Volo.Abp.AspNetCore.Components.WebAssembly.Theming.Routing
@using Microsoft.Extensions.Options
@inject IOptions<AbpRouterOptions> RouterOptions
<CascadingAuthenticationState>
<Router AppAssembly="@typeof(Program).Assembly"
AdditionalAssemblies="new []{ typeof(AbpIdentityBlazorModule).Assembly, typeof(AbpAspNetCoreComponentsWebAssemblyBasicThemeModule).Assembly }">
<Router AppAssembly="RouterOptions.Value.AppAssembly"
AdditionalAssemblies="RouterOptions.Value.AdditionalAssemblies">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
<NotAuthorized>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Reflection;

namespace Volo.Abp.AspNetCore.Components.WebAssembly.Theming.Routing
{
public class AbpRouterOptions
{
public Assembly AppAssembly { get; set; }

public RouterAssemblyList AdditionalAssemblies { get; }

public AbpRouterOptions()
{
AdditionalAssemblies = new RouterAssemblyList();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Collections.Generic;
using System.Reflection;

namespace Volo.Abp.AspNetCore.Components.WebAssembly.Theming.Routing
{
public class RouterAssemblyList : List<Assembly>
{

}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AspNetCore.Components.WebAssembly.Theming.Routing;
using Volo.Abp.AutoMapper;
using Volo.Abp.Modularity;
using Volo.Abp.PermissionManagement.Blazor;
Expand Down Expand Up @@ -26,6 +27,11 @@ public override void ConfigureServices(ServiceConfigurationContext context)
{
options.MenuContributors.Add(new AbpIdentityWebMainMenuContributor());
});

Configure<AbpRouterOptions>(options =>
{
options.AdditionalAssemblies.Add(typeof(AbpIdentityBlazorModule).Assembly);
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
using Volo.Abp;
using Volo.Abp.Autofac;
using Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme;
using Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme.Themes.Basic;
using Volo.Abp.AspNetCore.Components.WebAssembly.Theming.Routing;
using Volo.Abp.Modularity;
using Volo.Abp.UI.Navigation;
using Volo.Abp.Identity.Blazor;
Expand All @@ -31,10 +33,19 @@ public override void ConfigureServices(ServiceConfigurationContext context)
ConfigureAuthentication(builder);
ConfigureHttpClient(context, environment);
ConfigureBlazorise(context);
ConfigureRouter(context);
ConfigureUI(builder);
ConfigureMenu(context);
}

private void ConfigureRouter(ServiceConfigurationContext context)
{
Configure<AbpRouterOptions>(options =>
{
options.AppAssembly = typeof(MyProjectNameBlazorModule).Assembly;
});
}

private void ConfigureMenu(ServiceConfigurationContext context)
{
Configure<AbpNavigationOptions>(options =>
Expand Down

0 comments on commit 7d1a705

Please sign in to comment.