Skip to content

Commit d0bfe21

Browse files
committed
更新检查版本更新的方式
1 parent 59fa8ae commit d0bfe21

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

Edge.csproj

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,13 @@
3636

3737
<ItemGroup>
3838
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
39-
<PackageReference Include="CommunityToolkit.WinUI.Controls.SettingsControls" Version="8.0.240109" />
40-
<PackageReference Include="CommunityToolkit.WinUI.Converters" Version="8.0.240109" />
39+
<PackageReference Include="CommunityToolkit.WinUI.Controls.SettingsControls" Version="8.1.240328-rc" />
40+
<PackageReference Include="CommunityToolkit.WinUI.Converters" Version="8.1.240328-rc" />
4141
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.49-beta" />
42-
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240311000" />
42+
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240404000" />
4343
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.3233" />
4444
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
45-
<PackageReference Include="Octokit" Version="10.0.0" />
46-
<PackageReference Include="System.Text.Encoding.CodePages" Version="9.0.0-preview.2.24128.5" />
45+
<PackageReference Include="System.Text.Encoding.CodePages" Version="9.0.0-preview.3.24172.9" />
4746
<Manifest Include="$(ApplicationManifest)" />
4847
</ItemGroup>
4948

Settings/AboutItem.xaml.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
using Microsoft.UI.Xaml.Controls;
44
using Microsoft.Windows.AppNotifications;
55
using Microsoft.Windows.AppNotifications.Builder;
6+
using Newtonsoft.Json.Linq;
7+
using System.Linq;
8+
using System.Net.Http;
9+
using System.Net.Http.Headers;
610
using Windows.ApplicationModel;
711
using Windows.ApplicationModel.DataTransfer;
812

@@ -25,8 +29,15 @@ private async void CheckAppVersion(object sender, RoutedEventArgs e)
2529
{
2630
if (App.LatestVersion == null)
2731
{
28-
Octokit.GitHubClient client = new(new Octokit.ProductHeaderValue("Edge"));
29-
App.LatestVersion = (await client.Repository.GetAllTags("wtcpython", "WinUIEdge"))[0].Name[1..];
32+
HttpClient httpClient = new();
33+
httpClient.DefaultRequestHeaders.UserAgent.TryParseAdd("wtcpython/WinUIEdge 1.0");
34+
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/vnd.github.v3+json"));
35+
36+
HttpResponseMessage response = await httpClient.GetAsync("https://api.github.com/repos/wtcpython/WinUIEdge/tags");
37+
38+
string content = await response.Content.ReadAsStringAsync();
39+
40+
App.LatestVersion = JArray.Parse(content).First()["name"].ToString()[1..];
3041
}
3142
if (App.LatestVersion.CompareTo(appVersion) > 0)
3243
{
@@ -41,7 +52,7 @@ private async void CheckAppVersion(object sender, RoutedEventArgs e)
4152
notificationManager.Show(builder.BuildNotification());
4253
}
4354
}
44-
catch (Octokit.RateLimitExceededException) { }
55+
catch (HttpRequestException) { }
4556
}
4657

4758
private void CopyText(string text)

0 commit comments

Comments
 (0)