From ef12db52a01031940db8af57b2dd12b403761a50 Mon Sep 17 00:00:00 2001 From: xiaolipro <2357729423@qq.com> Date: Mon, 7 Sep 2026 16:16:15 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20.gitea/workflows/deplo?= =?UTF-8?q?y.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 触发构建 --- .gitea/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 9da703b..9d38b61 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -1,4 +1,4 @@ -# 复制到 admin .gitea/workflows/deploy.yml +# 复制到 admin .gitea/workflows/deploy.yml name: Build and Deploy on: From 937f0bb78bb61946703ac4e77349fbe47152c1a5 Mon Sep 17 00:00:00 2001 From: zzh <1368735060@qq.com> Date: Wed, 9 Sep 2026 09:17:14 +0800 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=20OAuth=20=E5=85=AC=E5=BC=80=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 从其他配置 wechat_mp 返回 AppId 与 OAuthRedirectBase,供 H5 网页授权使用。 Co-authored-by: Cursor --- .../WeChatRouteIntegrationTests.cs | 1 + .../Auth/AuthService.WeChatMp.cs | 25 +++++++++++++++++++ src/SimpleAdmin.Api/WeChat/Dtos/WeChatDtos.cs | 13 ++++++++++ 3 files changed, 39 insertions(+) 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 { From 7c1be3a7234c2081dcc2da6b2cd2a6b456cc3d03 Mon Sep 17 00:00:00 2001 From: zzh <1368735060@qq.com> Date: Wed, 9 Sep 2026 12:19:31 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20=E5=B0=86=E5=BE=AE=E4=BF=A1=20OAuth?= =?UTF-8?q?=20=E5=85=AC=E5=BC=80=E9=85=8D=E7=BD=AE=E6=94=B9=E4=B8=BA=20/we?= =?UTF-8?q?chat/oauth/config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 避免被 /wechat/mp/{appId} 吞掉导致方法/参数校验异常。 Co-authored-by: Cursor --- .../WeChatRouteIntegrationTests.cs | 2 +- src/SimpleAdmin.Api/Auth/AuthService.WeChatMp.cs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/SimpleAdmin.Api.IntegrationTests/WeChatRouteIntegrationTests.cs b/src/SimpleAdmin.Api.IntegrationTests/WeChatRouteIntegrationTests.cs index db21717..f6229da 100644 --- a/src/SimpleAdmin.Api.IntegrationTests/WeChatRouteIntegrationTests.cs +++ b/src/SimpleAdmin.Api.IntegrationTests/WeChatRouteIntegrationTests.cs @@ -32,7 +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/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 850bac3..f774fa1 100644 --- a/src/SimpleAdmin.Api/Auth/AuthService.WeChatMp.cs +++ b/src/SimpleAdmin.Api/Auth/AuthService.WeChatMp.cs @@ -161,9 +161,10 @@ public partial class AuthService /// /// H5 网页授权公开配置:AppId + OAuth 回调根(来自其他配置 wechat_mp)。 + /// 注意:勿挂在 /wechat/mp/{appId} 下,避免被公众号回调路由吞掉。 /// [AllowAnonymous] - [HttpGet("/wechat/mp/oauth-config")] + [HttpGet("/wechat/oauth/config")] [ApiExplorerSettings(GroupName = "WeChat")] public async Task GetWeChatOAuthConfigAsync( CancellationToken cancellationToken = default) From 41db6fa0afcaa9ec38fc5eb6941d77adf82ca806 Mon Sep 17 00:00:00 2001 From: zzh <1368735060@qq.com> Date: Wed, 9 Sep 2026 12:38:12 +0800 Subject: [PATCH 4/4] =?UTF-8?q?chore:=20=E7=94=9F=E4=BA=A7/=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E9=85=8D=E7=BD=AE=E5=88=86=E7=A6=BB=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E6=94=B6=E7=B4=A7=E5=BE=AE=E4=BF=A1=20mp=20AppId=20=E8=B7=AF?= =?UTF-8?q?=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Development 指向 oms.nanafa.com;Production 指向 ideship.com。微信 /wechat/mp/{appId} 仅匹配 wx 前缀。 Co-authored-by: Cursor --- .../Integrations/Itfx/ItfxGatewayOptions.cs | 4 +-- .../WeChatRouteIntegrationTests.cs | 2 +- .../Auth/AuthService.WeChatMp.cs | 5 +-- .../appsettings.Development.json | 9 +++-- .../appsettings.Production.json | 34 +++++++++++++++++++ 5 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 src/SimpleAdmin.Api/appsettings.Production.json diff --git a/src/Oms.Application/Integrations/Itfx/ItfxGatewayOptions.cs b/src/Oms.Application/Integrations/Itfx/ItfxGatewayOptions.cs index 1ba817e..6cbe9af 100644 --- a/src/Oms.Application/Integrations/Itfx/ItfxGatewayOptions.cs +++ b/src/Oms.Application/Integrations/Itfx/ItfxGatewayOptions.cs @@ -8,9 +8,9 @@ public class ItfxGatewayOptions public const string SectionName = "Oms:Itfx"; /// - /// itfx 服务根地址,如 http://api.nanafa.com/itfx。 + /// itfx 服务根地址。生产默认 api.ideship.com;测试用 appsettings.Development / Consul 覆盖为 api.nanafa.com。 /// - public string BaseUrl { get; set; } = "http://api.nanafa.com/itfx"; + public string BaseUrl { get; set; } = "https://api.ideship.com/itfx"; public int TimeoutSeconds { get; set; } = 30; diff --git a/src/SimpleAdmin.Api.IntegrationTests/WeChatRouteIntegrationTests.cs b/src/SimpleAdmin.Api.IntegrationTests/WeChatRouteIntegrationTests.cs index f6229da..9a412b6 100644 --- a/src/SimpleAdmin.Api.IntegrationTests/WeChatRouteIntegrationTests.cs +++ b/src/SimpleAdmin.Api.IntegrationTests/WeChatRouteIntegrationTests.cs @@ -30,7 +30,7 @@ public class WeChatRouteIntegrationTests await using var host = await SimpleAdminApiTestHost.CreateAsync(configureServices: ConfigureWeChatFallback); host.RoutePatterns.Should().Contain("apiwechat/verification"); - host.RoutePatterns.Should().Contain("wechat/mp/{appId}"); + host.RoutePatterns.Should().Contain("wechat/mp/{appId:regex(^wx[A-Za-z0-9]+$)}"); host.RoutePatterns.Should().Contain("wechat/mp/login-qrcode"); host.RoutePatterns.Should().Contain("wechat/oauth/config"); host.RoutePatterns.Should().Contain("wechat/mp/follow-qrcode"); diff --git a/src/SimpleAdmin.Api/Auth/AuthService.WeChatMp.cs b/src/SimpleAdmin.Api/Auth/AuthService.WeChatMp.cs index f774fa1..914cee0 100644 --- a/src/SimpleAdmin.Api/Auth/AuthService.WeChatMp.cs +++ b/src/SimpleAdmin.Api/Auth/AuthService.WeChatMp.cs @@ -70,9 +70,10 @@ public partial class AuthService /// /// 微信服务器接入验签,验签通过后原样返回 echostr。 + /// appId 仅匹配 wx 开头,避免 login-qrcode / oauth-config 等静态段落入本路由。 /// [AllowAnonymous] - [HttpGet("/wechat/mp/{appId}")] + [HttpGet("/wechat/mp/{appId:regex(^wx[A-Za-z0-9]+$)}")] [Produces("text/plain")] [ApiExplorerSettings(GroupName = "WeChat")] public async Task WeChatValidateAsync( @@ -120,7 +121,7 @@ public partial class AuthService /// 微信消息/事件推送(明文,XML/JSON)。 /// [AllowAnonymous] - [HttpPost("/wechat/mp/{appId}")] + [HttpPost("/wechat/mp/{appId:regex(^wx[A-Za-z0-9]+$)}")] [Consumes("text/xml", "application/xml", "application/json", "text/plain")] [Produces("text/plain", "application/xml")] [ApiExplorerSettings(GroupName = "WeChat")] diff --git a/src/SimpleAdmin.Api/appsettings.Development.json b/src/SimpleAdmin.Api/appsettings.Development.json index f9647a9..1439c62 100644 --- a/src/SimpleAdmin.Api/appsettings.Development.json +++ b/src/SimpleAdmin.Api/appsettings.Development.json @@ -12,7 +12,12 @@ }, "App": { "Urls": ["http://localhost:5281"], - "CorsOrigins": ["http://localhost:5173", "http://localhost:5281"], + "CorsOrigins": [ + "http://localhost:5173", + "http://localhost:5281", + "https://oms.nanafa.com", + "http://oms.nanafa.com" + ], "SendStartupNotification": false }, "Jwt": { @@ -46,7 +51,7 @@ }, "WeChat": { "Mp": { - "AppId": "wxd5141ba46c856e1f", + "AppId": "wxfffea62e089ee15f", "Secret": "379f51a89419dc36fbb9167feef6f89a", "Token": "c6ca74013df823c0e1da0feaaaf8bf66", "EncodingAesKey": "", diff --git a/src/SimpleAdmin.Api/appsettings.Production.json b/src/SimpleAdmin.Api/appsettings.Production.json new file mode 100644 index 0000000..49f2a98 --- /dev/null +++ b/src/SimpleAdmin.Api/appsettings.Production.json @@ -0,0 +1,34 @@ +{ + "UseLocalConfigs": false, + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "App": { + "CorsOrigins": [ + "https://ideship.com", + "https://www.ideship.com" + ], + "SendStartupNotification": false + }, + "WeChat": { + "Mp": { + "OAuthRedirectBase": "https://ideship.com", + "FollowUrl": "" + } + }, + "Oms": { + "TrackService": { + "Enabled": true, + "BaseUrl": "https://api.ideship.com/track" + }, + "Itfx": { + "BaseUrl": "https://api.ideship.com/itfx" + }, + "PlatformShop": { + "FrontendBaseUrl": "https://ideship.com" + } + } +}