fix: use i18n for mixed-channel warning messages and improve bulk pre-check

- BulkUpdate handler: add structured details to 409 response
- BulkUpdateAccounts: simplify to global pre-check before any DB write;
  remove per-account snapshot tracking which is no longer needed
- MixedChannelError.Error(): restore English message for API compatibility
- BulkEditAccountModal: use t() with details for both pre-check and 409
  fallback paths instead of displaying raw backend strings
- Update test to verify pre-check blocks on existing group conflicts
This commit is contained in:
erio
2026-03-01 14:39:07 +08:00
parent b67bf2227e
commit 3a04552f98
4 changed files with 36 additions and 33 deletions

View File

@@ -1542,27 +1542,16 @@ func (s *adminServiceImpl) BulkUpdateAccounts(ctx context.Context, input *BulkUp
// 预加载账号平台信息(混合渠道检查或 Sora 同步需要)。
platformByID := map[int64]string{}
groupAccountsByID := map[int64][]Account{}
groupNameByID := map[int64]string{}
if needMixedChannelCheck {
accounts, err := s.accountRepo.GetByIDs(ctx, input.AccountIDs)
if err != nil {
if needMixedChannelCheck {
return nil, err
}
} else {
for _, account := range accounts {
if account != nil {
platformByID[account.ID] = account.Platform
}
}
}
loadedAccounts, loadedNames, err := s.preloadMixedChannelRiskData(ctx, *input.GroupIDs)
if err != nil {
return nil, err
}
groupAccountsByID = loadedAccounts
groupNameByID = loadedNames
for _, account := range accounts {
if account != nil {
platformByID[account.ID] = account.Platform
}
}
}
// 预检查混合渠道风险:在任何写操作之前,若发现风险立即返回错误。
@@ -2529,6 +2518,6 @@ type MixedChannelError struct {
}
func (e *MixedChannelError) Error() string {
return fmt.Sprintf("警告:分组 \"%s\" 中同时包含 %s %s 账号。混合使用不同渠道可能导致 thinking block 签名验证问题,请确保 Anthropic 账号是 Antigravity 反代暴露的 api。确定要继续吗",
return fmt.Sprintf("mixed_channel_warning: Group '%s' contains both %s and %s accounts. Using mixed channels in the same context may cause thinking block signature validation issues, which will fallback to non-thinking mode for historical messages.",
e.GroupName, e.CurrentPlatform, e.OtherPlatform)
}