Use the ABP CLI to create a new project:
abp new BookStoreWebApp -u blazor-webapp -t appFor more information, see the ABP official documentation to learn about the ABP framework.
Replace LeptonXLiteTheme or BasicTheme with FluentBlazorTheme packages and remove Blazorise packages.
Refer to Simple.Blazor.csproj and Simple.Blazor.Client.csproj.
You can still use MVC; do not remove MVC-related packages.
If you want to use MVC for the login page and account-related pages, do not use the
Zyknow.Abp.Account.Blazor.FluentDesignUIpackages.
Open _Imports.razor and add the following:
@using Microsoft.FluentUI.AspNetCore.Components
@using Zyknow.Abp.FluentDesignUI
@using Zyknow.Abp.FluentDesignUI.Components
@using Zyknow.Abp.AspnetCore.Components.Web.FluentDesignTheme.Layout
@using Zyknow.Abp.AspnetCore.Components.Web.FluentDesignTheme.BundlingOpen BookStoreWebAppBlazorModule and BookStoreWebAppBlazorClientModule and make the following changes:
- Remove the
ConfigureBlazorisemethod. - Fix incorrect using namespaces.
- Update module dependencies:
- For example, replace
AbpTenantManagementBlazorWebAssemblyModulewithAbpTenantManagementBlazorWebAssemblyFluentDesignModule.
- For example, replace
Open Routes.razor and replace it with the following:
@using Microsoft.Extensions.Options
@using Zyknow.Abp.AspnetCore.Components.Web.FluentDesignTheme.Routing
@using Zyknow.Abp.AspnetCore.Components.Web.FluentDesignTheme.Themes.FluentDesignTheme
@using BlazorPro.BlazorSize
@inject IOptions<AbpRouterOptions> RouterOptions
<MediaQueryList>
<Router AppAssembly="typeof(Program).Assembly" AdditionalAssemblies="RouterOptions.Value.AdditionalAssemblies">
<Found Context="routeData">
<AuthorizeRouteView RouteData="routeData" DefaultLayout="typeof(DefaultLayout)">
<NotAuthorized>
<RedirectToLogin/>
</NotAuthorized>
</AuthorizeRouteView>
</Found>
</Router>
</MediaQueryList>Change AbpStyles and AbpScript to BlazorFluentDesignThemeBundles.
If you are using a WebApp project and have included Zyknow.Abp.Account.Blazor.Server.FluentDesignUI, you need to add extra code in App.razor:
-
Add the following code:
@code{ [CascadingParameter] private HttpContext HttpContext { get; set; } = default!; [Inject] protected IOptions<AbpFluentDesignThemeOptions> ThemeOptions { get; set; } private IComponentRenderMode? PageRenderMode => // account/* must be handled by the server HttpContext.Request.Path.StartsWithSegments("/Account") ? new InteractiveServerRenderMode() : (HttpContext.AcceptsInteractiveRouting() ? GetDefaultRenderMode() : null); protected IComponentRenderMode GetDefaultRenderMode() { var renderMode = HttpContext.Request.Cookies.FirstOrDefault(x => x.Key == "RenderMode"); var prerenderStr = HttpContext.Request.Cookies.FirstOrDefault(x => x.Key == "Prerender"); var prerender = prerenderStr.Value.IsNullOrEmpty() || bool.TryParse(prerenderStr.Value, out var result) && result; if (renderMode.Value == "InteractiveAutoRenderMode") { return new InteractiveAutoRenderMode(prerender); } if (renderMode.Value == "InteractiveServerRenderMode") { return new InteractiveServerRenderMode(prerender); } if (renderMode.Value == "InteractiveWebAssemblyRenderMode") { return new InteractiveWebAssemblyRenderMode(prerender); } // default to InteractiveAutoRenderMode return new InteractiveAutoRenderMode(prerender); } }
-
Replace render mode:
<HeadOutlet @rendermode="@PageRenderMode"/> ... <Routes @rendermode="InteractiveAuto"/>