1
This commit is contained in:
33
Yes.Blog/Areas/Install/Pages/Index.cshtml.cs
Normal file
33
Yes.Blog/Areas/Install/Pages/Index.cshtml.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
|
||||
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, "themes", "default");
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user