Add editable portal page content
This commit is contained in:
+33
-1
@@ -32,6 +32,7 @@ public sealed class MainForm : Form
|
||||
private Button _btnImport = null!;
|
||||
private Button _btnRefreshStatus = null!;
|
||||
private Button _btnSavePortal = null!;
|
||||
private Button _btnEditPortalContent = null!;
|
||||
|
||||
private string? _selectedDomain;
|
||||
private bool _closingBackupCreated;
|
||||
@@ -133,6 +134,8 @@ public sealed class MainForm : Form
|
||||
_btnRefreshStatus.Click += (s, e) => RefreshStatus();
|
||||
_btnSavePortal = CreateButton("保存入口设置", 96);
|
||||
_btnSavePortal.Click += async (s, e) => await SavePortalSettingsAsync();
|
||||
_btnEditPortalContent = CreateButton("主页内容", 96);
|
||||
_btnEditPortalContent.Click += (s, e) => EditPortalContent();
|
||||
|
||||
panel.Controls.Add(CreateLabel("配置文件"), 0, 0);
|
||||
panel.Controls.Add(_txtConfigPath, 1, 0);
|
||||
@@ -153,7 +156,7 @@ public sealed class MainForm : Form
|
||||
panel.Controls.Add(_lblStatus, 1, 3);
|
||||
panel.SetColumnSpan(_lblStatus, 2);
|
||||
panel.Controls.Add(_btnRefreshStatus, 3, 3);
|
||||
panel.SetColumnSpan(_btnRefreshStatus, 2);
|
||||
panel.Controls.Add(_btnEditPortalContent, 4, 3);
|
||||
return panel;
|
||||
}
|
||||
|
||||
@@ -467,6 +470,32 @@ public sealed class MainForm : Form
|
||||
}
|
||||
}
|
||||
|
||||
private void EditPortalContent()
|
||||
{
|
||||
using var dialog = new PortalContentDialog(_manager.PortalContent);
|
||||
if (dialog.ShowDialog(this) != DialogResult.OK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_manager.UpdatePortalContent(
|
||||
dialog.SiteName,
|
||||
dialog.Headline,
|
||||
dialog.Introduction);
|
||||
MessageBox.Show(
|
||||
"主页内容已保存并生成。刷新浏览器即可看到新内容。",
|
||||
"NginxMan",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "NginxMan", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshStatus()
|
||||
{
|
||||
if (!HasConfiguredNginxExe())
|
||||
@@ -481,6 +510,7 @@ public sealed class MainForm : Form
|
||||
_btnStop.Enabled = false;
|
||||
_btnBackup.Enabled = true;
|
||||
_btnImport.Enabled = true;
|
||||
_btnEditPortalContent.Enabled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -495,6 +525,7 @@ public sealed class MainForm : Form
|
||||
_btnStop.Enabled = isRunning;
|
||||
_btnBackup.Enabled = true;
|
||||
_btnImport.Enabled = true;
|
||||
_btnEditPortalContent.Enabled = true;
|
||||
}
|
||||
|
||||
private async Task RunNginxAsync(string actionName, Func<int> action, bool expectedRunning)
|
||||
@@ -546,6 +577,7 @@ public sealed class MainForm : Form
|
||||
_btnStop.Enabled = enabled;
|
||||
_btnBackup.Enabled = enabled;
|
||||
_btnImport.Enabled = enabled;
|
||||
_btnEditPortalContent.Enabled = enabled;
|
||||
_btnRefreshStatus.Enabled = enabled;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user