enter intro cutscene

This commit is contained in:
Naruse
2026-04-20 12:40:38 +08:00
parent 2826239284
commit 279da58dc1
81 changed files with 7279 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace MikuSB.SdkServer.Utils;
public class JsonStringToObjectConverter<T> : JsonConverter<T> where T : class
{
public override T? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
if (reader.TokenType != JsonTokenType.String)
return JsonSerializer.Deserialize<T>(ref reader, options);
var jsonString = reader.GetString();
return !string.IsNullOrEmpty(jsonString)
? JsonSerializer.Deserialize<T>(jsonString, options)
: null;
}
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
{
var json = JsonSerializer.Serialize(value, options);
writer.WriteStringValue(json);
}
}

View File

@@ -0,0 +1,34 @@
using Microsoft.AspNetCore.Http;
using MikuSB.Util;
namespace MikuSB.SdkServer.Utils;
public class RequestLoggingMiddleware(RequestDelegate next)
{
public async Task InvokeAsync(HttpContext context, Logger logger)
{
var request = context.Request;
var method = request.Method;
var path = request.Path + request.QueryString;
await next(context);
var statusCode = context.Response.StatusCode;
if (path.StartsWith("/report") || path.Contains("/log/") || path == "/alive")
return;
if (statusCode == 200)
{
logger.Info($"{method} {path} => {statusCode}");
}
else if (statusCode == 404)
{
logger.Warn($"{method} {path} => {statusCode}");
}
else
{
logger.Error($"{method} {path} => {statusCode}");
}
}
}