diff --git a/server/HoneyBox/src/HoneyBox.Core/Services/InvitationService.cs b/server/HoneyBox/src/HoneyBox.Core/Services/InvitationService.cs index fd4056fb..0874830d 100644 --- a/server/HoneyBox/src/HoneyBox.Core/Services/InvitationService.cs +++ b/server/HoneyBox/src/HoneyBox.Core/Services/InvitationService.cs @@ -72,7 +72,7 @@ public class InvitationService : IInvitationService // 获取分享配置 var shareTitle = await GetShareTitleAsync(); - var shareImage = string.Empty; // 海报图片需要单独生成,这里暂时返回空 + var shareImage = await GetShareImageAsync(); return new InvitationInfoResponse { @@ -255,5 +255,35 @@ public class InvitationService : IInvitationService return string.Empty; } + /// + /// 获取分享海报图片配置 + /// + /// 分享海报图片URL + private async Task GetShareImageAsync() + { + var config = await _dbContext.Configs + .FirstOrDefaultAsync(c => c.ConfigKey == "base"); + + if (config?.ConfigValue == null) + { + return string.Empty; + } + + try + { + var jsonDoc = JsonSerializer.Deserialize(config.ConfigValue); + if (jsonDoc.TryGetProperty("share_image", out var shareImage)) + { + return shareImage.GetString() ?? string.Empty; + } + } + catch (Exception ex) + { + _logger.LogWarning(ex, "解析分享海报图片配置失败"); + } + + return string.Empty; + } + #endregion }