improve:改进自动更新
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
ui:WindowHelper.UseModernWindowStyle = "True"
|
||||
ui:WindowHelper.SystemBackdropType="Mica"
|
||||
ui:TitleBar.Height="36"
|
||||
Title="InkCanvasForClass CE有新版本可用" Height="680" Width="850" ResizeMode="NoResize"
|
||||
Title="InkCanvasForClass CE有新版本可用" Height="600" Width="850" ResizeMode="NoResize"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
|
||||
<Grid Background="#fafafa" Margin="0,0,0,30">
|
||||
@@ -50,28 +50,7 @@
|
||||
<TextBlock x:Name="updateDateInfo" Text="2024年8月4日发布更新" FontSize="15" TextAlignment="Center"/>
|
||||
</ui:SimpleStackPanel>
|
||||
|
||||
<!-- 自动更新选项 -->
|
||||
<Border Background="White" BorderBrush="#e2e8f0" BorderThickness="1" CornerRadius="4" Margin="24,16,24,0">
|
||||
<ui:SimpleStackPanel Orientation="Vertical" HorizontalAlignment="Center" Margin="0,16,0,16" Spacing="10">
|
||||
<TextBlock Text="更新设置" FontWeight="Bold" FontSize="16" HorizontalAlignment="Center" Margin="0,0,0,6"/>
|
||||
|
||||
<!-- 水平排列两个ToggleSwitch -->
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Center" Spacing="20">
|
||||
<ui:SimpleStackPanel Orientation="Vertical" Spacing="4">
|
||||
<ui:ToggleSwitch x:Name="EnableAutoUpdateToggle" Header="启用自动更新" OnContent="开启" OffContent="关闭" IsOn="True" Width="170" Foreground="Black"/>
|
||||
</ui:SimpleStackPanel>
|
||||
|
||||
<ui:SimpleStackPanel Orientation="Vertical" Spacing="4">
|
||||
<ui:ToggleSwitch x:Name="EnableSilentUpdateToggle" Header="启用静默更新" OnContent="开启" OffContent="关闭" Width="170" Foreground="Black"/>
|
||||
</ui:SimpleStackPanel>
|
||||
</ui:SimpleStackPanel>
|
||||
|
||||
<TextBlock Text="静默更新将在软件不使用时自动安装,无需手动操作" FontSize="13" Foreground="#71717a" HorizontalAlignment="Center"
|
||||
Margin="4,0,0,0" Width="360" TextWrapping="Wrap"/>
|
||||
</ui:SimpleStackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- 更新按钮组 -->
|
||||
<!-- 更新按钮组 -->
|
||||
<Border Background="#f1f5f9" BorderBrush="#e2e8f0" BorderThickness="1" CornerRadius="4" Margin="24,16,24,20">
|
||||
<ui:SimpleStackPanel Orientation="Vertical" HorizontalAlignment="Center" Spacing="14" Margin="0,16,0,16">
|
||||
<TextBlock Text="请选择更新方式" FontWeight="Bold" FontSize="16" HorizontalAlignment="Center" Margin="0,0,0,6"/>
|
||||
|
||||
@@ -72,10 +72,6 @@ namespace Ink_Canvas
|
||||
|
||||
public UpdateResult Result { get; private set; } = UpdateResult.UpdateLater;
|
||||
|
||||
// 更新设置
|
||||
public bool IsAutoUpdateEnabled => EnableAutoUpdateToggle.IsOn;
|
||||
public bool IsSilentUpdateEnabled => EnableSilentUpdateToggle.IsOn;
|
||||
|
||||
public HasNewUpdateWindow(string currentVersion, string newVersion, string releaseDate, string releaseNotes = null)
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -96,9 +92,7 @@ namespace Ink_Canvas
|
||||
markdownContent.Markdown = ReleaseNotes;
|
||||
}
|
||||
|
||||
// 初始化自动更新设置
|
||||
EnableAutoUpdateToggle.IsOn = MainWindow.Settings.Startup.IsAutoUpdate;
|
||||
EnableSilentUpdateToggle.IsOn = MainWindow.Settings.Startup.IsAutoUpdateWithSilence;
|
||||
// 自动更新和静默更新设置已移至设置界面,此处不再需要
|
||||
|
||||
// 确保按钮可见且可用
|
||||
EnsureButtonsVisibility();
|
||||
@@ -148,9 +142,6 @@ namespace Ink_Canvas
|
||||
{
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Update Now button clicked");
|
||||
|
||||
// 保存自动更新设置
|
||||
SaveUpdateSettings();
|
||||
|
||||
// 设置结果为立即更新
|
||||
Result = UpdateResult.UpdateNow;
|
||||
|
||||
@@ -163,9 +154,6 @@ namespace Ink_Canvas
|
||||
{
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Update Later button clicked");
|
||||
|
||||
// 保存自动更新设置
|
||||
SaveUpdateSettings();
|
||||
|
||||
// 设置结果为稍后更新
|
||||
Result = UpdateResult.UpdateLater;
|
||||
|
||||
@@ -178,9 +166,6 @@ namespace Ink_Canvas
|
||||
{
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Skip Version button clicked");
|
||||
|
||||
// 保存自动更新设置
|
||||
SaveUpdateSettings();
|
||||
|
||||
// 设置结果为跳过该版本
|
||||
Result = UpdateResult.SkipVersion;
|
||||
|
||||
@@ -189,15 +174,7 @@ namespace Ink_Canvas
|
||||
Close();
|
||||
}
|
||||
|
||||
private void SaveUpdateSettings()
|
||||
{
|
||||
// 保存自动更新设置
|
||||
MainWindow.Settings.Startup.IsAutoUpdate = EnableAutoUpdateToggle.IsOn;
|
||||
MainWindow.Settings.Startup.IsAutoUpdateWithSilence = EnableSilentUpdateToggle.IsOn;
|
||||
|
||||
// 记录到日志
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | User settings changed: AutoUpdate={EnableAutoUpdateToggle.IsOn}, SilentUpdate={EnableSilentUpdateToggle.IsOn}");
|
||||
}
|
||||
|
||||
// 根据屏幕分辨率调整窗口大小
|
||||
private void AdjustWindowSizeForScreenResolution()
|
||||
|
||||
Reference in New Issue
Block a user