This commit is contained in:
2025-05-07 16:33:57 +08:00
parent ab7ae290f0
commit 9a9fd29e1e
5 changed files with 15 additions and 2 deletions

View File

@@ -13,6 +13,7 @@
public class InstallCommandHandler(
IConnectionStringProvider connectionStringProvider,
IHttpContextAccessor accessor,
IMigratorProvider migratorProvider,
IWebHostEnvironment env,
IConfigurationService configurationService,
@@ -25,6 +26,7 @@
private readonly IConfigurationService _configurationService = configurationService;
private readonly IWebHostEnvironment _env = env;
private readonly IFileService _fileService = fileService;
private readonly IHttpContextAccessor _accessor = accessor;
public async Task<InstallCommandResponse> Handle(InstallCommand request, CancellationToken cancellationToken)
{
if (!string.IsNullOrEmpty(_settings.ConnectionString) && !string.IsNullOrEmpty(_settings.DatabaseType) && !string.IsNullOrEmpty(_settings.DatabaseName))
@@ -50,6 +52,7 @@
var settings = new BlogSettings();
settings.Url = _accessor.HttpContext?.GetCurrentDomain() ?? "";
settings.DatabaseName = databaseName;
settings.DatabaseType = databaseType.ToString();

View File

@@ -12,6 +12,7 @@
<ItemGroup>
<PackageReference Include="Mapster.DependencyInjection" Version="1.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Qiniu" Version="8.7.0" />
<PackageReference Include="MediatR" Version="12.5.0" />
</ItemGroup>

View File

@@ -44,6 +44,7 @@
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="12.0.0" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.4" />
<PackageReference Include="MinimalApis.LiquidViews" Version="2.24.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Scalar.AspNetCore" Version="2.2.7" />
</ItemGroup>

View File

@@ -11,9 +11,9 @@
public string Name { get; set; } = "我的博客";
public string Logo { get; set; } = "https://img.yescent.com/FosQ9ua_nPhlNQwYgJwUXi9MFsB5.jpg";
public string Logo { get; set; } = "";
public string Url { get; set; } = "https://yescent.com";
public string Url { get; set; } = "https://blog.yescent.com";
public int PageSizeOfHomepage { get; set; } = 5;

View File

@@ -17,5 +17,13 @@ namespace Yes.Domain.Core.Extensions
}
return ipAddress ?? "";
}
public static string GetCurrentDomain(this HttpContext httpContext)
{
var request = httpContext.Request;
var host = request.Headers["X-Forwarded-Host"].FirstOrDefault() ?? request.Host.Host;
var protocol = request.Headers["X-Forwarded-Proto"].FirstOrDefault() ?? request.Scheme;
return $"{protocol}://{host}";
}
}
}