From 7633dbfef283a96cf5b07d6401501892b19399e5 Mon Sep 17 00:00:00 2001 From: uye <99072975+ABA2396@users.noreply.github.com> Date: Wed, 27 Sep 2023 13:28:29 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E7=BB=9F=E4=B8=80=20URL=20=E5=AD=98?= =?UTF-8?q?=E6=94=BE=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaWpfGui/Constants/MaaUrls.cs | 10 ++++++++++ src/MaaWpfGui/Models/ResourceUpdater.cs | 8 ++++---- src/MaaWpfGui/Services/Web/MaaApiService.cs | 4 ++-- src/MaaWpfGui/ViewModels/UI/CopilotViewModel.cs | 7 +++---- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/MaaWpfGui/Constants/MaaUrls.cs b/src/MaaWpfGui/Constants/MaaUrls.cs index 022a92a404..1aa672553d 100644 --- a/src/MaaWpfGui/Constants/MaaUrls.cs +++ b/src/MaaWpfGui/Constants/MaaUrls.cs @@ -22,6 +22,8 @@ namespace MaaWpfGui.Constants public const string Bilibili = "https://space.bilibili.com/3493274731940507"; + public const string BilibiliVideo = "https://www.bilibili.com/video/"; + public const string GitHub = "https://github.com/MaaAssistantArknights/MaaAssistantArknights"; public const string GitHubIssues = "https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues"; @@ -30,10 +32,18 @@ namespace MaaWpfGui.Constants public const string PrtsPlus = "https://prts.plus"; + public const string PrtsPlusCopilotGet = "https://www.maa.plus/copilot/get/"; + + public const string PrtsPlusCopilotRating = "https://prts.maa.plus/copilot/rating"; + public const string MapPrts = "https://map.ark-nights.com/areas?coord_override=maa"; public const string CustomInfrastGenerator = "https://yituliu.site/tools/maa"; + public const string MaaApi = "https://ota.maa.plus/MaaAssistantArknights/api/"; + + public const string MaaResourceApi = "https://ota.maa.plus/MaaAssistantArknights/MaaAssistantArknights/"; + public const string QqGroups = "https://ota.maa.plus/MaaAssistantArknights/api/qqgroup/index.html"; public const string QqChannel = "https://pd.qq.com/s/4j1ju9z47"; diff --git a/src/MaaWpfGui/Models/ResourceUpdater.cs b/src/MaaWpfGui/Models/ResourceUpdater.cs index b0e81b1616..3f36fd49e6 100644 --- a/src/MaaWpfGui/Models/ResourceUpdater.cs +++ b/src/MaaWpfGui/Models/ResourceUpdater.cs @@ -4,6 +4,7 @@ using System.IO; using System.Linq; using System.Net.Http; using System.Threading.Tasks; +using MaaWpfGui.Constants; using MaaWpfGui.Helper; using Stylet; @@ -11,7 +12,6 @@ namespace MaaWpfGui.Models { public static class ResourceUpdater { - private const string MaaResourceApi = "https://ota.maa.plus/MaaAssistantArknights/MaaAssistantArknights/"; private static readonly List _maaSingleFiles = new List { @@ -86,7 +86,7 @@ namespace MaaWpfGui.Models foreach (var file in _maaSingleFiles) { - var sRet = await UpdateFileWithETag(MaaResourceApi, file, file); + var sRet = await UpdateFileWithETag(MaaUrls.MaaResourceApi, file, file); if (sRet == UpdateResult.Failed) { @@ -106,7 +106,7 @@ namespace MaaWpfGui.Models // 这些文件数量不固定,需要先获取索引文件,再根据索引文件下载 private static async Task UpdateFilesWithIndex() { - var indexSRet = await UpdateFileWithETag(MaaResourceApi, MaaDynamicFilesIndex, MaaDynamicFilesIndex); + var indexSRet = await UpdateFileWithETag(MaaUrls.MaaResourceApi, MaaDynamicFilesIndex, MaaDynamicFilesIndex); if (indexSRet == UpdateResult.Failed || indexSRet == UpdateResult.NotModified) { return indexSRet; @@ -134,7 +134,7 @@ namespace MaaWpfGui.Models return; } - var sRet = await UpdateFileWithETag(MaaResourceApi, file, file); + var sRet = await UpdateFileWithETag(MaaUrls.MaaResourceApi, file, file); if (sRet == UpdateResult.Failed) { ret = UpdateResult.Failed; diff --git a/src/MaaWpfGui/Services/Web/MaaApiService.cs b/src/MaaWpfGui/Services/Web/MaaApiService.cs index 0229534623..814b4a3933 100644 --- a/src/MaaWpfGui/Services/Web/MaaApiService.cs +++ b/src/MaaWpfGui/Services/Web/MaaApiService.cs @@ -14,6 +14,7 @@ using System; using System.IO; using System.Threading.Tasks; +using MaaWpfGui.Constants; using MaaWpfGui.Helper; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -23,7 +24,6 @@ namespace MaaWpfGui.Services.Web public class MaaApiService : IMaaApiService { private const string CacheDir = "cache/"; - private const string MaaApi = "https://ota.maa.plus/MaaAssistantArknights/api/"; public MaaApiService() { @@ -31,7 +31,7 @@ namespace MaaWpfGui.Services.Web public async Task RequestMaaApiWithCache(string api) { - var url = MaaApi + api; + var url = MaaUrls.MaaApi + api; var response = await Instances.HttpService.GetStringAsync(new Uri(url)); if (response == null) diff --git a/src/MaaWpfGui/ViewModels/UI/CopilotViewModel.cs b/src/MaaWpfGui/ViewModels/UI/CopilotViewModel.cs index 9173e863e5..c1da920bcf 100644 --- a/src/MaaWpfGui/ViewModels/UI/CopilotViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/CopilotViewModel.cs @@ -224,7 +224,7 @@ namespace MaaWpfGui.ViewModels.UI { try { - var jsonResponse = await Instances.HttpService.GetStringAsync(new Uri($"https://prts.maa.plus/copilot/get/{copilotId}")); + var jsonResponse = await Instances.HttpService.GetStringAsync(new Uri(MaaUrls.PrtsPlusCopilotGet + copilotId)); var json = (JObject)JsonConvert.DeserializeObject(jsonResponse); if (json != null && json.ContainsKey("status_code") && json["status_code"]?.ToString() == "200") { @@ -302,7 +302,7 @@ namespace MaaWpfGui.ViewModels.UI var linkParser = new Regex(@"AV\d+|(BV.*?).{10}", RegexOptions.Compiled | RegexOptions.IgnoreCase); foreach (Match match in linkParser.Matches(details)) { - Url = "https://www.bilibili.com/video/" + match.Value; + Url = MaaUrls.BilibiliVideo + match.Value; break; } @@ -832,7 +832,6 @@ namespace MaaWpfGui.ViewModels.UI private bool _isVideoTask; - private const string CopilotRatingUrl = "https://prts.maa.plus/copilot/rating"; private readonly List _recentlyRatedCopilotId = new List(); // TODO: 可能考虑加个持久化 private bool _couldLikeWebJson; @@ -903,7 +902,7 @@ namespace MaaWpfGui.ViewModels.UI rating, }); */ - var response = await Instances.HttpService.PostAsJsonAsync(new Uri(CopilotRatingUrl), new { id = CopilotId, rating }); + var response = await Instances.HttpService.PostAsJsonAsync(new Uri(MaaUrls.PrtsPlusCopilotRating), new { id = CopilotId, rating }); if (response == null) { AddLog(LocalizationHelper.GetString("FailedToLikeWebJson"), UiLogColor.Error);