Skip to content

Commit 6d94cf9

Browse files
committed
Improved template
1 parent 521e7c9 commit 6d94cf9

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

‎src/ElectronNET.Templates/templates/blazor/.template.config/template.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
}
3131
],
3232
"replaces": "net8.0",
33-
"defaultValue": "net8.0"
33+
"defaultValue": "net10.0"
3434
},
3535
"ElectronVersion": {
3636
"type": "parameter",

‎src/ElectronNET.Templates/templates/blazor/Components/App.razor‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
<meta charset="utf-8" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<base href="/" />
8+
<ResourcePreloader />
89
<link rel="stylesheet" href="app.css" />
10+
<ImportMap />
911
<title>ElectronBlazorApp</title>
1012
<HeadOutlet />
1113
</head>

‎src/ElectronNET.Templates/templates/blazor/Program.cs‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,30 @@
11
using ElectronNET.API;
22
using ElectronNET.API.Entities;
3+
using ElectronNET.AspNet.Middleware;
4+
using ElectronNET.AspNet.Services;
35

46
var builder = WebApplication.CreateBuilder(args);
57

68
builder.Services.AddRazorComponents()
79
.AddInteractiveServerComponents();
810

11+
builder.Services.AddSingleton<IElectronAuthenticationService, ElectronAuthenticationService>();
12+
13+
builder.Services.AddElectron();
14+
915
// Starts the Electron shell and invokes ElectronAppReady once it is up.
1016
builder.UseElectron(args, ElectronAppReady);
1117

1218
var app = builder.Build();
1319

20+
app.UseMiddleware<ElectronAuthenticationMiddleware>();
21+
app.UseRouting();
22+
23+
if (!app.Environment.IsDevelopment())
24+
{
25+
app.UseExceptionHandler("/Error", createScopeForErrors: true);
26+
}
27+
1428
app.UseStaticFiles();
1529
app.UseAntiforgery();
1630

@@ -24,6 +38,7 @@ static async Task ElectronAppReady()
2438
{
2539
var window = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions
2640
{
41+
IsRunningBlazor = true,
2742
Width = 1152,
2843
Height = 940,
2944
Show = false,

0 commit comments

Comments
 (0)