🧱 Mixed page infra

This commit is contained in:
2025-07-16 13:00:10 +08:00
parent cd4af2e26f
commit e4dcf2517a
10 changed files with 95 additions and 12 deletions

View File

@@ -1,13 +1,14 @@
<!DOCTYPE html>
<html lang="">
<head>
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Solarpass</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
%%APP_DATA%%
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>

View File

@@ -9,10 +9,11 @@
<p class="mt-4 opacity-75 text-xs">
<span v-if="version == null">Loading...</span>
<span v-else
>v{{ version.version }} @ {{ version.commit.substring(0, 6) }}
{{ version.updatedAt }}</span
>
<span v-else>
v{{ version.version }} @
{{ version.commit.substring(0, 6) }}
{{ version.updatedAt }}
</span>
</p>
</n-card>
</section>

View File

@@ -0,0 +1,24 @@
using DysonNetwork.Shared.Data;
using DysonNetwork.Shared.PageData;
namespace DysonNetwork.Pass.Pages.Data;
public class VersionPageData : IPageDataProvider
{
public bool CanHandlePath(PathString path) => true;
public Task<IDictionary<string, object?>> GetAppDataAsync(HttpContext context)
{
var versionData = new AppVersion
{
Version = ThisAssembly.AssemblyVersion,
Commit = ThisAssembly.GitCommitId,
UpdateDate = ThisAssembly.GitCommitDate
};
var result = typeof(AppVersion).GetProperties()
.ToDictionary(property => property.Name, property => property.GetValue(versionData));
return Task.FromResult<IDictionary<string, object?>>(result);
}
}

View File

@@ -1,6 +1,9 @@
using System.Text.Json;
using DysonNetwork.Pass;
using DysonNetwork.Pass.Pages.Data;
using DysonNetwork.Pass.Startup;
using DysonNetwork.Shared.Http;
using DysonNetwork.Shared.PageData;
using DysonNetwork.Shared.Registry;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.FileProviders;
@@ -30,6 +33,8 @@ builder.Services.AddAppBusinessServices(builder.Configuration);
// Add scheduled jobs
builder.Services.AddAppScheduledJobs();
builder.Services.AddTransient<IPageDataProvider, VersionPageData>();
var app = builder.Build();
// Run database migrations
@@ -42,6 +47,8 @@ using (var scope = app.Services.CreateScope())
// Configure application middleware pipeline
app.ConfigureAppMiddleware(builder.Configuration, builder.Environment.ContentRootPath);
app.MapPages(Path.Combine(builder.Environment.WebRootPath, "dist", "index.html"));
// Configure gRPC
app.ConfigureGrpcServices();

View File

@@ -46,8 +46,6 @@ public static class ApplicationConfiguration
app.MapControllers().RequireRateLimiting("fixed");
app.MapFallbackToFile("dist/index.html");
return app;
}