improve:历史版本回滚
支持最近不再接收更新
This commit is contained in:
@@ -970,6 +970,24 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
private async void AutoUpdate()
|
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;
|
AvailableLatestVersion = null;
|
||||||
AvailableLatestLineGroup = null;
|
AvailableLatestLineGroup = null;
|
||||||
|
|||||||
@@ -157,6 +157,8 @@ namespace Ink_Canvas
|
|||||||
public UpdateChannel UpdateChannel { get; set; } = UpdateChannel.Release;
|
public UpdateChannel UpdateChannel { get; set; } = UpdateChannel.Release;
|
||||||
[JsonProperty("skippedVersion")]
|
[JsonProperty("skippedVersion")]
|
||||||
public string SkippedVersion { get; set; } = "";
|
public string SkippedVersion { get; set; } = "";
|
||||||
|
[JsonProperty("autoUpdatePauseUntilDate")]
|
||||||
|
public string AutoUpdatePauseUntilDate { get; set; } = "";
|
||||||
[JsonProperty("isEnableNibMode")]
|
[JsonProperty("isEnableNibMode")]
|
||||||
public bool IsEnableNibMode { get; set; }
|
public bool IsEnableNibMode { get; set; }
|
||||||
[JsonProperty("isFoldAtStartup")]
|
[JsonProperty("isFoldAtStartup")]
|
||||||
|
|||||||
@@ -20,103 +20,105 @@
|
|||||||
<Border.Effect>
|
<Border.Effect>
|
||||||
<DropShadowEffect Color="#000000" BlurRadius="20" ShadowDepth="0" Opacity="0.1"/>
|
<DropShadowEffect Color="#000000" BlurRadius="20" ShadowDepth="0" Opacity="0.1"/>
|
||||||
</Border.Effect>
|
</Border.Effect>
|
||||||
<Grid>
|
<AdornerDecorator>
|
||||||
<!-- 标题栏 -->
|
<Grid>
|
||||||
<Border Background="{DynamicResource SettingsPageBackground}" Height="48" VerticalAlignment="Top">
|
<!-- 标题栏 -->
|
||||||
<Grid>
|
<Border Background="{DynamicResource SettingsPageBackground}" Height="48" VerticalAlignment="Top">
|
||||||
<TextBlock Text="{TemplateBinding Title}"
|
<Grid>
|
||||||
FontSize="14" FontWeight="SemiBold"
|
<TextBlock Text="{TemplateBinding Title}"
|
||||||
Foreground="{DynamicResource SettingsPageForeground}"
|
FontSize="14" FontWeight="SemiBold"
|
||||||
VerticalAlignment="Center"
|
Foreground="{DynamicResource SettingsPageForeground}"
|
||||||
Margin="16,0,0,0"/>
|
VerticalAlignment="Center"
|
||||||
<!-- 最小化按钮 -->
|
Margin="16,0,0,0"/>
|
||||||
<Button Name="MinimizeButton"
|
<!-- 最小化按钮 -->
|
||||||
HorizontalAlignment="Right"
|
<Button Name="MinimizeButton"
|
||||||
VerticalAlignment="Top"
|
HorizontalAlignment="Right"
|
||||||
Margin="0,8,40,0"
|
VerticalAlignment="Top"
|
||||||
Width="32" Height="32"
|
Margin="0,8,40,0"
|
||||||
Background="Transparent"
|
Width="32" Height="32"
|
||||||
BorderThickness="0"
|
Background="Transparent"
|
||||||
Click="MinimizeButton_Click"
|
BorderThickness="0"
|
||||||
Cursor="Hand"
|
Click="MinimizeButton_Click"
|
||||||
ToolTip="最小化">
|
Cursor="Hand"
|
||||||
<Button.Template>
|
ToolTip="最小化">
|
||||||
<ControlTemplate TargetType="Button">
|
<Button.Template>
|
||||||
<Border Background="{TemplateBinding Background}"
|
<ControlTemplate TargetType="Button">
|
||||||
CornerRadius="4"
|
<Border Background="{TemplateBinding Background}"
|
||||||
BorderThickness="{TemplateBinding BorderThickness}"
|
CornerRadius="4"
|
||||||
BorderBrush="{TemplateBinding BorderBrush}">
|
BorderThickness="{TemplateBinding BorderThickness}"
|
||||||
<TextBlock Text="−" FontSize="14"
|
BorderBrush="{TemplateBinding BorderBrush}">
|
||||||
Foreground="{DynamicResource SettingsPageForeground}"
|
<TextBlock Text="−" FontSize="14"
|
||||||
HorizontalAlignment="Center"
|
Foreground="{DynamicResource SettingsPageForeground}"
|
||||||
VerticalAlignment="Center"/>
|
HorizontalAlignment="Center"
|
||||||
</Border>
|
VerticalAlignment="Center"/>
|
||||||
<ControlTemplate.Triggers>
|
</Border>
|
||||||
<Trigger Property="IsMouseOver" Value="True">
|
<ControlTemplate.Triggers>
|
||||||
<Setter Property="Background">
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
<Setter.Value>
|
<Setter Property="Background">
|
||||||
<SolidColorBrush Color="#FF2563eb" Opacity="0.1"/>
|
<Setter.Value>
|
||||||
</Setter.Value>
|
<SolidColorBrush Color="#FF2563eb" Opacity="0.1"/>
|
||||||
</Setter>
|
</Setter.Value>
|
||||||
</Trigger>
|
</Setter>
|
||||||
<Trigger Property="IsPressed" Value="True">
|
</Trigger>
|
||||||
<Setter Property="Background">
|
<Trigger Property="IsPressed" Value="True">
|
||||||
<Setter.Value>
|
<Setter Property="Background">
|
||||||
<SolidColorBrush Color="#FF2563eb" Opacity="0.2"/>
|
<Setter.Value>
|
||||||
</Setter.Value>
|
<SolidColorBrush Color="#FF2563eb" Opacity="0.2"/>
|
||||||
</Setter>
|
</Setter.Value>
|
||||||
</Trigger>
|
</Setter>
|
||||||
</ControlTemplate.Triggers>
|
</Trigger>
|
||||||
</ControlTemplate>
|
</ControlTemplate.Triggers>
|
||||||
</Button.Template>
|
</ControlTemplate>
|
||||||
</Button>
|
</Button.Template>
|
||||||
|
</Button>
|
||||||
|
|
||||||
<!-- 关闭按钮 -->
|
<!-- 关闭按钮 -->
|
||||||
<Button Name="CloseButton"
|
<Button Name="CloseButton"
|
||||||
HorizontalAlignment="Right"
|
HorizontalAlignment="Right"
|
||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
Margin="0,8,8,0"
|
Margin="0,8,8,0"
|
||||||
Width="32" Height="32"
|
Width="32" Height="32"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
BorderThickness="0"
|
BorderThickness="0"
|
||||||
Click="CloseButton_Click"
|
Click="CloseButton_Click"
|
||||||
Cursor="Hand"
|
Cursor="Hand"
|
||||||
ToolTip="关闭">
|
ToolTip="关闭">
|
||||||
<Button.Template>
|
<Button.Template>
|
||||||
<ControlTemplate TargetType="Button">
|
<ControlTemplate TargetType="Button">
|
||||||
<Border Background="{TemplateBinding Background}"
|
<Border Background="{TemplateBinding Background}"
|
||||||
CornerRadius="4"
|
CornerRadius="4"
|
||||||
BorderThickness="{TemplateBinding BorderThickness}"
|
BorderThickness="{TemplateBinding BorderThickness}"
|
||||||
BorderBrush="{TemplateBinding BorderBrush}">
|
BorderBrush="{TemplateBinding BorderBrush}">
|
||||||
<TextBlock Text="×" FontSize="14"
|
<TextBlock Text="×" FontSize="14"
|
||||||
Foreground="{DynamicResource SettingsPageForeground}"
|
Foreground="{DynamicResource SettingsPageForeground}"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
VerticalAlignment="Center"/>
|
VerticalAlignment="Center"/>
|
||||||
</Border>
|
</Border>
|
||||||
<ControlTemplate.Triggers>
|
<ControlTemplate.Triggers>
|
||||||
<Trigger Property="IsMouseOver" Value="True">
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
<Setter Property="Background">
|
<Setter Property="Background">
|
||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
<SolidColorBrush Color="#ef4444" Opacity="0.1"/>
|
<SolidColorBrush Color="#ef4444" Opacity="0.1"/>
|
||||||
</Setter.Value>
|
</Setter.Value>
|
||||||
</Setter>
|
</Setter>
|
||||||
</Trigger>
|
</Trigger>
|
||||||
<Trigger Property="IsPressed" Value="True">
|
<Trigger Property="IsPressed" Value="True">
|
||||||
<Setter Property="Background">
|
<Setter Property="Background">
|
||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
<SolidColorBrush Color="#ef4444" Opacity="0.2"/>
|
<SolidColorBrush Color="#ef4444" Opacity="0.2"/>
|
||||||
</Setter.Value>
|
</Setter.Value>
|
||||||
</Setter>
|
</Setter>
|
||||||
</Trigger>
|
</Trigger>
|
||||||
</ControlTemplate.Triggers>
|
</ControlTemplate.Triggers>
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
</Button.Template>
|
</Button.Template>
|
||||||
</Button>
|
</Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
<!-- 内容区域 -->
|
<!-- 内容区域 -->
|
||||||
<ContentPresenter Margin="0,48,0,0"/>
|
<ContentPresenter Margin="0,48,0,0"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
</AdornerDecorator>
|
||||||
</Border>
|
</Border>
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
</Window.Template>
|
</Window.Template>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Ink_Canvas.Helpers;
|
using Ink_Canvas.Helpers;
|
||||||
using iNKORE.UI.WPF.Modern;
|
using iNKORE.UI.WPF.Modern;
|
||||||
|
using iNKORE.UI.WPF.Modern.Controls;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@@ -201,7 +202,83 @@ namespace Ink_Canvas
|
|||||||
private async void RollbackButton_Click(object sender, RoutedEventArgs e)
|
private async void RollbackButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (selectedItem == null) return;
|
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;
|
RollbackButton.IsEnabled = false;
|
||||||
VersionComboBox.IsEnabled = false;
|
VersionComboBox.IsEnabled = false;
|
||||||
DownloadProgressPanel.Visibility = Visibility.Visible;
|
DownloadProgressPanel.Visibility = Visibility.Visible;
|
||||||
|
|||||||
Reference in New Issue
Block a user