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,6 +20,7 @@
|
|||||||
<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>
|
||||||
|
<AdornerDecorator>
|
||||||
<Grid>
|
<Grid>
|
||||||
<!-- 标题栏 -->
|
<!-- 标题栏 -->
|
||||||
<Border Background="{DynamicResource SettingsPageBackground}" Height="48" VerticalAlignment="Top">
|
<Border Background="{DynamicResource SettingsPageBackground}" Height="48" VerticalAlignment="Top">
|
||||||
@@ -117,6 +118,7 @@
|
|||||||
<!-- 内容区域 -->
|
<!-- 内容区域 -->
|
||||||
<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