diff --git a/src/SimpleAdmin.Api.IntegrationTests/WeChatRouteIntegrationTests.cs b/src/SimpleAdmin.Api.IntegrationTests/WeChatRouteIntegrationTests.cs
index 5c4f785..db21717 100644
--- a/src/SimpleAdmin.Api.IntegrationTests/WeChatRouteIntegrationTests.cs
+++ b/src/SimpleAdmin.Api.IntegrationTests/WeChatRouteIntegrationTests.cs
@@ -32,6 +32,7 @@ public class WeChatRouteIntegrationTests
host.RoutePatterns.Should().Contain("apiwechat/verification");
host.RoutePatterns.Should().Contain("wechat/mp/{appId}");
host.RoutePatterns.Should().Contain("wechat/mp/login-qrcode");
+ host.RoutePatterns.Should().Contain("wechat/mp/oauth-config");
host.RoutePatterns.Should().Contain("wechat/mp/follow-qrcode");
host.RoutePatterns.Should().Contain("wechat/oauth/user-info");
host.RoutePatterns.Should().Contain("wechat/customer/register");
diff --git a/src/SimpleAdmin.Api/Auth/AuthService.WeChatMp.cs b/src/SimpleAdmin.Api/Auth/AuthService.WeChatMp.cs
index 05bc350..850bac3 100644
--- a/src/SimpleAdmin.Api/Auth/AuthService.WeChatMp.cs
+++ b/src/SimpleAdmin.Api/Auth/AuthService.WeChatMp.cs
@@ -159,6 +159,31 @@ public partial class AuthService
cancellationToken);
}
+ ///
+ /// H5 网页授权公开配置:AppId + OAuth 回调根(来自其他配置 wechat_mp)。
+ ///
+ [AllowAnonymous]
+ [HttpGet("/wechat/mp/oauth-config")]
+ [ApiExplorerSettings(GroupName = "WeChat")]
+ public async Task GetWeChatOAuthConfigAsync(
+ CancellationToken cancellationToken = default)
+ {
+ var options = await WeChatMpConfigProvider.GetAsync(cancellationToken);
+ if (string.IsNullOrWhiteSpace(options.AppId))
+ {
+ throw new BusinessException(
+ "未配置微信公众号 AppId。请在「其他配置」维护 wechat_mp,AppKey 填公众号 AppId。");
+ }
+
+ return new WxOAuthConfigOutput
+ {
+ AppId = options.AppId.Trim(),
+ OAuthRedirectBase = string.IsNullOrWhiteSpace(options.OAuthRedirectBase)
+ ? null
+ : options.OAuthRedirectBase.Trim().TrimEnd('/')
+ };
+ }
+
///
/// 获取 PC 扫码登录二维码。
///
diff --git a/src/SimpleAdmin.Api/WeChat/Dtos/WeChatDtos.cs b/src/SimpleAdmin.Api/WeChat/Dtos/WeChatDtos.cs
index f5c09ba..d254466 100644
--- a/src/SimpleAdmin.Api/WeChat/Dtos/WeChatDtos.cs
+++ b/src/SimpleAdmin.Api/WeChat/Dtos/WeChatDtos.cs
@@ -12,6 +12,19 @@ public class WxLoginQrcodeOutput
public int ExpiresIn { get; set; } = 600;
}
+/// H5 网页授权所需公开配置(不含 Secret/Token)。
+public class WxOAuthConfigOutput
+{
+ /// 公众号 AppId(来自其他配置 wechat_mp.AppKey)。
+ public string AppId { get; set; } = string.Empty;
+
+ ///
+ /// OAuth 回调根地址(来自 wechat_mp.BaseUrl),如 https://ideship.com。
+ /// 为空时前端回退到当前页面 origin。
+ ///
+ public string? OAuthRedirectBase { get; set; }
+}
+
/// 引导关注公众号:优先返回可直接跳转的公众号链接。
public class WxFollowQrcodeOutput
{