改进渠道管理功能(优先级提示、定时测试优化、参数修复) - #2048
Conversation
# Conflicts: # web/src/i18n/locales/zh.json
feat(i18n): Add French language support.
解锁deepseek补全倍率;允许deepseek渠道获取模型
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
fix: Redirect address after successful tg binding
fix: sync third-party binding state in personal settings
add submodel.ai
fix : fix submodel adapter
…ENS/CUSTOM)
Replace the legacy boolean “DisplayInCurrencyEnabled” with an injected, type-safe
configuration `general_setting.quota_display_type`, and wire it through the
backend and frontend.
Backend
- Add `QuotaDisplayType` to `operation_setting.GeneralSetting` with injected
registration via `config.GlobalConfig.Register("general_setting", ...)`.
Helpers: `IsCurrencyDisplay()`, `IsCNYDisplay()`, `GetQuotaDisplayType()`.
- Expose `quota_display_type` in `/api/status` and keep legacy
`display_in_currency` for backward compatibility.
- Logger: update `LogQuota` and `FormatQuota` to support USD/CNY/TOKENS. When
CNY is selected, convert using `operation_setting.USDExchangeRate`.
- Controllers:
- `billing`: compute subscription/usage amounts based on the selected type
(USD: divide by `QuotaPerUnit`; CNY: USD→CNY; TOKENS: keep raw tokens).
- `topup` / `topup_stripe`: treat inputs as “amount” for USD/CNY and as
token-count for TOKENS; adjust min topup and pay money accordingly.
- `misc`: include `quota_display_type` in status payload.
- Compatibility: in `model/option.UpdateOption`, map updates to
`DisplayInCurrencyEnabled` → `general_setting.quota_display_type`
(true→USD, false→TOKENS). Keep exporting the legacy key in `OptionMap`.
Frontend
- Settings: replace the “display in currency” switch with a Select
(`general_setting.quota_display_type`) offering USD / CNY / Tokens.
Provide fallback mapping from legacy `DisplayInCurrencyEnabled`.
- Persist `quota_display_type` to localStorage (keep `display_in_currency`
for legacy components).
- Rendering helpers: base all quota/price rendering on `quota_display_type`;
use `usd_exchange_rate` for CNY symbol/values.
- Pricing page: default view currency follows site display type (USD/CNY),
while TOKENS mode still allows per-view currency toggling when needed.
Notes
- No database migrations required.
- Legacy clients remain functional via compatibility fields.
feat: support claude-sonnet-4-5-20250929
fix: Optimize sidebar refresh to avoid redundant loading states
refactor: Openai video model 移动到 dto
feat: jimeng use openai sdk input_reference i2v
将 `ClaudeMediaMessage.Thinking` 的类型从 `string` 修改为 `*string`,以解决 `omitempty` 导致 `"thinking": ""` 字段在 JSON 序列化时被忽略的问题。 同时更新了 `service/convert.go` 和 `relay/channel/claude/relay-claude.go` 中的相关逻辑,以兼容新的指针类型,确保生成的 Claude 事件流符合官方规范。
1. 将对SiliconFlow渠道的RelayModeImagesGenerations请求,转发至v1/images/generations端点。 2. SiliconFlow图像生成接口额外参数适配。
1. 解析ImageRequest的Extra时,处理err 2. DoResponse方法添加RelayModeImagesGenerations(fallthrough)
fix(convert): 修复 OpenAI 转 Claude 流时 thinking 块的格式问题
feat: 添加SiliconFlow图像生成接口自动转换支持
feat: endpoint type log
… improve error handling
WalkthroughUpdates tests to skip non-auto-ban channels, adjusts relay logic to determine disable-eligibility by channelType instead of channelId, and enhances the EditChannelModal UI with tooltips and an icon explaining priority and weight. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Client
participant Controller as Controller (relay.go)
participant Service as Service (ShouldDisableChannel)
participant Worker as gopool worker
participant Store as ChannelStore
Client->>Controller: Relay request
Controller->>Service: ShouldDisableChannel(channelType, err)
alt eligible to disable
Controller->>Worker: async DisableChannel(channelId)
Worker->>Store: DisableChannel(channelId)
Store-->>Worker: result
Worker-->>Controller: (async completes)
else not eligible
Controller-->>Client: proceed without disable
end
note over Controller,Service: Eligibility now keyed by channelType (was channelId)
%% Styling notes (color is supplemental; labels carry meaning)
rect rgba(230, 240, 255, 0.6)
note over Controller: Changed interaction
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
controller/channel-test.go(2 hunks)controller/relay.go(1 hunks)web/src/components/table/channels/modals/EditChannelModal.jsx(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
controller/relay.go (1)
service/channel.go (1)
ShouldDisableChannel(47-99)
🔇 Additional comments (4)
controller/channel-test.go (2)
562-565: Good optimization: early exit for non-auto-ban channels.The added guard correctly skips channels with auto-ban disabled before processing, reducing unnecessary test overhead. This aligns with the PR objective and improves efficiency.
589-591: Correctly removed redundant check after early filtering.The
channel.GetAutoBan()check is no longer needed here because channels with auto-ban disabled are now filtered at the start of the loop (lines 562-565). The updated comment clearly documents this change.controller/relay.go (1)
287-287: Critical fix: corrected parameter from channelId to channelType.This is an important bug fix. The
ShouldDisableChannelfunction expectschannelType(a channel type constant likeChannelTypeGemini) as shown in the service/channel.go snippet, notchannelId(a unique identifier). PassingchannelIdwould have broken type-specific disable logic, such as the switch statement at line 60-64 in service/channel.go that checks for specific channel types.Based on code from service/channel.go showing the correct function signature and type-specific switch logic.
web/src/components/table/channels/modals/EditChannelModal.jsx (1)
51-51: Verify IconHelpCircle export
EnsureIconHelpCircleis actually exported by@douyinfe/semi-icons(e.g., inspectnode_modules/@douyinfe/semi-icons/index.*or runnpm explore @douyinfe/semi-icons -- grep -R "IconHelpCircle" -n .). If the name differs, update to the correct export (e.g.,IconInfoCircleorIconQuestionCircle).
| label={ | ||
| <span> | ||
| {t('渠道优先级')} | ||
| <Tooltip content='优先级决定渠道选择顺序。数值越高越优先,重试时依次降低优先级(retry=0选最高组)'> | ||
| <IconHelpCircle className='text-gray-400 cursor-help' style={{ marginLeft: 4 }} /> | ||
| </Tooltip> | ||
| </span> | ||
| } |
There was a problem hiding this comment.
Add i18n support for tooltip content.
The tooltip content is hardcoded in Chinese without using the t() translation function, which is inconsistent with the rest of the file and breaks internationalization support.
Apply this diff to add i18n support:
label={
<span>
{t('渠道优先级')}
- <Tooltip content='优先级决定渠道选择顺序。数值越高越优先,重试时依次降低优先级(retry=0选最高组)'>
+ <Tooltip content={t('优先级决定渠道选择顺序。数值越高越优先,重试时依次降低优先级(retry=0选最高组)')}>
<IconHelpCircle className='text-gray-400 cursor-help' style={{ marginLeft: 4 }} />
</Tooltip>
</span>
} label={
<span>
{t('渠道权重')}
- <Tooltip content='权重决定同优先级内的流量分配。数值越高流量越多,weight=0也会分配流量(实际权重+10)'>
+ <Tooltip content={t('权重决定同优先级内的流量分配。数值越高流量越多,weight=0也会分配流量(实际权重+10)')}>
<IconHelpCircle className='text-gray-400 cursor-help' style={{ marginLeft: 4 }} />
</Tooltip>
</span>
}Also applies to: 2413-2420
🤖 Prompt for AI Agents
In web/src/components/table/channels/modals/EditChannelModal.jsx around lines
2394-2401 and 2413-2420, the Tooltip content is hardcoded in Chinese; replace
the literal Chinese strings with calls to the translation function t() (e.g.
t('渠道优先级说明') or an appropriate i18n key) so the tooltip text is
internationalized, ensuring the Tooltip's content prop receives the translated
string and updating/adding the corresponding translation entries for the key(s)
used.
本 PR 包含三个针对渠道管理的改进:
feat: 为渠道优先级和权重添加提示图标
refactor: 优化定时测试逻辑
fix: 修复 ShouldDisableChannel 参数错误
Summary by CodeRabbit
New Features
Refactor
Tests