diff --git a/DysonNetwork.Pass/Client/index.html b/DysonNetwork.Pass/Client/index.html
index a5ca9ee..08ed20b 100644
--- a/DysonNetwork.Pass/Client/index.html
+++ b/DysonNetwork.Pass/Client/index.html
@@ -1,13 +1,14 @@
-
+
Solarpass
-
-
-
-
-
+ %%APP_DATA%%
+
+
+
+
+
diff --git a/DysonNetwork.Pass/Client/src/views/authorize.vue b/DysonNetwork.Pass/Client/src/views/authorize.vue
new file mode 100644
index 0000000..e69de29
diff --git a/DysonNetwork.Pass/Client/src/views/index.vue b/DysonNetwork.Pass/Client/src/views/index.vue
index 7105546..c401745 100644
--- a/DysonNetwork.Pass/Client/src/views/index.vue
+++ b/DysonNetwork.Pass/Client/src/views/index.vue
@@ -9,10 +9,11 @@
Loading...
- v{{ version.version }} @ {{ version.commit.substring(0, 6) }}
- {{ version.updatedAt }}
+
+ v{{ version.version }} @
+ {{ version.commit.substring(0, 6) }}
+ {{ version.updatedAt }}
+
diff --git a/DysonNetwork.Pass/Client/src/views/login.vue b/DysonNetwork.Pass/Client/src/views/login.vue
new file mode 100644
index 0000000..e69de29
diff --git a/DysonNetwork.Pass/Pages/Data/VersionPageData.cs b/DysonNetwork.Pass/Pages/Data/VersionPageData.cs
new file mode 100644
index 0000000..dcc8600
--- /dev/null
+++ b/DysonNetwork.Pass/Pages/Data/VersionPageData.cs
@@ -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> 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>(result);
+ }
+}
\ No newline at end of file
diff --git a/DysonNetwork.Pass/Program.cs b/DysonNetwork.Pass/Program.cs
index 9dd6e86..e571f69 100644
--- a/DysonNetwork.Pass/Program.cs
+++ b/DysonNetwork.Pass/Program.cs
@@ -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();
+
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();
diff --git a/DysonNetwork.Pass/Startup/ApplicationConfiguration.cs b/DysonNetwork.Pass/Startup/ApplicationConfiguration.cs
index f7498da..da69c11 100644
--- a/DysonNetwork.Pass/Startup/ApplicationConfiguration.cs
+++ b/DysonNetwork.Pass/Startup/ApplicationConfiguration.cs
@@ -46,8 +46,6 @@ public static class ApplicationConfiguration
app.MapControllers().RequireRateLimiting("fixed");
- app.MapFallbackToFile("dist/index.html");
-
return app;
}
diff --git a/DysonNetwork.Shared/PageData/IPageDataProvider.cs b/DysonNetwork.Shared/PageData/IPageDataProvider.cs
new file mode 100644
index 0000000..aaacf89
--- /dev/null
+++ b/DysonNetwork.Shared/PageData/IPageDataProvider.cs
@@ -0,0 +1,9 @@
+using Microsoft.AspNetCore.Http;
+
+namespace DysonNetwork.Shared.PageData;
+
+public interface IPageDataProvider
+{
+ bool CanHandlePath(PathString path);
+ Task> GetAppDataAsync(HttpContext context);
+}
\ No newline at end of file
diff --git a/DysonNetwork.Shared/PageData/Startup.cs b/DysonNetwork.Shared/PageData/Startup.cs
new file mode 100644
index 0000000..8769d95
--- /dev/null
+++ b/DysonNetwork.Shared/PageData/Startup.cs
@@ -0,0 +1,42 @@
+using System.Text.Json;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Routing;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace DysonNetwork.Shared.PageData;
+
+public static class PageStartup
+{
+ public static WebApplication MapPages(this WebApplication app, string defaultFile)
+ {
+#pragma warning disable ASP0016
+ app.MapFallback(async context =>
+ {
+ var html = await File.ReadAllTextAsync(defaultFile);
+
+ using var scope = app.Services.CreateScope();
+ var providers = scope.ServiceProvider.GetServices();
+
+ var matches = providers
+ .Where(p => p.CanHandlePath(context.Request.Path))
+ .Select(p => p.GetAppDataAsync(context))
+ .ToList();
+ var results = await Task.WhenAll(matches);
+
+ var appData = new Dictionary();
+ foreach (var result in results)
+ foreach (var (key, value) in result)
+ appData[key] = value;
+
+ var json = JsonSerializer.Serialize(appData);
+ html = html.Replace("%%APP_DATA%%", $"");
+
+ context.Response.ContentType = "text/html";
+ await context.Response.WriteAsync(html);
+ });
+#pragma warning restore ASP0016
+
+ return app;
+ }
+}
\ No newline at end of file
diff --git a/DysonNetwork.sln.DotSettings.user b/DysonNetwork.sln.DotSettings.user
index d207423..5967b91 100644
--- a/DysonNetwork.sln.DotSettings.user
+++ b/DysonNetwork.sln.DotSettings.user
@@ -43,6 +43,7 @@
ForceIncluded
ForceIncluded
ForceIncluded
+ ForceIncluded
ForceIncluded
ForceIncluded
ForceIncluded