Added a simple web api abstraction method
This commit is contained in:
23
src/HopFrame.Web/Components/App.razor
Normal file
23
src/HopFrame.Web/Components/App.razor
Normal file
@@ -0,0 +1,23 @@
|
||||
@using HopFrame.Web.Components.Pages
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<base href="/"/>
|
||||
<ImportMap/>
|
||||
<HeadOutlet/>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<Router AppAssembly="typeof(HopFrameHome).Assembly">
|
||||
<Found Context="routeData">
|
||||
<RouteView RouteData="routeData"/>
|
||||
</Found>
|
||||
</Router>
|
||||
<script src="_framework/blazor.web.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
<link rel="stylesheet" type='text/css' href="https://cdn.jsdelivr.net/gh/devicons/devicon@latest/devicon.min.css" />
|
||||
<link rel="stylesheet" href="@Assets["_content/HopFrame.Web/hopframe.css"]"/>
|
||||
<link rel="stylesheet" href="@Assets["_content/HopFrame.Web/HopFrame.Web.bundle.scp.css"]"/>
|
||||
<link rel="stylesheet" href="@Assets["_content/Microsoft.FluentUI.AspNetCore.Components/css/reboot.css"]"/>
|
||||
<link rel="stylesheet" href="@Assets["_content/Microsoft.FluentUI.AspNetCore.Components/Microsoft.FluentUI.AspNetCore.Components.bundle.scp.css"]">
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using HopFrame.Core;
|
||||
using HopFrame.Core.Config;
|
||||
using HopFrame.Web.Components;
|
||||
using HopFrame.Web.Components.Pages;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.FluentUI.AspNetCore.Components;
|
||||
@@ -15,11 +16,12 @@ public static class ServiceCollectionExtensions {
|
||||
/// <param name="services">The service collection to add the services to</param>
|
||||
/// <param name="configurator">The configurator used to build the HopFrame configuration</param>
|
||||
/// <param name="fluentUiLibraryConfiguration">The configuration for the FluentUI components</param>
|
||||
/// <param name="addRazorComponents">Set this to false if you don't want to automatically configure razor components with interactive server components</param>
|
||||
/// <returns>The same service collection that is passed in</returns>
|
||||
public static IServiceCollection AddHopFrame(this IServiceCollection services, Action<HopFrameConfigurator> configurator, LibraryConfiguration? fluentUiLibraryConfiguration = null) {
|
||||
public static IServiceCollection AddHopFrame(this IServiceCollection services, Action<HopFrameConfigurator> configurator, LibraryConfiguration? fluentUiLibraryConfiguration = null, bool addRazorComponents = true) {
|
||||
var config = new HopFrameConfig();
|
||||
configurator.Invoke(new HopFrameConfigurator(config));
|
||||
return AddHopFrame(services, config, fluentUiLibraryConfiguration);
|
||||
return AddHopFrame(services, config, fluentUiLibraryConfiguration, addRazorComponents);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -28,22 +30,46 @@ public static class ServiceCollectionExtensions {
|
||||
/// <param name="services">The service collection to add the services to</param>
|
||||
/// <param name="config">The config used for the HopFrame admin ui</param>
|
||||
/// <param name="fluentUiLibraryConfiguration">The configuration for the FluentUI components</param>
|
||||
/// <param name="addRazorComponents">Set this to false if you don't want to automatically configure razor components with interactive server components</param>
|
||||
/// <returns>The same service collection that is passed in</returns>
|
||||
public static IServiceCollection AddHopFrame(this IServiceCollection services, HopFrameConfig config, LibraryConfiguration? fluentUiLibraryConfiguration = null) {
|
||||
public static IServiceCollection AddHopFrame(this IServiceCollection services, HopFrameConfig config, LibraryConfiguration? fluentUiLibraryConfiguration = null, bool addRazorComponents = true) {
|
||||
services.AddSingleton(config);
|
||||
services.AddHopFrameServices();
|
||||
services.AddFluentUIComponents(fluentUiLibraryConfiguration);
|
||||
|
||||
if (addRazorComponents) {
|
||||
services.AddRazorComponents()
|
||||
.AddInteractiveServerComponents();
|
||||
}
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Maps the HopFrame admin ui endpoints
|
||||
/// Adds the HopFrame admin ui endpoints
|
||||
/// </summary>
|
||||
/// <seealso cref="AddHopFramePages"/>
|
||||
[Obsolete($"Use '{nameof(AddHopFramePages)}' instead")]
|
||||
public static RazorComponentsEndpointConventionBuilder MapHopFramePages(this RazorComponentsEndpointConventionBuilder builder) {
|
||||
return AddHopFramePages(builder);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the HopFrame admin ui endpoints
|
||||
/// </summary>
|
||||
public static RazorComponentsEndpointConventionBuilder AddHopFramePages(this RazorComponentsEndpointConventionBuilder builder) {
|
||||
builder
|
||||
.AddInteractiveServerRenderMode()
|
||||
.AddAdditionalAssemblies(typeof(HopFrameHome).Assembly);
|
||||
return builder;
|
||||
}
|
||||
|
||||
public static WebApplication MapHopFrame(this WebApplication app) {
|
||||
app.UseAntiforgery();
|
||||
app.MapStaticAssets();
|
||||
app.MapRazorComponents<App>()
|
||||
.AddInteractiveServerRenderMode();
|
||||
return app;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user