diff --git a/CnGalWebSite/CnGalWebSite.APIServer/Application/GPT/ChatGPTService.cs b/CnGalWebSite/CnGalWebSite.APIServer/Application/GPT/ChatGPTService.cs index 4586fa993..d3334b362 100644 --- a/CnGalWebSite/CnGalWebSite.APIServer/Application/GPT/ChatGPTService.cs +++ b/CnGalWebSite/CnGalWebSite.APIServer/Application/GPT/ChatGPTService.cs @@ -21,7 +21,6 @@ public class ChatGPTService:IChatGPTService private readonly IHttpService _httpService; private readonly IConfiguration _configuration; private readonly List _record = new List(); - private readonly HttpClient _httpClient; private readonly ILogger _logger; private readonly JsonSerializerOptions _jsonOptions = new() @@ -34,13 +33,18 @@ public ChatGPTService(IHttpService httpService, IConfiguration configuration, IL _httpService = httpService; _configuration = configuration; _logger = logger; - - _httpClient = _httpService.GetClient(); - _httpClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + _configuration["ChatGPTApiKey"]); } public async Task< string > GetReply(string question) { + HttpClient _httpClient = null; + if (_httpClient == null) + { + _httpClient =await _httpService.GetClientAsync(); + _httpClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + _configuration["ChatGPTApiKey"]); + } + + var datetime= DateTime.Now.ToCstTime(); //检查上限 diff --git a/CnGalWebSite/CnGalWebSite.Core/Services/IHttpService.cs b/CnGalWebSite/CnGalWebSite.Core/Services/IHttpService.cs index 9ce77521a..845983d39 100644 --- a/CnGalWebSite/CnGalWebSite.Core/Services/IHttpService.cs +++ b/CnGalWebSite/CnGalWebSite.Core/Services/IHttpService.cs @@ -15,7 +15,5 @@ public interface IHttpService bool IsAuth { get; set; } Task GetClientAsync(); - - HttpClient GetClient(); } } diff --git a/CnGalWebSite/CnGalWebSite.IdentityServer.Admin.SSR/Services/HttpService.cs b/CnGalWebSite/CnGalWebSite.IdentityServer.Admin.SSR/Services/HttpService.cs index cdcab3d7d..285c43840 100644 --- a/CnGalWebSite/CnGalWebSite.IdentityServer.Admin.SSR/Services/HttpService.cs +++ b/CnGalWebSite/CnGalWebSite.IdentityServer.Admin.SSR/Services/HttpService.cs @@ -64,10 +64,5 @@ public async Task GetClientAsync() _client.SetBearerToken(token); return _client; } - - public HttpClient GetClient() - { - return GetClientAsync().GetAwaiter().GetResult(); - } } } diff --git a/CnGalWebSite/CnGalWebSite.PublicToolbox/PostTools/VideoService.cs b/CnGalWebSite/CnGalWebSite.PublicToolbox/PostTools/VideoService.cs index d21285a26..8e33b1513 100644 --- a/CnGalWebSite/CnGalWebSite.PublicToolbox/PostTools/VideoService.cs +++ b/CnGalWebSite/CnGalWebSite.PublicToolbox/PostTools/VideoService.cs @@ -100,7 +100,7 @@ public async Task GetVideoContext(RepostVideoModel item, I OnProgressUpdate(item, OutputLevel.Infor, $"获取视频内容"); //获取视频内容 - var json = await _httpService.GetClient().GetStringAsync(ToolHelper.WebApiPath + "api/thirdparties/GetBilibiliVideoInfor?id=" + model.Relevances.BilibiliId); + var json = await(await _httpService.GetClientAsync()).GetStringAsync(ToolHelper.WebApiPath + "api/thirdparties/GetBilibiliVideoInfor?id=" + model.Relevances.BilibiliId); var data = JObject.Parse(json); if (data["code"].ToObject() != 0) diff --git a/CnGalWebSite/CnGalWebSite.Server/Services/HttpService.cs b/CnGalWebSite/CnGalWebSite.Server/Services/HttpService.cs index 0a6c29767..c952897a3 100644 --- a/CnGalWebSite/CnGalWebSite.Server/Services/HttpService.cs +++ b/CnGalWebSite/CnGalWebSite.Server/Services/HttpService.cs @@ -66,15 +66,5 @@ public async Task GetClientAsync() _client.SetBearerToken(token); return _client; } - - public HttpClient GetClient() - { - var state = _authenticationStateProvider.GetAuthenticationStateAsync().GetAwaiter().GetResult(); - var token = _tokenManagementService.GetUserAccessTokenAsync(state.User).GetAwaiter().GetResult(); - - _client.SetBearerToken(token); - return _client; - - } } } diff --git a/CnGalWebSite/CnGalWebSite.Shared/Component/Entries/Relevances/Normal/RelevanceOtherTip.razor b/CnGalWebSite/CnGalWebSite.Shared/Component/Entries/Relevances/Normal/RelevanceOtherTip.razor index fafaba487..8531d8391 100644 --- a/CnGalWebSite/CnGalWebSite.Shared/Component/Entries/Relevances/Normal/RelevanceOtherTip.razor +++ b/CnGalWebSite/CnGalWebSite.Shared/Component/Entries/Relevances/Normal/RelevanceOtherTip.razor @@ -68,6 +68,7 @@ "中文维基百科" => "Wiki.png", "月幕Galgame" => "YMGal.png", "Bilibili" => "bilibili.png", + "bilibili" => "bilibili.png", "WikiData" => "Wikidata.png", "微博" => "weibo.png", "AcFun" => "AcFun.png", @@ -103,7 +104,7 @@ { return Model.DisplayName switch { - "Bilibili" => IsVideo ? "前往 bilibili 观看" : Model.DisplayName, + "bilibili" => IsVideo ? "前往 bilibili 观看" : Model.DisplayName, _ => Model.DisplayName }; }