Introduce BandLayoutService and shared models to manage grid band layouts across components. Refactor CatalogsGrid and MassDataGrid to use the new service, removing duplicated layout logic. Update _Imports.razor and register the service in Program.cs for improved maintainability and code reuse.
62 lines
1.7 KiB
C#
62 lines
1.7 KiB
C#
using DbFirst.BlazorWebApp.Components;
|
|
using DbFirst.BlazorWebApp.Services;
|
|
using DevExpress.Blazor;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
builder.Services.AddRazorComponents()
|
|
.AddInteractiveServerComponents();
|
|
|
|
builder.Services.AddDevExpressBlazor(options => options.BootstrapVersion = BootstrapVersion.v5);
|
|
builder.Services.AddScoped<ThemeState>();
|
|
builder.Services.AddScoped<BandLayoutService>();
|
|
|
|
var apiBaseUrl = builder.Configuration["ApiBaseUrl"];
|
|
if (!string.IsNullOrWhiteSpace(apiBaseUrl))
|
|
{
|
|
builder.Services.AddHttpClient<CatalogApiClient>(client =>
|
|
{
|
|
client.BaseAddress = new Uri(apiBaseUrl);
|
|
});
|
|
builder.Services.AddHttpClient<DashboardApiClient>(client =>
|
|
{
|
|
client.BaseAddress = new Uri(apiBaseUrl);
|
|
});
|
|
builder.Services.AddHttpClient<MassDataApiClient>(client =>
|
|
{
|
|
client.BaseAddress = new Uri(apiBaseUrl);
|
|
});
|
|
builder.Services.AddHttpClient<LayoutApiClient>(client =>
|
|
{
|
|
client.BaseAddress = new Uri(apiBaseUrl);
|
|
});
|
|
}
|
|
else
|
|
{
|
|
builder.Services.AddHttpClient<CatalogApiClient>();
|
|
builder.Services.AddHttpClient<DashboardApiClient>();
|
|
builder.Services.AddHttpClient<MassDataApiClient>();
|
|
builder.Services.AddHttpClient<LayoutApiClient>();
|
|
}
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (!app.Environment.IsDevelopment())
|
|
{
|
|
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
|
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
|
app.UseHsts();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseStaticFiles();
|
|
app.UseAntiforgery();
|
|
|
|
app.MapRazorComponents<App>()
|
|
.AddInteractiveServerRenderMode();
|
|
|
|
app.Run();
|