improve:历史版本回滚
支持最近不再接收更新
This commit is contained in:
@@ -970,6 +970,24 @@ namespace Ink_Canvas
|
||||
|
||||
private async void AutoUpdate()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Settings.Startup.AutoUpdatePauseUntilDate))
|
||||
{
|
||||
if (DateTime.TryParse(Settings.Startup.AutoUpdatePauseUntilDate, out DateTime pauseUntilDate))
|
||||
{
|
||||
if (DateTime.Now < pauseUntilDate)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 自动更新已暂停,直到 {pauseUntilDate:yyyy-MM-dd}");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 暂停期已过,恢复自动更新检查");
|
||||
Settings.Startup.AutoUpdatePauseUntilDate = "";
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 清除之前的更新状态,确保使用新通道重新检查
|
||||
AvailableLatestVersion = null;
|
||||
AvailableLatestLineGroup = null;
|
||||
|
||||
@@ -157,6 +157,8 @@ namespace Ink_Canvas
|
||||
public UpdateChannel UpdateChannel { get; set; } = UpdateChannel.Release;
|
||||
[JsonProperty("skippedVersion")]
|
||||
public string SkippedVersion { get; set; } = "";
|
||||
[JsonProperty("autoUpdatePauseUntilDate")]
|
||||
public string AutoUpdatePauseUntilDate { get; set; } = "";
|
||||
[JsonProperty("isEnableNibMode")]
|
||||
public bool IsEnableNibMode { get; set; }
|
||||
[JsonProperty("isFoldAtStartup")]
|
||||
|
||||
@@ -20,103 +20,105 @@
|
||||
<Border.Effect>
|
||||
<DropShadowEffect Color="#000000" BlurRadius="20" ShadowDepth="0" Opacity="0.1"/>
|
||||
</Border.Effect>
|
||||
<Grid>
|
||||
<!-- 标题栏 -->
|
||||
<Border Background="{DynamicResource SettingsPageBackground}" Height="48" VerticalAlignment="Top">
|
||||
<Grid>
|
||||
<TextBlock Text="{TemplateBinding Title}"
|
||||
FontSize="14" FontWeight="SemiBold"
|
||||
Foreground="{DynamicResource SettingsPageForeground}"
|
||||
VerticalAlignment="Center"
|
||||
Margin="16,0,0,0"/>
|
||||
<!-- 最小化按钮 -->
|
||||
<Button Name="MinimizeButton"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top"
|
||||
Margin="0,8,40,0"
|
||||
Width="32" Height="32"
|
||||
Background="Transparent"
|
||||
BorderThickness="0"
|
||||
Click="MinimizeButton_Click"
|
||||
Cursor="Hand"
|
||||
ToolTip="最小化">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Background="{TemplateBinding Background}"
|
||||
CornerRadius="4"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}">
|
||||
<TextBlock Text="−" FontSize="14"
|
||||
Foreground="{DynamicResource SettingsPageForeground}"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Color="#FF2563eb" Opacity="0.1"/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="Background">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Color="#FF2563eb" Opacity="0.2"/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
</Button>
|
||||
|
||||
<!-- 关闭按钮 -->
|
||||
<Button Name="CloseButton"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top"
|
||||
Margin="0,8,8,0"
|
||||
Width="32" Height="32"
|
||||
Background="Transparent"
|
||||
BorderThickness="0"
|
||||
Click="CloseButton_Click"
|
||||
Cursor="Hand"
|
||||
ToolTip="关闭">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Background="{TemplateBinding Background}"
|
||||
CornerRadius="4"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}">
|
||||
<TextBlock Text="×" FontSize="14"
|
||||
Foreground="{DynamicResource SettingsPageForeground}"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Color="#ef4444" Opacity="0.1"/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="Background">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Color="#ef4444" Opacity="0.2"/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Border>
|
||||
<!-- 内容区域 -->
|
||||
<ContentPresenter Margin="0,48,0,0"/>
|
||||
</Grid>
|
||||
<AdornerDecorator>
|
||||
<Grid>
|
||||
<!-- 标题栏 -->
|
||||
<Border Background="{DynamicResource SettingsPageBackground}" Height="48" VerticalAlignment="Top">
|
||||
<Grid>
|
||||
<TextBlock Text="{TemplateBinding Title}"
|
||||
FontSize="14" FontWeight="SemiBold"
|
||||
Foreground="{DynamicResource SettingsPageForeground}"
|
||||
VerticalAlignment="Center"
|
||||
Margin="16,0,0,0"/>
|
||||
<!-- 最小化按钮 -->
|
||||
<Button Name="MinimizeButton"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top"
|
||||
Margin="0,8,40,0"
|
||||
Width="32" Height="32"
|
||||
Background="Transparent"
|
||||
BorderThickness="0"
|
||||
Click="MinimizeButton_Click"
|
||||
Cursor="Hand"
|
||||
ToolTip="最小化">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Background="{TemplateBinding Background}"
|
||||
CornerRadius="4"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}">
|
||||
<TextBlock Text="−" FontSize="14"
|
||||
Foreground="{DynamicResource SettingsPageForeground}"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Color="#FF2563eb" Opacity="0.1"/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="Background">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Color="#FF2563eb" Opacity="0.2"/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
</Button>
|
||||
|
||||
<!-- 关闭按钮 -->
|
||||
<Button Name="CloseButton"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top"
|
||||
Margin="0,8,8,0"
|
||||
Width="32" Height="32"
|
||||
Background="Transparent"
|
||||
BorderThickness="0"
|
||||
Click="CloseButton_Click"
|
||||
Cursor="Hand"
|
||||
ToolTip="关闭">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Background="{TemplateBinding Background}"
|
||||
CornerRadius="4"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}">
|
||||
<TextBlock Text="×" FontSize="14"
|
||||
Foreground="{DynamicResource SettingsPageForeground}"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Color="#ef4444" Opacity="0.1"/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="Background">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Color="#ef4444" Opacity="0.2"/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Border>
|
||||
<!-- 内容区域 -->
|
||||
<ContentPresenter Margin="0,48,0,0"/>
|
||||
</Grid>
|
||||
</AdornerDecorator>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Window.Template>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@@ -201,7 +202,83 @@ namespace Ink_Canvas
|
||||
private async void RollbackButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (selectedItem == null) return;
|
||||
LogHelper.WriteLogToFile($"HistoryRollback | 用户点击回滚,目标版本: {selectedItem.Version}");
|
||||
|
||||
var dialog = new ContentDialog
|
||||
{
|
||||
Title = "暂停自动更新",
|
||||
PrimaryButtonText = "确定",
|
||||
SecondaryButtonText = "取消"
|
||||
};
|
||||
|
||||
var panel = new iNKORE.UI.WPF.Modern.Controls.SimpleStackPanel
|
||||
{
|
||||
Spacing = 16,
|
||||
Margin = new Thickness(0, 10, 0, 0)
|
||||
};
|
||||
|
||||
var textBlock = new TextBlock
|
||||
{
|
||||
Text = "请选择在回滚后多久不再接收自动更新:",
|
||||
FontSize = 14,
|
||||
Foreground = (Brush)Resources["TextPrimaryBrush"]
|
||||
};
|
||||
|
||||
var daysComboBox = new ComboBox
|
||||
{
|
||||
Width = 200,
|
||||
Height = 36,
|
||||
HorizontalAlignment = HorizontalAlignment.Left
|
||||
};
|
||||
|
||||
for (int i = 0; i <= 7; i++)
|
||||
{
|
||||
daysComboBox.Items.Add(new ComboBoxItem
|
||||
{
|
||||
Content = $"{i} 天",
|
||||
Tag = i
|
||||
});
|
||||
}
|
||||
|
||||
daysComboBox.SelectedIndex = 0;
|
||||
|
||||
panel.Children.Add(textBlock);
|
||||
panel.Children.Add(daysComboBox);
|
||||
dialog.Content = panel;
|
||||
|
||||
var dialogResult = await dialog.ShowAsync();
|
||||
|
||||
if (dialogResult == ContentDialogResult.Primary)
|
||||
{
|
||||
int days = 1;
|
||||
if (daysComboBox.SelectedItem is ComboBoxItem selectedItemCombo &&
|
||||
selectedItemCombo.Tag != null &&
|
||||
int.TryParse(selectedItemCombo.Tag.ToString(), out int selectedDays))
|
||||
{
|
||||
days = selectedDays;
|
||||
}
|
||||
|
||||
if (days == 0)
|
||||
{
|
||||
MainWindow.Settings.Startup.AutoUpdatePauseUntilDate = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
DateTime pauseUntilDate = DateTime.Now.AddDays(days);
|
||||
MainWindow.Settings.Startup.AutoUpdatePauseUntilDate = pauseUntilDate.ToString("yyyy-MM-dd");
|
||||
LogHelper.WriteLogToFile($"HistoryRollback | 用户选择暂停自动更新 {days} 天,截止日期: {pauseUntilDate:yyyy-MM-dd}");
|
||||
}
|
||||
|
||||
MainWindow.SaveSettingsToFile();
|
||||
|
||||
LogHelper.WriteLogToFile($"HistoryRollback | 用户选择暂停自动更新 {days} 天");
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogToFile("HistoryRollback | 用户取消了回滚操作");
|
||||
return;
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile($"HistoryRollback | 用户确认回滚,目标版本: {selectedItem.Version}");
|
||||
RollbackButton.IsEnabled = false;
|
||||
VersionComboBox.IsEnabled = false;
|
||||
DownloadProgressPanel.Visibility = Visibility.Visible;
|
||||
|
||||
Reference in New Issue
Block a user