This commit is contained in:
2025-05-09 15:03:54 +08:00
parent 331b06e733
commit 7416a2dd12
336 changed files with 339 additions and 246095 deletions

View File

@@ -0,0 +1,32 @@
namespace Yes.Application.Admins.Themes
{
public record GetThemeFileQuery(string ThemeName, string FileName) : IRequest<GetThemeFileQueryResponse>;
public record GetThemeFileQueryResponse(
string Content
);
public class GetThemeFileQueryHandler(IOptionsMonitor<BlogSettings> options, IMapper mapper, IWebHostEnvironment env) : IRequestHandler<GetThemeFileQuery, GetThemeFileQueryResponse>
{
private readonly BlogSettings _settings = options.CurrentValue;
private readonly IMapper _mapper = mapper;
private readonly IWebHostEnvironment _env = env;
public async Task<GetThemeFileQueryResponse> Handle(GetThemeFileQuery request, CancellationToken cancellationToken)
{
var themeName = request.ThemeName;
var fileName = request.FileName;
var themes = new List<GetThemeFileQueryResponse>();
var filePath = Path.Combine(_env.ContentRootPath, "files", "themes", themeName, fileName);
var content = "";
if (File.Exists(filePath))
{
content = File.ReadAllText(filePath);
}
return new GetThemeFileQueryResponse(content);
}
}
}