Add blazor & MVC Support (#602)

* Add initial code for Razor pages support

* Remove finalizer

* Try fully loading blazor

This is most likely entirely broken because of a rebase now

* UseSptBlazor after app.Use

* Fix up StaticWebAsset loading, add MudBlazor

* Implement page

* Update comment

* Replaced existing status page with razor

* Track background video in LFS

* Update attributes

* Improved status page theming

* Fix up wwwroot publish folder to SPT_Data/wwwroot

* Added name to page

* Remove unnecessary code

* Begin fixing up MVC & Blazor for modding

* Update TestMod

* Cleanup todo

* Further work out mod support

* Re-order initialization and use logger

* Rename library to SPTarkov.Server.Web

---------

Co-authored-by: Chomp <dev@dev.sp-tarkov.com>
Co-authored-by: Chomp <27521899+chompDev@users.noreply.github.com>
This commit is contained in:
Jesse
2025-10-02 21:03:27 +02:00
committed by GitHub
parent cf29c7bde3
commit 687b4f7a49
23 changed files with 820 additions and 73 deletions
@@ -0,0 +1,9 @@
@page "/test/page"
<h3>TestModPage</h3>
<img src="/TestMod/chomp.jpg" alt="Chomp!" />
@code {
}
@@ -0,0 +1,12 @@
using Microsoft.AspNetCore.Mvc;
namespace TestMod.Controllers;
public class TestController : Controller
{
[HttpGet("/test/ping")]
public IActionResult Ping()
{
return Content("Pong from MVC!");
}
}
+4 -1
View File
@@ -2,11 +2,12 @@
using SPTarkov.Server.Core.DI;
using SPTarkov.Server.Core.Models.Spt.Mod;
using SPTarkov.Server.Core.Models.Utils;
using SPTarkov.Server.Web;
using Version = SemanticVersioning.Version;
namespace TestMod;
public record TestModMetadata : AbstractModMetadata
public record TestModMetadata : AbstractModMetadata, IModWebMetadata
{
public override string ModGuid { get; init; } = "com.sp-tarkov.test-mod";
public override string Name { get; init; } = "test-mod";
@@ -26,6 +27,8 @@ public class TestMod(ISptLogger<TestMod> logger) : IOnLoad
{
public Task OnLoad()
{
logger.Info("Test mod loaded!");
return Task.CompletedTask;
}
}
+15 -7
View File
@@ -1,8 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\Build.props" />
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<AssemblyName>TestMod2</AssemblyName>
<AssemblyName>TestMod</AssemblyName>
<OutputType>Library</OutputType>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\Libraries\SPTarkov.Common\SPTarkov.Common.csproj" />
@@ -10,20 +11,27 @@
<ProjectReference Include="..\..\Libraries\SPTarkov.Reflection\SPTarkov.Reflection.csproj" />
<ProjectReference Include="..\..\Libraries\SPTarkov.Server.Assets\SPTarkov.Server.Assets.csproj" />
<ProjectReference Include="..\..\Libraries\SPTarkov.Server.Core\SPTarkov.Server.Core.csproj" />
<ProjectReference Include="..\..\Libraries\SPTarkov.Server.Web\SPTarkov.Server.Web.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<Target Name="CopyToServer" AfterTargets="PostBuildEvent">
<ItemGroup>
<OutputDLL Include="$(ProjectDir)$(OutDir)$(TargetName).dll" />
<Resources Include="$(ProjectDir)Resources\**\*.*" />
<WebAssets Include="$(ProjectDir)wwwroot\**\*.*" />
</ItemGroup>
<!-- Copies the output dll -->
<Copy
SourceFiles="@(OutputDLL);"
DestinationFolder="$(SolutionDir)\SPTarkov.Server\bin\$(Configuration)\net9.0\user\mods\$(TargetName)"
/>
<Copy SourceFiles="@(OutputDLL);" DestinationFolder="$(SolutionDir)\SPTarkov.Server\bin\$(Configuration)\net9.0\user\mods\TestMod" />
<Copy
SourceFiles="@(Resources);"
DestinationFolder="$(SolutionDir)\SPTarkov.Server\bin\$(Configuration)\net9.0\user\mods\$(TargetName)\Resources\%(RecursiveDir)"
DestinationFolder="$(SolutionDir)\SPTarkov.Server\bin\$(Configuration)\net9.0\user\mods\TestMod\Resources\%(RecursiveDir)"
/>
<!-- Copy the wwwroot folder -->
<Copy
SourceFiles="@(WebAssets)"
DestinationFolder="$(SolutionDir)\SPTarkov.Server\bin\$(Configuration)\net9.0\user\mods\TestMod\wwwroot\%(RecursiveDir)"
/>
</Target>
</Project>
Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB