feat(settings): support dual-mode wechat oauth defaults

This commit is contained in:
IanShaw027
2026-04-21 20:36:10 +08:00
parent 17c6348b57
commit 2cebb0dc60
15 changed files with 490 additions and 214 deletions

View File

@@ -36,6 +36,8 @@ type SystemSettings struct {
WeChatConnectAppID string
WeChatConnectAppSecret string
WeChatConnectAppSecretConfigured bool
WeChatConnectOpenEnabled bool
WeChatConnectMPEnabled bool
WeChatConnectMode string
WeChatConnectScopes string
WeChatConnectRedirectURL string
@@ -191,12 +193,30 @@ type WeChatConnectOAuthConfig struct {
Enabled bool
AppID string
AppSecret string
OpenEnabled bool
MPEnabled bool
Mode string
Scopes string
RedirectURL string
FrontendRedirectURL string
}
func (cfg WeChatConnectOAuthConfig) SupportsMode(mode string) bool {
switch normalizeWeChatConnectModeSetting(mode) {
case "mp":
return cfg.MPEnabled
default:
return cfg.OpenEnabled
}
}
func (cfg WeChatConnectOAuthConfig) ScopeForMode(mode string) string {
if normalizeWeChatConnectModeSetting(mode) == "mp" {
return normalizeWeChatConnectScopeSetting(cfg.Scopes, "mp")
}
return defaultWeChatConnectScopeForMode("open")
}
// StreamTimeoutSettings 流超时处理配置(仅控制超时后的处理方式,超时判定由网关配置控制)
type StreamTimeoutSettings struct {
// Enabled 是否启用流超时处理