feat: 优化触发器配置体验

- 根据触发器类型动态展示对应配置区域,减少无关字段干扰。
- 将单次、每日、每周、每月和生效时间范围改为日期选择器与时分秒下拉选择,避免手动输入时间格式。
- 为单次执行增加延后执行快捷设置,支持常用快捷按钮和自定义分钟、小时、天后执行。
- 移除开机自启设置、注册表写入逻辑和相关配置字段,降低对用户系统的影响。
- 同步优化部分任务状态、触发摘要和设置界面文案。
This commit is contained in:
2026-05-21 10:54:20 +08:00
parent 2a669bdfe7
commit d33fe30569
8 changed files with 489 additions and 144 deletions

View File

@@ -2,12 +2,33 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="任务编辑"
Height="650"
Width="860"
MinHeight="600"
MinWidth="780"
Height="690"
Width="900"
MinHeight="620"
MinWidth="820"
WindowStartupLocation="CenterOwner"
Icon="app.ico">
<Window.Resources>
<Style x:Key="SectionTitle" TargetType="TextBlock">
<Setter Property="FontWeight" Value="SemiBold" />
<Setter Property="Margin" Value="0,0,0,8" />
</Style>
<Style x:Key="FieldLabel" TargetType="TextBlock">
<Setter Property="Width" Value="90" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="0,0,10,0" />
</Style>
<Style x:Key="FieldRow" TargetType="StackPanel">
<Setter Property="Orientation" Value="Horizontal" />
<Setter Property="Margin" Value="0,8,0,0" />
</Style>
<Style x:Key="TimeCombo" TargetType="ComboBox">
<Setter Property="Width" Value="58" />
<Setter Property="Height" Value="30" />
<Setter Property="DisplayMemberPath" Value="Label" />
</Style>
</Window.Resources>
<DockPanel Margin="12">
<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,12,0,0">
<TextBlock x:Name="ValidationText" Foreground="#B42318" VerticalAlignment="Center" Margin="0,0,14,0" />
@@ -55,72 +76,159 @@
<Border Grid.Column="2" BorderBrush="#D8DEE9" BorderThickness="1" Padding="12">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock x:Name="TriggerEmptyText"
Text="请先添加或选择一个触发器。"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="#667085" />
<TextBlock Text="触发类型" VerticalAlignment="Center" />
<ComboBox x:Name="KindBox" Grid.Column="1" Height="30" SelectionChanged="Field_Changed" />
<DockPanel x:Name="TriggerEditorPanel">
<StackPanel DockPanel.Dock="Top">
<TextBlock Text="触发类型" Style="{StaticResource SectionTitle}" />
<ComboBox x:Name="KindBox" Height="30" DisplayMemberPath="Label" SelectionChanged="Field_Changed" />
</StackPanel>
<TextBlock Text="单次时间" Grid.Row="1" Margin="0,10,0,0" VerticalAlignment="Center" />
<TextBox x:Name="OneTimeBox" Grid.Row="1" Grid.Column="1" Margin="0,10,0,0" Height="30" ToolTip="格式yyyy-MM-dd HH:mm:ss" TextChanged="Field_Changed" />
<GroupBox DockPanel.Dock="Bottom" Header="高级调度与预览" Margin="0,14,0,0">
<DockPanel Margin="10">
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
<TextBlock Text="错过触发补偿策略" VerticalAlignment="Center" Margin="0,0,10,0" />
<ComboBox x:Name="MisfireBox" Width="180" Height="30" DisplayMemberPath="Label" />
</StackPanel>
<TextBox x:Name="PreviewBox" Margin="0,12,0,0" IsReadOnly="True" AcceptsReturn="True" Height="130" />
</DockPanel>
</GroupBox>
<TextBlock Text="间隔" Grid.Row="2" Margin="0,10,0,0" VerticalAlignment="Center" />
<StackPanel Grid.Row="2" Grid.Column="1" Margin="0,10,0,0" Orientation="Horizontal">
<TextBox x:Name="IntervalValueBox" Width="80" Height="30" TextChanged="Field_Changed" />
<ComboBox x:Name="IntervalUnitBox" Width="120" Height="30" Margin="8,0,0,0" SelectionChanged="Field_Changed" />
</StackPanel>
<ScrollViewer VerticalScrollBarVisibility="Auto" Margin="0,14,0,0">
<StackPanel>
<StackPanel x:Name="OneTimeSection">
<TextBlock Text="单次执行" Style="{StaticResource SectionTitle}" />
<StackPanel Style="{StaticResource FieldRow}">
<TextBlock Text="快速设置" Style="{StaticResource FieldLabel}" />
<TextBox x:Name="OneTimeDelayValueBox" Width="70" Height="30" Text="5" />
<ComboBox x:Name="OneTimeDelayUnitBox" Width="90" Height="30" Margin="8,0,0,0" DisplayMemberPath="Label" />
<TextBlock Text="后执行" VerticalAlignment="Center" Margin="8,0,10,0" />
<Button Content="应用" Width="70" Click="ApplyOneTimeDelay_Click" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="100,8,0,0">
<Button Content="5 分钟后" Tag="5" Click="QuickOneTimeDelay_Click" />
<Button Content="30 分钟后" Tag="30" Margin="8,0,0,0" Click="QuickOneTimeDelay_Click" />
<Button Content="1 小时后" Tag="60" Margin="8,0,0,0" Click="QuickOneTimeDelay_Click" />
<Button Content="明天此时" Tag="1440" Margin="8,0,0,0" Click="QuickOneTimeDelay_Click" />
</StackPanel>
<StackPanel Style="{StaticResource FieldRow}">
<TextBlock Text="执行日期" Style="{StaticResource FieldLabel}" />
<DatePicker x:Name="OneTimeDatePicker" Width="150" Height="30" SelectedDateChanged="Field_Changed" />
</StackPanel>
<StackPanel Style="{StaticResource FieldRow}">
<TextBlock Text="执行时间" Style="{StaticResource FieldLabel}" />
<ComboBox x:Name="OneTimeHourBox" Style="{StaticResource TimeCombo}" SelectionChanged="Field_Changed" />
<TextBlock Text="时" VerticalAlignment="Center" Margin="4,0,8,0" />
<ComboBox x:Name="OneTimeMinuteBox" Style="{StaticResource TimeCombo}" SelectionChanged="Field_Changed" />
<TextBlock Text="分" VerticalAlignment="Center" Margin="4,0,8,0" />
<ComboBox x:Name="OneTimeSecondBox" Style="{StaticResource TimeCombo}" SelectionChanged="Field_Changed" />
<TextBlock Text="秒" VerticalAlignment="Center" Margin="4,0,0,0" />
</StackPanel>
</StackPanel>
<TextBlock Text="起止时间" Grid.Row="3" Margin="0,10,0,0" VerticalAlignment="Center" />
<StackPanel Grid.Row="3" Grid.Column="1" Margin="0,10,0,0" Orientation="Horizontal">
<TextBox x:Name="StartsAtBox" Width="180" Height="30" ToolTip="留空表示立即生效" TextChanged="Field_Changed" />
<TextBox x:Name="EndsAtBox" Width="180" Height="30" Margin="8,0,0,0" ToolTip="留空表示长期有效" TextChanged="Field_Changed" />
</StackPanel>
<StackPanel x:Name="IntervalSection">
<TextBlock Text="固定间隔" Style="{StaticResource SectionTitle}" />
<StackPanel Style="{StaticResource FieldRow}">
<TextBlock Text="每隔" Style="{StaticResource FieldLabel}" />
<TextBox x:Name="IntervalValueBox" Width="80" Height="30" TextChanged="Field_Changed" />
<ComboBox x:Name="IntervalUnitBox" Width="120" Height="30" Margin="8,0,0,0" DisplayMemberPath="Label" SelectionChanged="Field_Changed" />
</StackPanel>
</StackPanel>
<TextBlock Text="每日/每周时间" Grid.Row="4" Margin="0,10,0,0" VerticalAlignment="Center" />
<TextBox x:Name="TimeOfDayBox" Grid.Row="4" Grid.Column="1" Margin="0,10,0,0" Height="30" ToolTip="格式HH:mm:ss" TextChanged="Field_Changed" />
<StackPanel x:Name="DailySection">
<TextBlock Text="每日定时" Style="{StaticResource SectionTitle}" />
<StackPanel Style="{StaticResource FieldRow}">
<TextBlock Text="执行时间" Style="{StaticResource FieldLabel}" />
<ComboBox x:Name="DailyHourBox" Style="{StaticResource TimeCombo}" SelectionChanged="Field_Changed" />
<TextBlock Text="时" VerticalAlignment="Center" Margin="4,0,8,0" />
<ComboBox x:Name="DailyMinuteBox" Style="{StaticResource TimeCombo}" SelectionChanged="Field_Changed" />
<TextBlock Text="分" VerticalAlignment="Center" Margin="4,0,8,0" />
<ComboBox x:Name="DailySecondBox" Style="{StaticResource TimeCombo}" SelectionChanged="Field_Changed" />
<TextBlock Text="秒" VerticalAlignment="Center" Margin="4,0,0,0" />
</StackPanel>
</StackPanel>
<TextBlock Text="周几" Grid.Row="5" Margin="0,10,0,0" VerticalAlignment="Center" />
<WrapPanel Grid.Row="5" Grid.Column="1" Margin="0,10,0,0">
<CheckBox x:Name="SunBox" Content="日" Margin="0,0,10,0" Checked="Field_Changed" Unchecked="Field_Changed" />
<CheckBox x:Name="MonBox" Content="一" Margin="0,0,10,0" Checked="Field_Changed" Unchecked="Field_Changed" />
<CheckBox x:Name="TueBox" Content="二" Margin="0,0,10,0" Checked="Field_Changed" Unchecked="Field_Changed" />
<CheckBox x:Name="WedBox" Content="" Margin="0,0,10,0" Checked="Field_Changed" Unchecked="Field_Changed" />
<CheckBox x:Name="ThuBox" Content="" Margin="0,0,10,0" Checked="Field_Changed" Unchecked="Field_Changed" />
<CheckBox x:Name="FriBox" Content="" Margin="0,0,10,0" Checked="Field_Changed" Unchecked="Field_Changed" />
<CheckBox x:Name="SatBox" Content="" Margin="0,0,10,0" Checked="Field_Changed" Unchecked="Field_Changed" />
</WrapPanel>
<StackPanel x:Name="WeeklySection">
<TextBlock Text="每周定时" Style="{StaticResource SectionTitle}" />
<StackPanel Style="{StaticResource FieldRow}">
<TextBlock Text="星期" Style="{StaticResource FieldLabel}" />
<WrapPanel>
<CheckBox x:Name="SunBox" Content="" Margin="0,0,10,0" Checked="Field_Changed" Unchecked="Field_Changed" />
<CheckBox x:Name="MonBox" Content="" Margin="0,0,10,0" Checked="Field_Changed" Unchecked="Field_Changed" />
<CheckBox x:Name="TueBox" Content="" Margin="0,0,10,0" Checked="Field_Changed" Unchecked="Field_Changed" />
<CheckBox x:Name="WedBox" Content="" Margin="0,0,10,0" Checked="Field_Changed" Unchecked="Field_Changed" />
<CheckBox x:Name="ThuBox" Content="四" Margin="0,0,10,0" Checked="Field_Changed" Unchecked="Field_Changed" />
<CheckBox x:Name="FriBox" Content="五" Margin="0,0,10,0" Checked="Field_Changed" Unchecked="Field_Changed" />
<CheckBox x:Name="SatBox" Content="六" Margin="0,0,10,0" Checked="Field_Changed" Unchecked="Field_Changed" />
</WrapPanel>
</StackPanel>
<StackPanel Style="{StaticResource FieldRow}">
<TextBlock Text="执行时间" Style="{StaticResource FieldLabel}" />
<ComboBox x:Name="WeeklyHourBox" Style="{StaticResource TimeCombo}" SelectionChanged="Field_Changed" />
<TextBlock Text="时" VerticalAlignment="Center" Margin="4,0,8,0" />
<ComboBox x:Name="WeeklyMinuteBox" Style="{StaticResource TimeCombo}" SelectionChanged="Field_Changed" />
<TextBlock Text="分" VerticalAlignment="Center" Margin="4,0,8,0" />
<ComboBox x:Name="WeeklySecondBox" Style="{StaticResource TimeCombo}" SelectionChanged="Field_Changed" />
<TextBlock Text="秒" VerticalAlignment="Center" Margin="4,0,0,0" />
</StackPanel>
</StackPanel>
<TextBlock Text="每月" Grid.Row="6" Margin="0,10,0,0" VerticalAlignment="Center" />
<StackPanel Grid.Row="6" Grid.Column="1" Margin="0,10,0,0" Orientation="Horizontal">
<TextBox x:Name="MonthDayBox" Width="80" Height="30" TextChanged="Field_Changed" />
<CheckBox x:Name="LastBusinessDayBox" Content="最后一个工作日" Margin="10,0,0,0" VerticalAlignment="Center" Checked="Field_Changed" Unchecked="Field_Changed" />
</StackPanel>
<StackPanel x:Name="MonthlySection">
<TextBlock Text="每月定时" Style="{StaticResource SectionTitle}" />
<StackPanel Style="{StaticResource FieldRow}">
<TextBlock Text="日期" Style="{StaticResource FieldLabel}" />
<TextBox x:Name="MonthDayBox" Width="80" Height="30" TextChanged="Field_Changed" />
<TextBlock Text="日" VerticalAlignment="Center" Margin="4,0,10,0" />
<CheckBox x:Name="LastBusinessDayBox" Content="每月最后一个工作日" VerticalAlignment="Center" Checked="Field_Changed" Unchecked="Field_Changed" />
</StackPanel>
<StackPanel Style="{StaticResource FieldRow}">
<TextBlock Text="执行时间" Style="{StaticResource FieldLabel}" />
<ComboBox x:Name="MonthlyHourBox" Style="{StaticResource TimeCombo}" SelectionChanged="Field_Changed" />
<TextBlock Text="时" VerticalAlignment="Center" Margin="4,0,8,0" />
<ComboBox x:Name="MonthlyMinuteBox" Style="{StaticResource TimeCombo}" SelectionChanged="Field_Changed" />
<TextBlock Text="分" VerticalAlignment="Center" Margin="4,0,8,0" />
<ComboBox x:Name="MonthlySecondBox" Style="{StaticResource TimeCombo}" SelectionChanged="Field_Changed" />
<TextBlock Text="秒" VerticalAlignment="Center" Margin="4,0,0,0" />
</StackPanel>
</StackPanel>
<TextBlock Text="Cron 表达式" Grid.Row="7" Margin="0,10,0,0" VerticalAlignment="Center" />
<TextBox x:Name="CronBox" Grid.Row="7" Grid.Column="1" Margin="0,10,0,0" Height="30" TextChanged="Field_Changed" />
<StackPanel x:Name="CronSection">
<TextBlock Text="Cron 表达式" Style="{StaticResource SectionTitle}" />
<TextBox x:Name="CronBox" Height="30" TextChanged="Field_Changed" />
<TextBlock Text="适合高级规则;下方会实时预览未来 5 次执行时间。" Foreground="#667085" Margin="0,6,0,0" />
</StackPanel>
<GroupBox Grid.Row="8" Grid.ColumnSpan="2" Header="高级调度与预览" Margin="0,14,0,0">
<DockPanel Margin="10">
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
<TextBlock Text="错过触发补偿策略" VerticalAlignment="Center" Margin="0,0,10,0" />
<ComboBox x:Name="MisfireBox" Width="180" Height="30" />
<Separator Margin="0,16,0,12" />
<StackPanel x:Name="WindowSection">
<TextBlock Text="生效时间范围" Style="{StaticResource SectionTitle}" />
<CheckBox x:Name="UseStartsAtBox" Content="设置起始生效时间" Checked="WindowOption_Changed" Unchecked="WindowOption_Changed" />
<StackPanel x:Name="StartsAtPanel" Style="{StaticResource FieldRow}">
<TextBlock Text="开始于" Style="{StaticResource FieldLabel}" />
<DatePicker x:Name="StartsAtDatePicker" Width="150" Height="30" SelectedDateChanged="Field_Changed" />
<ComboBox x:Name="StartsAtHourBox" Style="{StaticResource TimeCombo}" Margin="8,0,0,0" SelectionChanged="Field_Changed" />
<TextBlock Text=":" VerticalAlignment="Center" Margin="4,0" />
<ComboBox x:Name="StartsAtMinuteBox" Style="{StaticResource TimeCombo}" SelectionChanged="Field_Changed" />
<TextBlock Text=":" VerticalAlignment="Center" Margin="4,0" />
<ComboBox x:Name="StartsAtSecondBox" Style="{StaticResource TimeCombo}" SelectionChanged="Field_Changed" />
</StackPanel>
<CheckBox x:Name="UseEndsAtBox" Content="设置结束失效时间" Margin="0,10,0,0" Checked="WindowOption_Changed" Unchecked="WindowOption_Changed" />
<StackPanel x:Name="EndsAtPanel" Style="{StaticResource FieldRow}">
<TextBlock Text="结束于" Style="{StaticResource FieldLabel}" />
<DatePicker x:Name="EndsAtDatePicker" Width="150" Height="30" SelectedDateChanged="Field_Changed" />
<ComboBox x:Name="EndsAtHourBox" Style="{StaticResource TimeCombo}" Margin="8,0,0,0" SelectionChanged="Field_Changed" />
<TextBlock Text=":" VerticalAlignment="Center" Margin="4,0" />
<ComboBox x:Name="EndsAtMinuteBox" Style="{StaticResource TimeCombo}" SelectionChanged="Field_Changed" />
<TextBlock Text=":" VerticalAlignment="Center" Margin="4,0" />
<ComboBox x:Name="EndsAtSecondBox" Style="{StaticResource TimeCombo}" SelectionChanged="Field_Changed" />
</StackPanel>
</StackPanel>
</StackPanel>
<TextBox x:Name="PreviewBox" Margin="0,12,0,0" IsReadOnly="True" AcceptsReturn="True" Height="130" />
</DockPanel>
</GroupBox>
</ScrollViewer>
</DockPanel>
</Grid>
</Border>
</Grid>
@@ -142,14 +250,14 @@
<TextBlock Text="目标地址" VerticalAlignment="Center" />
<TextBox x:Name="TargetUrlBox" Grid.Column="1" Height="30" IsReadOnly="True" />
<TextBlock Text="Channel" Grid.Row="1" Margin="0,10,0,0" VerticalAlignment="Center" />
<TextBlock Text="频道" Grid.Row="1" Margin="0,10,0,0" VerticalAlignment="Center" />
<ComboBox x:Name="ChannelBox" Grid.Row="1" Grid.Column="1" Margin="0,10,0,0" Height="30" IsEditable="True" />
<TextBlock Text="Title" Grid.Row="2" Margin="0,10,0,0" VerticalAlignment="Center" />
<TextBlock Text="标题" Grid.Row="2" Margin="0,10,0,0" VerticalAlignment="Center" />
<TextBox x:Name="TitleBox" Grid.Row="2" Grid.Column="1" Margin="0,10,0,0" Height="30" />
<TextBlock Text="Body" Grid.Row="3" Margin="0,10,0,0" />
<TextBlock Text="内容" Grid.Row="3" Margin="0,10,0,0" />
<TextBox x:Name="BodyBox" Grid.Row="3" Grid.Column="1" Margin="0,10,0,0" AcceptsReturn="True" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto" />
<StackPanel Grid.Row="4" Grid.Column="1" Orientation="Horizontal" Margin="0,10,0,0">
<Button Content="Send Test Message" Click="TestSend_Click" />
<Button Content="发送测试消息" Click="TestSend_Click" />
<TextBlock x:Name="TestResultText" VerticalAlignment="Center" Margin="8,0,0,0" />
</StackPanel>
</Grid>