improve:自动更新
This commit is contained in:
@@ -105,6 +105,71 @@ namespace Ink_Canvas.Helpers
|
||||
}
|
||||
}
|
||||
},
|
||||
{ UpdateChannel.Preview, new List<UpdateLineGroup>
|
||||
{
|
||||
new UpdateLineGroup
|
||||
{
|
||||
GroupName = "GitHub主线",
|
||||
VersionUrl = "https://github.com/InkCanvasForClass/community-beta/raw/refs/heads/main/AutomaticUpdateVersionControl.txt",
|
||||
DownloadUrlFormat = "https://github.com/InkCanvasForClass/community-beta/releases/download/{0}/InkCanvasForClass.CE.{0}.zip",
|
||||
LogUrl = "https://github.com/InkCanvasForClass/community-beta/raw/refs/heads/main/UpdateLog.md"
|
||||
},
|
||||
new UpdateLineGroup
|
||||
{
|
||||
GroupName = "bgithub备用",
|
||||
VersionUrl = "https://bgithub.xyz/InkCanvasForClass/community-beta/raw/refs/heads/main/AutomaticUpdateVersionControl.txt",
|
||||
DownloadUrlFormat = "https://bgithub.xyz/InkCanvasForClass/community-beta/releases/download/{0}/InkCanvasForClass.CE.{0}.zip",
|
||||
LogUrl = "https://bgithub.xyz/InkCanvasForClass/community-beta/raw/refs/heads/main/UpdateLog.md"
|
||||
},
|
||||
new UpdateLineGroup
|
||||
{
|
||||
GroupName = "kkgithub线路",
|
||||
VersionUrl = "https://kkgithub.com/InkCanvasForClass/community-beta/raw/refs/heads/main/AutomaticUpdateVersionControl.txt",
|
||||
DownloadUrlFormat = "https://kkgithub.com/InkCanvasForClass/community-beta/releases/download/{0}/InkCanvasForClass.CE.{0}.zip",
|
||||
LogUrl = "https://kkgithub.com/InkCanvasForClass/community-beta/raw/refs/heads/main/UpdateLog.md"
|
||||
},
|
||||
new UpdateLineGroup
|
||||
{
|
||||
GroupName = "智教联盟",
|
||||
DownloadUrlFormat = "https://get.smart-teach.cn/d/Ningbo-S3/shared/jiangling/community-beta/InkCanvasForClass.CE.{0}.zip",
|
||||
LogUrl = "https://bgithub.xyz/InkCanvasForClass/community-beta/raw/refs/heads/main/UpdateLog.md"
|
||||
},
|
||||
new UpdateLineGroup
|
||||
{
|
||||
GroupName = "inkeys",
|
||||
DownloadUrlFormat = "https://iccce.inkeys.top/Beta/InkCanvasForClass.CE.{0}.zip",
|
||||
LogUrl = "https://bgithub.xyz/InkCanvasForClass/community-beta/raw/refs/heads/main/UpdateLog.md"
|
||||
},
|
||||
new UpdateLineGroup
|
||||
{
|
||||
GroupName = "gh-proxy",
|
||||
VersionUrl = "https://gh-proxy.org/https://raw.githubusercontent.com/InkCanvasForClass/community-beta/refs/heads/main/AutomaticUpdateVersionControl.txt",
|
||||
DownloadUrlFormat = "https://gh-proxy.org/https://github.com/InkCanvasForClass/community-beta/releases/download/{0}/InkCanvasForClass.CE.{0}.zip",
|
||||
LogUrl = "https://gh-proxy.org/https://raw.githubusercontent.com/InkCanvasForClass/community-beta/refs/heads/main/UpdateLog.md"
|
||||
},
|
||||
new UpdateLineGroup
|
||||
{
|
||||
GroupName = "hk.gh-proxy",
|
||||
VersionUrl = "https://hk.gh-proxy.org/https://raw.githubusercontent.com/InkCanvasForClass/community-beta/refs/heads/main/AutomaticUpdateVersionControl.txt",
|
||||
DownloadUrlFormat = "https://hk.gh-proxy.org/https://github.com/InkCanvasForClass/community-beta/releases/download/{0}/InkCanvasForClass.CE.{0}.zip",
|
||||
LogUrl = "https://hk.gh-proxy.org/https://raw.githubusercontent.com/InkCanvasForClass/community-beta/refs/heads/main/UpdateLog.md"
|
||||
},
|
||||
new UpdateLineGroup
|
||||
{
|
||||
GroupName = "cdn.gh-proxy",
|
||||
VersionUrl = "https://cdn.gh-proxy.org/https://raw.githubusercontent.com/InkCanvasForClass/community-beta/refs/heads/main/AutomaticUpdateVersionControl.txt",
|
||||
DownloadUrlFormat = "https://cdn.gh-proxy.org/https://github.com/InkCanvasForClass/community-beta/releases/download/{0}/InkCanvasForClass.CE.{0}.zip",
|
||||
LogUrl = "https://cdn.gh-proxy.org/https://raw.githubusercontent.com/InkCanvasForClass/community-beta/refs/heads/main/UpdateLog.md"
|
||||
},
|
||||
new UpdateLineGroup
|
||||
{
|
||||
GroupName = "edgeone.gh-proxy",
|
||||
VersionUrl = "https://edgeone.gh-proxy.org/https://raw.githubusercontent.com/InkCanvasForClass/community-beta/refs/heads/main/AutomaticUpdateVersionControl.txt",
|
||||
DownloadUrlFormat = "https://edgeone.gh-proxy.org/https://github.com/InkCanvasForClass/community-beta/releases/download/{0}/InkCanvasForClass.CE.{0}.zip",
|
||||
LogUrl = "https://edgeone.gh-proxy.org/https://raw.githubusercontent.com/InkCanvasForClass/community-beta/refs/heads/main/UpdateLog.md"
|
||||
}
|
||||
}
|
||||
},
|
||||
{ UpdateChannel.Beta, new List<UpdateLineGroup>
|
||||
{
|
||||
new UpdateLineGroup
|
||||
@@ -527,7 +592,7 @@ namespace Ink_Canvas.Helpers
|
||||
{
|
||||
try
|
||||
{
|
||||
string apiUrl = channel == UpdateChannel.Beta
|
||||
string apiUrl = (channel == UpdateChannel.Beta || channel == UpdateChannel.Preview)
|
||||
? "https://api.github.com/repos/InkCanvasForClass/community-beta/releases"
|
||||
: "https://api.github.com/repos/InkCanvasForClass/community/releases";
|
||||
using (var client = new HttpClient())
|
||||
@@ -569,7 +634,37 @@ namespace Ink_Canvas.Helpers
|
||||
{
|
||||
try
|
||||
{
|
||||
string apiUrl = channel == UpdateChannel.Beta
|
||||
if (channel == UpdateChannel.Beta)
|
||||
{
|
||||
string apiUrl = "https://api.github.com/repos/InkCanvasForClass/community-beta/releases";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Add("User-Agent", "ICC-CE Auto Updater");
|
||||
LogHelper.WriteLogToFile("AutoUpdate | 使用GitHub API调用");
|
||||
var response = await client.GetStringAsync(apiUrl);
|
||||
var releases = JArray.Parse(response);
|
||||
|
||||
if (releases.Count > 0)
|
||||
{
|
||||
var latestRelease = releases[0];
|
||||
string version = latestRelease["tag_name"]?.ToString();
|
||||
string releaseNotes = latestRelease["body"]?.ToString();
|
||||
string downloadUrl = latestRelease["assets"]?.First?["browser_download_url"]?.ToString();
|
||||
|
||||
DateTime? releaseTime = null;
|
||||
if (latestRelease["published_at"] != null && DateTime.TryParse(latestRelease["published_at"].ToString(), out DateTime parsedTime))
|
||||
{
|
||||
releaseTime = parsedTime;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(version) && !string.IsNullOrEmpty(downloadUrl))
|
||||
return (version, downloadUrl, releaseNotes, releaseTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string apiUrl = channel == UpdateChannel.Preview
|
||||
? "https://api.github.com/repos/InkCanvasForClass/community-beta/releases/latest"
|
||||
: "https://api.github.com/repos/InkCanvasForClass/community/releases/latest";
|
||||
using (var client = new HttpClient())
|
||||
@@ -582,7 +677,6 @@ namespace Ink_Canvas.Helpers
|
||||
string releaseNotes = json["body"]?.ToString();
|
||||
string downloadUrl = json["assets"]?.First?["browser_download_url"]?.ToString();
|
||||
|
||||
// 解析发布时间
|
||||
DateTime? releaseTime = null;
|
||||
if (json["published_at"] != null && DateTime.TryParse(json["published_at"].ToString(), out DateTime parsedTime))
|
||||
{
|
||||
@@ -593,6 +687,7 @@ namespace Ink_Canvas.Helpers
|
||||
return (version, downloadUrl, releaseNotes, releaseTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | GitHub Releases API 获取失败: {ex.Message}", LogHelper.LogType.Warning);
|
||||
@@ -2023,7 +2118,7 @@ namespace Ink_Canvas.Helpers
|
||||
var result = new List<(string, string, string)>();
|
||||
try
|
||||
{
|
||||
string apiUrl = channel == UpdateChannel.Beta
|
||||
string apiUrl = (channel == UpdateChannel.Beta || channel == UpdateChannel.Preview)
|
||||
? "https://api.github.com/repos/InkCanvasForClass/community-beta/releases"
|
||||
: "https://api.github.com/repos/InkCanvasForClass/community/releases";
|
||||
using (var client = new HttpClient())
|
||||
|
||||
@@ -642,10 +642,12 @@
|
||||
<ui:RadioButtons x:Name="UpdateChannelSelector" Margin="0,4,0,0">
|
||||
<RadioButton Content="稳定版 (Release)" GroupName="UpdateChannel"
|
||||
Tag="Release" Checked="UpdateChannelSelector_Checked"/>
|
||||
<RadioButton Content="预览版 (Preview)" GroupName="UpdateChannel"
|
||||
Tag="Preview" Checked="UpdateChannelSelector_Checked"/>
|
||||
<RadioButton Content="测试版 (Beta)" GroupName="UpdateChannel"
|
||||
Tag="Beta" Checked="UpdateChannelSelector_Checked"/>
|
||||
</ui:RadioButtons>
|
||||
<TextBlock Text="# 稳定版提供可靠更新,测试版提供新功能抢先体验" TextWrapping="Wrap" Foreground="#a1a1aa" />
|
||||
<TextBlock Text="# 稳定版提供可靠更新,预览版提供新功能体验同时拥有相较Beta版更强的稳定性,测试版提供新功能抢先体验" TextWrapping="Wrap" Foreground="#a1a1aa" />
|
||||
</ui:SimpleStackPanel>
|
||||
|
||||
<!-- 手动更新按钮 -->
|
||||
|
||||
@@ -3827,7 +3827,9 @@ namespace Ink_Canvas
|
||||
if (radioButton != null)
|
||||
{
|
||||
string channel = radioButton.Tag.ToString();
|
||||
UpdateChannel newChannel = channel == "Beta" ? UpdateChannel.Beta : UpdateChannel.Release;
|
||||
UpdateChannel newChannel = channel == "Beta" ? UpdateChannel.Beta
|
||||
: channel == "Preview" ? UpdateChannel.Preview
|
||||
: UpdateChannel.Release;
|
||||
|
||||
// 如果通道没有变化,不需要执行更新检查
|
||||
if (Settings.Startup.UpdateChannel == newChannel)
|
||||
|
||||
@@ -140,6 +140,7 @@ namespace Ink_Canvas
|
||||
public enum UpdateChannel
|
||||
{
|
||||
Release,
|
||||
Preview,
|
||||
Beta
|
||||
}
|
||||
|
||||
|
||||
@@ -128,6 +128,9 @@
|
||||
<Border x:Name="UpdateChannelReleaseBorder" Padding="13,7" CornerRadius="8" Background="#e1e1e1" Cursor="Hand" Tag="UpdateChannel_Release" Margin="0,0,8,8" MouseLeftButtonDown="OptionButton_Click">
|
||||
<TextBlock Foreground="#2e3436" FontSize="14" FontWeight="Bold" Text="稳定版"/>
|
||||
</Border>
|
||||
<Border x:Name="UpdateChannelPreviewBorder" Padding="13,7" CornerRadius="8" Cursor="Hand" Tag="UpdateChannel_Preview" Margin="0,0,8,8" MouseLeftButtonDown="OptionButton_Click">
|
||||
<TextBlock Foreground="#2e3436" FontSize="14" Text="预览版"/>
|
||||
</Border>
|
||||
<Border x:Name="UpdateChannelBetaBorder" Padding="13,7" CornerRadius="8" Cursor="Hand" Tag="UpdateChannel_Beta" Margin="0,0,8,8" MouseLeftButtonDown="OptionButton_Click">
|
||||
<TextBlock Foreground="#2e3436" FontSize="14" Text="测试版"/>
|
||||
</Border>
|
||||
|
||||
@@ -182,11 +182,15 @@ namespace Ink_Canvas.Windows.SettingsViews
|
||||
// 更新通道
|
||||
if (MainWindow.Settings.Startup.UpdateChannel == UpdateChannel.Release)
|
||||
{
|
||||
UpdateUpdateChannelButtons(true);
|
||||
UpdateUpdateChannelButtons(UpdateChannel.Release);
|
||||
}
|
||||
else if (MainWindow.Settings.Startup.UpdateChannel == UpdateChannel.Preview)
|
||||
{
|
||||
UpdateUpdateChannelButtons(UpdateChannel.Preview);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateUpdateChannelButtons(false);
|
||||
UpdateUpdateChannelButtons(UpdateChannel.Beta);
|
||||
}
|
||||
|
||||
// 仅PPT模式
|
||||
@@ -356,7 +360,20 @@ namespace Ink_Canvas.Windows.SettingsViews
|
||||
MainWindowSettingsHelper.InvokeMainWindowMethod("UpdateChannelSelector_Checked",
|
||||
new System.Windows.Controls.RadioButton { Tag = "Release" }, e);
|
||||
// 更新UI状态
|
||||
UpdateUpdateChannelButtons(true);
|
||||
UpdateUpdateChannelButtons(UpdateChannel.Release);
|
||||
break;
|
||||
|
||||
case "UpdateChannel_Preview":
|
||||
// 选择预览版
|
||||
MainWindowSettingsHelper.UpdateSettingDirectly(() =>
|
||||
{
|
||||
MainWindow.Settings.Startup.UpdateChannel = UpdateChannel.Preview;
|
||||
}, "UpdateChannelSelector");
|
||||
// 调用 MainWindow 中的方法
|
||||
MainWindowSettingsHelper.InvokeMainWindowMethod("UpdateChannelSelector_Checked",
|
||||
new System.Windows.Controls.RadioButton { Tag = "Preview" }, e);
|
||||
// 更新UI状态
|
||||
UpdateUpdateChannelButtons(UpdateChannel.Preview);
|
||||
break;
|
||||
|
||||
case "UpdateChannel_Beta":
|
||||
@@ -369,7 +386,7 @@ namespace Ink_Canvas.Windows.SettingsViews
|
||||
MainWindowSettingsHelper.InvokeMainWindowMethod("UpdateChannelSelector_Checked",
|
||||
new System.Windows.Controls.RadioButton { Tag = "Beta" }, e);
|
||||
// 更新UI状态
|
||||
UpdateUpdateChannelButtons(false);
|
||||
UpdateUpdateChannelButtons(UpdateChannel.Beta);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -377,34 +394,46 @@ namespace Ink_Canvas.Windows.SettingsViews
|
||||
/// <summary>
|
||||
/// 更新更新通道按钮状态
|
||||
/// </summary>
|
||||
private void UpdateUpdateChannelButtons(bool isReleaseSelected)
|
||||
private void UpdateUpdateChannelButtons(UpdateChannel selectedChannel)
|
||||
{
|
||||
try
|
||||
{
|
||||
bool isDarkTheme = ThemeHelper.IsDarkTheme;
|
||||
var selectedBrush = isDarkTheme ? ThemeHelper.GetButtonBackgroundBrush() : new SolidColorBrush(Color.FromRgb(225, 225, 225));
|
||||
var unselectedBrush = isDarkTheme ? new SolidColorBrush(Color.FromRgb(35, 35, 35)) : new SolidColorBrush(Colors.Transparent);
|
||||
|
||||
if (UpdateChannelReleaseBorder != null)
|
||||
{
|
||||
UpdateChannelReleaseBorder.Background = isReleaseSelected
|
||||
? (isDarkTheme ? ThemeHelper.GetButtonBackgroundBrush() : new SolidColorBrush(Color.FromRgb(225, 225, 225)))
|
||||
: (isDarkTheme ? new SolidColorBrush(Color.FromRgb(35, 35, 35)) : new SolidColorBrush(Colors.Transparent));
|
||||
bool isSelected = selectedChannel == UpdateChannel.Release;
|
||||
UpdateChannelReleaseBorder.Background = isSelected ? selectedBrush : unselectedBrush;
|
||||
var textBlock = UpdateChannelReleaseBorder.Child as TextBlock;
|
||||
if (textBlock != null)
|
||||
{
|
||||
textBlock.FontWeight = isReleaseSelected ? FontWeights.Bold : FontWeights.Normal;
|
||||
textBlock.FontWeight = isSelected ? FontWeights.Bold : FontWeights.Normal;
|
||||
textBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
|
||||
}
|
||||
}
|
||||
|
||||
if (UpdateChannelPreviewBorder != null)
|
||||
{
|
||||
bool isSelected = selectedChannel == UpdateChannel.Preview;
|
||||
UpdateChannelPreviewBorder.Background = isSelected ? selectedBrush : unselectedBrush;
|
||||
var textBlock = UpdateChannelPreviewBorder.Child as TextBlock;
|
||||
if (textBlock != null)
|
||||
{
|
||||
textBlock.FontWeight = isSelected ? FontWeights.Bold : FontWeights.Normal;
|
||||
textBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
|
||||
}
|
||||
}
|
||||
|
||||
if (UpdateChannelBetaBorder != null)
|
||||
{
|
||||
UpdateChannelBetaBorder.Background = !isReleaseSelected
|
||||
? (isDarkTheme ? ThemeHelper.GetButtonBackgroundBrush() : new SolidColorBrush(Color.FromRgb(225, 225, 225)))
|
||||
: (isDarkTheme ? new SolidColorBrush(Color.FromRgb(35, 35, 35)) : new SolidColorBrush(Colors.Transparent));
|
||||
bool isSelected = selectedChannel == UpdateChannel.Beta;
|
||||
UpdateChannelBetaBorder.Background = isSelected ? selectedBrush : unselectedBrush;
|
||||
var textBlock = UpdateChannelBetaBorder.Child as TextBlock;
|
||||
if (textBlock != null)
|
||||
{
|
||||
textBlock.FontWeight = !isReleaseSelected ? FontWeights.Bold : FontWeights.Normal;
|
||||
textBlock.FontWeight = isSelected ? FontWeights.Bold : FontWeights.Normal;
|
||||
textBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
|
||||
}
|
||||
}
|
||||
@@ -478,11 +507,22 @@ namespace Ink_Canvas.Windows.SettingsViews
|
||||
textBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
|
||||
}
|
||||
}
|
||||
if (UpdateChannelPreviewBorder != null)
|
||||
{
|
||||
UpdateChannelPreviewBorder.Background = isDarkTheme
|
||||
? ThemeHelper.GetButtonBackgroundBrush()
|
||||
: new SolidColorBrush(Color.FromRgb(225, 225, 225));
|
||||
var textBlock = UpdateChannelPreviewBorder.Child as TextBlock;
|
||||
if (textBlock != null)
|
||||
{
|
||||
textBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
|
||||
}
|
||||
}
|
||||
if (UpdateChannelBetaBorder != null)
|
||||
{
|
||||
UpdateChannelBetaBorder.Background = isDarkTheme
|
||||
? new SolidColorBrush(Color.FromRgb(35, 35, 35))
|
||||
: new SolidColorBrush(Colors.Transparent);
|
||||
? ThemeHelper.GetButtonBackgroundBrush()
|
||||
: new SolidColorBrush(Color.FromRgb(225, 225, 225));
|
||||
var textBlock = UpdateChannelBetaBorder.Child as TextBlock;
|
||||
if (textBlock != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user