Files
yes.blog/Yes.Blog/Areas/Install/Pages/Index.cshtml.cs
2025-05-10 00:11:07 +08:00

34 lines
1.0 KiB
C#

namespace Yes.Blog.Areas.Install.Pages
{
public class IndexModel(IOptionsMonitor<BlogSettings> options, IWebHostEnvironment env, IFileService fileService) : PageModel
{
public IActionResult OnGet()
{
var defaultTheme = Path.Combine(env.ContentRootPath, "files", "themes", "default");
var dir = new DirectoryInfo(defaultTheme);
if (!dir.Exists)
{
Directory.CreateDirectory(defaultTheme);
}
if (dir.GetFiles().Length == 0)
{
var sourcePath = Path.Combine(env.WebRootPath, "defaulttheme");
fileService.CopyFolder(sourcePath, defaultTheme);
}
var settings = options.CurrentValue;
if (!string.IsNullOrEmpty(settings.ConnectionString) && !string.IsNullOrEmpty(settings.DatabaseName) && !string.IsNullOrEmpty(settings.DatabaseType))
{
return Redirect("/");
}
return Page();
}
}
}