improve:自动更新

This commit is contained in:
2026-03-28 20:20:44 +08:00
parent b19c19d73c
commit 1124bb6bfa
7 changed files with 206 additions and 14 deletions
@@ -157,6 +157,25 @@
</StackPanel>
</Border>
<Grid Height="54" Margin="0,0,0,16">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical" Margin="0,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left" Grid.Column="0" MaxWidth="350">
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="软件架构" HorizontalAlignment="Left"/>
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" Text="选择更新架构" HorizontalAlignment="Left" TextWrapping="Wrap"/>
</StackPanel>
<WrapPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,15,0" Grid.Column="1">
<Border x:Name="UpdateArchX86Border" Padding="13,7" CornerRadius="8" Background="#e1e1e1" Cursor="Hand" Tag="UpdateArch_X86" Margin="0,0,8,8" MouseLeftButtonDown="OptionButton_Click">
<TextBlock Foreground="#2e3436" FontSize="14" FontWeight="Bold" Text="32 位 (x86)"/>
</Border>
<Border x:Name="UpdateArchX64Border" Padding="13,7" CornerRadius="8" Cursor="Hand" Tag="UpdateArch_X64" Margin="0,0,8,8" MouseLeftButtonDown="OptionButton_Click">
<TextBlock Foreground="#2e3436" FontSize="14" Text="64 位 (x64)"/>
</Border>
</WrapPanel>
</Grid>
<Grid Height="54">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
@@ -48,7 +48,10 @@ namespace Ink_Canvas.Windows.SettingsViews
{
var version = Assembly.GetExecutingAssembly().GetName().Version;
var platform = Environment.Is64BitOperatingSystem ? "windows-x64" : "windows-x86";
CurrentVersionText.Text = $"当前版本: v{version} | {platform}";
var pkgArch = MainWindow.Settings.Startup.UpdatePackageArchitecture == UpdatePackageArchitecture.X64
? "更新包: 64位"
: "更新包: 32位";
CurrentVersionText.Text = $"当前版本: v{version} | {platform} | {pkgArch}";
LoadLastCheckTime();
@@ -111,6 +114,11 @@ namespace Ink_Canvas.Windows.SettingsViews
{
UpdateUpdateChannelButtons(UpdateChannel.Beta);
}
if (MainWindow.Settings.Startup.UpdatePackageArchitecture == UpdatePackageArchitecture.X64)
UpdateUpdateArchitectureButtons(UpdatePackageArchitecture.X64);
else
UpdateUpdateArchitectureButtons(UpdatePackageArchitecture.X86);
}
catch (Exception ex)
{
@@ -806,6 +814,79 @@ namespace Ink_Canvas.Windows.SettingsViews
LoadHistoryVersions();
LoadUpdateLogWithPriority(UpdateChannel.Beta);
break;
case "UpdateArch_X86":
MainWindowSettingsHelper.UpdateSettingDirectly(() =>
{
MainWindow.Settings.Startup.UpdatePackageArchitecture = UpdatePackageArchitecture.X86;
}, "UpdatePackageArchitecture");
UpdateUpdateArchitectureButtons(UpdatePackageArchitecture.X86);
MainWindow.SaveSettingsToFile();
RefreshVersionArchLabel();
break;
case "UpdateArch_X64":
MainWindowSettingsHelper.UpdateSettingDirectly(() =>
{
MainWindow.Settings.Startup.UpdatePackageArchitecture = UpdatePackageArchitecture.X64;
}, "UpdatePackageArchitecture");
UpdateUpdateArchitectureButtons(UpdatePackageArchitecture.X64);
MainWindow.SaveSettingsToFile();
RefreshVersionArchLabel();
break;
}
}
private void RefreshVersionArchLabel()
{
try
{
if (MainWindow.Settings == null || CurrentVersionText == null) return;
var version = Assembly.GetExecutingAssembly().GetName().Version;
var platform = Environment.Is64BitOperatingSystem ? "windows-x64" : "windows-x86";
var pkgArch = MainWindow.Settings.Startup.UpdatePackageArchitecture == UpdatePackageArchitecture.X64
? "更新包: 64位"
: "更新包: 32位";
CurrentVersionText.Text = $"当前版本: v{version} | {platform} | {pkgArch}";
}
catch { /* ignore */ }
}
private void UpdateUpdateArchitectureButtons(UpdatePackageArchitecture selected)
{
try
{
bool isDarkTheme = ThemeHelper.IsDarkTheme;
var selectedBrush = isDarkTheme ? new SolidColorBrush(Color.FromRgb(25, 25, 25)) : new SolidColorBrush(Color.FromRgb(225, 225, 225));
var unselectedBrush = new SolidColorBrush(Colors.Transparent);
if (UpdateArchX86Border != null)
{
bool isSel = selected == UpdatePackageArchitecture.X86;
UpdateArchX86Border.Background = isSel ? selectedBrush : unselectedBrush;
var tb = UpdateArchX86Border.Child as TextBlock;
if (tb != null)
{
tb.FontWeight = isSel ? FontWeights.Bold : FontWeights.Normal;
tb.Foreground = ThemeHelper.GetTextPrimaryBrush();
}
}
if (UpdateArchX64Border != null)
{
bool isSel = selected == UpdatePackageArchitecture.X64;
UpdateArchX64Border.Background = isSel ? selectedBrush : unselectedBrush;
var tb = UpdateArchX64Border.Child as TextBlock;
if (tb != null)
{
tb.FontWeight = isSel ? FontWeights.Bold : FontWeights.Normal;
tb.Foreground = ThemeHelper.GetTextPrimaryBrush();
}
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"更新软件架构按钮状态时出错: {ex.Message}");
}
}