mirror of
https://github.com/jie65535/GrasscutterCommandGenerator.git
synced 2025-08-02 16:59:14 +08:00
Update Check Gitee
This commit is contained in:
parent
ad4ca74e71
commit
7dc7c7c8ac
@ -142,7 +142,7 @@ namespace GrasscutterTools.Forms
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var info = Github.ReleaseAPI.GetReleasesLastest("jie65535", "GrasscutterCommandGenerator").Result;
|
var info = ReleaseAPI.GetReleasesLastest("jie65535", "GrasscutterCommandGenerator").Result;
|
||||||
if (Version.TryParse(info.TagName.Substring(1), out Version lastestVersion) && AppVersion < lastestVersion)
|
if (Version.TryParse(info.TagName.Substring(1), out Version lastestVersion) && AppVersion < lastestVersion)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(Settings.Default.CheckedLastVersion)
|
if (!string.IsNullOrEmpty(Settings.Default.CheckedLastVersion)
|
||||||
|
@ -85,7 +85,6 @@
|
|||||||
<Compile Include="Game\ItemMap.cs" />
|
<Compile Include="Game\ItemMap.cs" />
|
||||||
<Compile Include="Game\SetStatsCommand.cs" />
|
<Compile Include="Game\SetStatsCommand.cs" />
|
||||||
<Compile Include="Game\TextMapData.cs" />
|
<Compile Include="Game\TextMapData.cs" />
|
||||||
<Compile Include="Github\ReleaseAPI.cs" />
|
|
||||||
<Compile Include="GOOD\GOOD.cs" />
|
<Compile Include="GOOD\GOOD.cs" />
|
||||||
<Compile Include="GOOD\Artifact.cs" />
|
<Compile Include="GOOD\Artifact.cs" />
|
||||||
<Compile Include="GOOD\Character.cs" />
|
<Compile Include="GOOD\Character.cs" />
|
||||||
@ -102,6 +101,7 @@
|
|||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Utils\ArtifactUtils.cs" />
|
<Compile Include="Utils\ArtifactUtils.cs" />
|
||||||
<Compile Include="Utils\HttpHelper.cs" />
|
<Compile Include="Utils\HttpHelper.cs" />
|
||||||
|
<Compile Include="Utils\ReleaseAPI.cs" />
|
||||||
<EmbeddedResource Include="Forms\FormGachaBannerEditor2.en-us.resx">
|
<EmbeddedResource Include="Forms\FormGachaBannerEditor2.en-us.resx">
|
||||||
<DependentUpon>FormGachaBannerEditor2.cs</DependentUpon>
|
<DependentUpon>FormGachaBannerEditor2.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
@ -1,32 +1,12 @@
|
|||||||
/**
|
using System;
|
||||||
* Grasscutter Tools
|
|
||||||
* Copyright (C) 2022 jie65535
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published
|
|
||||||
* by the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
using System;
|
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using GrasscutterTools.Utils;
|
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace GrasscutterTools.Github
|
namespace GrasscutterTools.Utils
|
||||||
{
|
{
|
||||||
public static class ReleaseAPI
|
internal class ReleaseAPI
|
||||||
{
|
{
|
||||||
public static async Task<ReleaseInfo> GetReleasesLastest(string username, string repo)
|
public static async Task<ReleaseInfo> GetReleasesLastest(string username, string repo)
|
||||||
{
|
{
|
||||||
@ -36,6 +16,13 @@ namespace GrasscutterTools.Github
|
|||||||
HttpHelper.HttpClient.DefaultRequestHeaders.UserAgent.Add(headerValue);
|
HttpHelper.HttpClient.DefaultRequestHeaders.UserAgent.Add(headerValue);
|
||||||
return await HttpHelper.GetAsync<ReleaseInfo>($"https://api.github.com/repos/{username}/{repo}/releases/latest");
|
return await HttpHelper.GetAsync<ReleaseInfo>($"https://api.github.com/repos/{username}/{repo}/releases/latest");
|
||||||
}
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// 如果Github无法访问,尝试从Gitee获取
|
||||||
|
var release = await HttpHelper.GetAsync<ReleaseInfo>($"https://gitee.com/api/v5/repos/{username}/{repo}/releases/latest");
|
||||||
|
release.Url = $"https://gitee.com/{username}/{repo}/releases";
|
||||||
|
return release;
|
||||||
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
HttpHelper.HttpClient.DefaultRequestHeaders.UserAgent.Remove(headerValue);
|
HttpHelper.HttpClient.DefaultRequestHeaders.UserAgent.Remove(headerValue);
|
Loading…
Reference in New Issue
Block a user