mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-16 07:33:06 +08:00
feat(settings): channel_monitor_show_quota public setting (default off)
- 新增公开设置 key(迁移 226 已插入默认 false),控制用户端监控页 是否展示配额/余额;管理端不受影响 - 解析 fail-closed:仅字面 "true" 视为开启(对齐 available_channels_enabled 语义,而非 hide_throughput 的 fail-open) - 全链路贯通:domain key 常量 → setting_public(公开读取 + ChannelMonitorRuntime .ShowQuota + 注入 payload)→ settings_view/parse/update → handler DTO (admin/user 响应 + admin 更新请求)→ api_contract_test 两个 wantJSON 块
This commit is contained in:
@@ -190,6 +190,7 @@ func (s *SettingService) InitializeDefaultSettings(ctx context.Context) error {
|
||||
SettingKeyChannelMonitorMode: ChannelMonitorModeV1,
|
||||
SettingKeyChannelMonitorDefaultIntervalSeconds: "60",
|
||||
SettingKeyChannelMonitorHideThroughput: "true",
|
||||
SettingKeyChannelMonitorShowQuota: "false",
|
||||
|
||||
// Grok: safe defaults — no cross-vendor model rewrite unless operators enable it.
|
||||
SettingKeyGrokDefaultTextModel: "grok-4.5",
|
||||
@@ -798,6 +799,9 @@ func (s *SettingService) parseSettings(settings map[string]string) *SystemSettin
|
||||
// 默认隐藏吞吐(迁移 206 的隐私默认):未配置时必须与 setting_public.go 的
|
||||
// 公开读取路径给出同一个值,否则管理端看到“未隐藏”而用户端实际已隐藏。
|
||||
result.ChannelMonitorHideThroughput = !isFalseSettingValue(settings[SettingKeyChannelMonitorHideThroughput])
|
||||
// 配额展示默认关闭且 fail-closed:仅字面 "true" 视为开启
|
||||
// (与 setting_public.go 公开读取路径保持一致)。
|
||||
result.ChannelMonitorShowQuota = settings[SettingKeyChannelMonitorShowQuota] == "true"
|
||||
|
||||
// Grok default mapping policy
|
||||
result.GrokDefaultTextModel = strings.TrimSpace(settings[SettingKeyGrokDefaultTextModel])
|
||||
|
||||
Reference in New Issue
Block a user