1. 资源管理冗余(ForwardGemini双重Close) - 错误分支读取body后立即关闭原始body,用内存副本重新包装 - defer添加nil guard,避免重复关闭 - fallback成功时显式关闭旧body,确保连接释放 2. Schema校验丢失(cleanJSONSchema移除字段无感知) - 新增schemaCleaningWarningsEnabled()支持环境变量控制 - 实现warnSchemaKeyRemovedOnce()在非release模式下告警 - 移除关键验证字段时输出warning,包含key和path 3. UI响应式风险(UsersView操作菜单硬编码定位) - 菜单改为先粗定位、渲染后测量、再clamp到视口内 - 添加max-height + overflow-auto,超出时可滚动 - 增强交互:点击其它位置/滚动/resize自动关闭或重新定位 4. 身份补丁干扰(TransformClaudeToGemini默认注入) - 新增TransformOptions + TransformClaudeToGeminiWithOptions - 系统设置新增enable_identity_patch、identity_patch_prompt - 完整打通handler/dto/service/frontend配置链路 - 默认保持启用,向后兼容现有行为 测试: - 后端单测全量通过:go test ./... - 前端类型检查通过:npm run typecheck
112 lines
3.8 KiB
Go
112 lines
3.8 KiB
Go
package service
|
||
|
||
// Status constants
|
||
const (
|
||
StatusActive = "active"
|
||
StatusDisabled = "disabled"
|
||
StatusError = "error"
|
||
StatusUnused = "unused"
|
||
StatusUsed = "used"
|
||
StatusExpired = "expired"
|
||
)
|
||
|
||
// Role constants
|
||
const (
|
||
RoleAdmin = "admin"
|
||
RoleUser = "user"
|
||
)
|
||
|
||
// Platform constants
|
||
const (
|
||
PlatformAnthropic = "anthropic"
|
||
PlatformOpenAI = "openai"
|
||
PlatformGemini = "gemini"
|
||
PlatformAntigravity = "antigravity"
|
||
)
|
||
|
||
// Account type constants
|
||
const (
|
||
AccountTypeOAuth = "oauth" // OAuth类型账号(full scope: profile + inference)
|
||
AccountTypeSetupToken = "setup-token" // Setup Token类型账号(inference only scope)
|
||
AccountTypeAPIKey = "apikey" // API Key类型账号
|
||
)
|
||
|
||
// Redeem type constants
|
||
const (
|
||
RedeemTypeBalance = "balance"
|
||
RedeemTypeConcurrency = "concurrency"
|
||
RedeemTypeSubscription = "subscription"
|
||
)
|
||
|
||
// Admin adjustment type constants
|
||
const (
|
||
AdjustmentTypeAdminBalance = "admin_balance" // 管理员调整余额
|
||
AdjustmentTypeAdminConcurrency = "admin_concurrency" // 管理员调整并发数
|
||
)
|
||
|
||
// Group subscription type constants
|
||
const (
|
||
SubscriptionTypeStandard = "standard" // 标准计费模式(按余额扣费)
|
||
SubscriptionTypeSubscription = "subscription" // 订阅模式(按限额控制)
|
||
)
|
||
|
||
// Subscription status constants
|
||
const (
|
||
SubscriptionStatusActive = "active"
|
||
SubscriptionStatusExpired = "expired"
|
||
SubscriptionStatusSuspended = "suspended"
|
||
)
|
||
|
||
// Setting keys
|
||
const (
|
||
// 注册设置
|
||
SettingKeyRegistrationEnabled = "registration_enabled" // 是否开放注册
|
||
SettingKeyEmailVerifyEnabled = "email_verify_enabled" // 是否开启邮件验证
|
||
|
||
// 邮件服务设置
|
||
SettingKeySMTPHost = "smtp_host" // SMTP服务器地址
|
||
SettingKeySMTPPort = "smtp_port" // SMTP端口
|
||
SettingKeySMTPUsername = "smtp_username" // SMTP用户名
|
||
SettingKeySMTPPassword = "smtp_password" // SMTP密码(加密存储)
|
||
SettingKeySMTPFrom = "smtp_from" // 发件人地址
|
||
SettingKeySMTPFromName = "smtp_from_name" // 发件人名称
|
||
SettingKeySMTPUseTLS = "smtp_use_tls" // 是否使用TLS
|
||
|
||
// Cloudflare Turnstile 设置
|
||
SettingKeyTurnstileEnabled = "turnstile_enabled" // 是否启用 Turnstile 验证
|
||
SettingKeyTurnstileSiteKey = "turnstile_site_key" // Turnstile Site Key
|
||
SettingKeyTurnstileSecretKey = "turnstile_secret_key" // Turnstile Secret Key
|
||
|
||
// OEM设置
|
||
SettingKeySiteName = "site_name" // 网站名称
|
||
SettingKeySiteLogo = "site_logo" // 网站Logo (base64)
|
||
SettingKeySiteSubtitle = "site_subtitle" // 网站副标题
|
||
SettingKeyAPIBaseURL = "api_base_url" // API端点地址(用于客户端配置和导入)
|
||
SettingKeyContactInfo = "contact_info" // 客服联系方式
|
||
SettingKeyDocURL = "doc_url" // 文档链接
|
||
|
||
// 默认配置
|
||
SettingKeyDefaultConcurrency = "default_concurrency" // 新用户默认并发量
|
||
SettingKeyDefaultBalance = "default_balance" // 新用户默认余额
|
||
|
||
// 管理员 API Key
|
||
SettingKeyAdminAPIKey = "admin_api_key" // 全局管理员 API Key(用于外部系统集成)
|
||
|
||
// Gemini 配额策略(JSON)
|
||
SettingKeyGeminiQuotaPolicy = "gemini_quota_policy"
|
||
|
||
// Model fallback settings
|
||
SettingKeyEnableModelFallback = "enable_model_fallback"
|
||
SettingKeyFallbackModelAnthropic = "fallback_model_anthropic"
|
||
SettingKeyFallbackModelOpenAI = "fallback_model_openai"
|
||
SettingKeyFallbackModelGemini = "fallback_model_gemini"
|
||
SettingKeyFallbackModelAntigravity = "fallback_model_antigravity"
|
||
|
||
// Request identity patch (Claude -> Gemini systemInstruction injection)
|
||
SettingKeyEnableIdentityPatch = "enable_identity_patch"
|
||
SettingKeyIdentityPatchPrompt = "identity_patch_prompt"
|
||
)
|
||
|
||
// AdminAPIKeyPrefix is the prefix for admin API keys (distinct from user "sk-" keys).
|
||
const AdminAPIKeyPrefix = "admin-"
|