- 根据触发器类型动态展示对应配置区域,减少无关字段干扰。 - 将单次、每日、每周、每月和生效时间范围改为日期选择器与时分秒下拉选择,避免手动输入时间格式。 - 为单次执行增加延后执行快捷设置,支持常用快捷按钮和自定义分钟、小时、天后执行。 - 移除开机自启设置、注册表写入逻辑和相关配置字段,降低对用户系统的影响。 - 同步优化部分任务状态、触发摘要和设置界面文案。
55 lines
1.5 KiB
C#
55 lines
1.5 KiB
C#
using System.Windows;
|
|
|
|
namespace OmniScheduler;
|
|
|
|
public partial class SettingsWindow : Window
|
|
{
|
|
private readonly AppSettings _settings;
|
|
|
|
private SettingsWindow(Window owner, AppSettings settings)
|
|
{
|
|
InitializeComponent();
|
|
Owner = owner;
|
|
_settings = settings;
|
|
UrlBox.Text = settings.OmniNotifyUrl;
|
|
RetentionDaysBox.Text = settings.LogRetentionDays.ToString();
|
|
MaxRecordsBox.Text = settings.MaxLogRecords.ToString();
|
|
}
|
|
|
|
public static bool Edit(Window owner, AppSettings settings)
|
|
{
|
|
var dialog = new SettingsWindow(owner, settings);
|
|
return dialog.ShowDialog() == true;
|
|
}
|
|
|
|
private void Save_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
ValidationText.Text = "";
|
|
if (!Uri.TryCreate(UrlBox.Text.Trim(), UriKind.Absolute, out _))
|
|
{
|
|
ValidationText.Text = "API 地址格式不正确";
|
|
return;
|
|
}
|
|
|
|
if (!int.TryParse(RetentionDaysBox.Text, out var days) || days < 1)
|
|
{
|
|
ValidationText.Text = "日志保留天数至少为 1";
|
|
return;
|
|
}
|
|
|
|
if (!int.TryParse(MaxRecordsBox.Text, out var max) || max < 100)
|
|
{
|
|
ValidationText.Text = "最大日志条数至少为 100";
|
|
return;
|
|
}
|
|
|
|
_settings.OmniNotifyUrl = UrlBox.Text.Trim();
|
|
_settings.LogRetentionDays = days;
|
|
_settings.MaxLogRecords = max;
|
|
DialogResult = true;
|
|
}
|
|
|
|
private void Cancel_Click(object sender, RoutedEventArgs e)
|
|
=> DialogResult = false;
|
|
}
|