From 4e75d8fda9f010e856741328d9a49ee66a1b3a53 Mon Sep 17 00:00:00 2001 From: nick8802754751 <> Date: Sat, 17 Jan 2026 16:06:44 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=E6=B7=B7=E5=90=88?= =?UTF-8?q?=E6=B8=A0=E9=81=93=E8=AD=A6=E5=91=8A=E7=A1=AE=E8=AE=A4=E6=A1=86?= =?UTF-8?q?=E5=92=8C=E8=BF=87=E6=BB=A4=20prompt=5Fcache=5Fretention=20?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 前端: EditAccountModal 和 CreateAccountModal 添加 409 mixed_channel_warning 处理 - 前端: 弹出确认框让用户确认混合渠道风险 - 后端: 过滤 OpenAI 请求中的 prompt_cache_retention 参数(上游不支持) - 添加中英文翻译 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --- .../service/openai_gateway_service.go | 6 ++ .../components/account/CreateAccountModal.vue | 60 ++++++++++++++----- .../components/account/EditAccountModal.vue | 32 +++++++++- frontend/src/i18n/locales/en.ts | 1 + frontend/src/i18n/locales/zh.ts | 1 + 5 files changed, 82 insertions(+), 18 deletions(-) diff --git a/backend/internal/service/openai_gateway_service.go b/backend/internal/service/openai_gateway_service.go index c7d94882d..45b4c69c4 100644 --- a/backend/internal/service/openai_gateway_service.go +++ b/backend/internal/service/openai_gateway_service.go @@ -649,6 +649,12 @@ func (s *OpenAIGatewayService) Forward(ctx context.Context, c *gin.Context, acco bodyModified = true } } + + // Remove prompt_cache_retention (not supported by upstream OpenAI API) + if _, has := reqBody["prompt_cache_retention"]; has { + delete(reqBody, "prompt_cache_retention") + bodyModified = true + } } // Re-serialize body only if modified diff --git a/frontend/src/components/account/CreateAccountModal.vue b/frontend/src/components/account/CreateAccountModal.vue index c81de00ee..05f328acd 100644 --- a/frontend/src/components/account/CreateAccountModal.vue +++ b/frontend/src/components/account/CreateAccountModal.vue @@ -2157,6 +2157,46 @@ const handleClose = () => { emit('close') } +// Helper function to create account with mixed channel warning handling +const doCreateAccount = async (payload: any, confirmMixedChannelRisk = false) => { + if (confirmMixedChannelRisk) { + payload.confirm_mixed_channel_risk = true + } + + submitting.value = true + try { + await adminAPI.accounts.create(payload) + appStore.showSuccess(t('admin.accounts.accountCreated')) + emit('created') + handleClose() + } catch (error: any) { + // Handle 409 mixed_channel_warning - show confirmation dialog + if (error.response?.status === 409 && error.response?.data?.error === 'mixed_channel_warning') { + const details = error.response.data.details || {} + const groupName = details.group_name || 'Unknown' + const currentPlatform = details.current_platform || 'Unknown' + const otherPlatform = details.other_platform || 'Unknown' + + const confirmMessage = t('admin.accounts.mixedChannelWarning', { + groupName, + currentPlatform, + otherPlatform + }) + + if (confirm(confirmMessage)) { + // Retry with confirmation flag + submitting.value = false + await doCreateAccount(payload, true) + return + } + } else { + appStore.showError(error.response?.data?.detail || t('admin.accounts.failedToCreate')) + } + } finally { + submitting.value = false + } +} + const handleSubmit = async () => { // For OAuth-based type, handle OAuth flow (goes to step 2) if (isOAuthFlow.value) { @@ -2213,21 +2253,11 @@ const handleSubmit = async () => { form.credentials = credentials - submitting.value = true - try { - await adminAPI.accounts.create({ - ...form, - group_ids: form.group_ids, - auto_pause_on_expired: autoPauseOnExpired.value - }) - appStore.showSuccess(t('admin.accounts.accountCreated')) - emit('created') - handleClose() - } catch (error: any) { - appStore.showError(error.response?.data?.detail || t('admin.accounts.failedToCreate')) - } finally { - submitting.value = false - } + await doCreateAccount({ + ...form, + group_ids: form.group_ids, + auto_pause_on_expired: autoPauseOnExpired.value + }) } const goBackToBasicInfo = () => { diff --git a/frontend/src/components/account/EditAccountModal.vue b/frontend/src/components/account/EditAccountModal.vue index d27364f12..63b54df04 100644 --- a/frontend/src/components/account/EditAccountModal.vue +++ b/frontend/src/components/account/EditAccountModal.vue @@ -8,7 +8,7 @@
@@ -1294,12 +1294,17 @@ const handleClose = () => { emit('close') } -const handleSubmit = async () => { +const handleSubmit = async (confirmMixedChannelRisk = false) => { if (!props.account) return submitting.value = true try { const updatePayload: Record = { ...form } + + // Add confirmation flag if user confirmed mixed channel risk + if (confirmMixedChannelRisk) { + updatePayload.confirm_mixed_channel_risk = true + } // 后端期望 proxy_id: 0 表示清除代理,而不是 null if (updatePayload.proxy_id === null) { updatePayload.proxy_id = 0 @@ -1415,7 +1420,28 @@ const handleSubmit = async () => { emit('updated') handleClose() } catch (error: any) { - appStore.showError(error.response?.data?.message || error.response?.data?.detail || t('admin.accounts.failedToUpdate')) + // Handle 409 mixed_channel_warning - show confirmation dialog + if (error.response?.status === 409 && error.response?.data?.error === 'mixed_channel_warning') { + const details = error.response.data.details || {} + const groupName = details.group_name || 'Unknown' + const currentPlatform = details.current_platform || 'Unknown' + const otherPlatform = details.other_platform || 'Unknown' + + const confirmMessage = t('admin.accounts.mixedChannelWarning', { + groupName, + currentPlatform, + otherPlatform + }) + + if (confirm(confirmMessage)) { + // Retry with confirmation flag + submitting.value = false + await handleSubmit(true) + return + } + } else { + appStore.showError(error.response?.data?.message || error.response?.data?.detail || t('admin.accounts.failedToUpdate')) + } } finally { submitting.value = false } diff --git a/frontend/src/i18n/locales/en.ts b/frontend/src/i18n/locales/en.ts index b25b5a0b7..b36d31e41 100644 --- a/frontend/src/i18n/locales/en.ts +++ b/frontend/src/i18n/locales/en.ts @@ -1306,6 +1306,7 @@ export default { accountUpdated: 'Account updated successfully', failedToCreate: 'Failed to create account', failedToUpdate: 'Failed to update account', + mixedChannelWarning: 'Warning: Group "{groupName}" contains both {currentPlatform} and {otherPlatform} accounts. Mixing different channels may cause thinking block signature validation issues, which will fallback to non-thinking mode. Are you sure you want to continue?', pleaseEnterAccountName: 'Please enter account name', pleaseEnterApiKey: 'Please enter API Key', apiKeyIsRequired: 'API Key is required', diff --git a/frontend/src/i18n/locales/zh.ts b/frontend/src/i18n/locales/zh.ts index b7be85579..ad8380a87 100644 --- a/frontend/src/i18n/locales/zh.ts +++ b/frontend/src/i18n/locales/zh.ts @@ -1439,6 +1439,7 @@ export default { accountUpdated: '账号更新成功', failedToCreate: '创建账号失败', failedToUpdate: '更新账号失败', + mixedChannelWarning: '警告:分组 "{groupName}" 中同时包含 {currentPlatform} 和 {otherPlatform} 账号。混合使用不同渠道可能导致 thinking block 签名验证问题,会自动回退到非 thinking 模式。确定要继续吗?', pleaseEnterAccountName: '请输入账号名称', pleaseEnterApiKey: '请输入 API Key', apiKeyIsRequired: 'API Key 是必需的', From 6549a40cf40922f8b9a6cfd30ecb4ae9263c8ae7 Mon Sep 17 00:00:00 2001 From: nick8802754751 <> Date: Sat, 17 Jan 2026 16:16:47 +0800 Subject: [PATCH 2/2] =?UTF-8?q?refactor:=20=E4=BD=BF=E7=94=A8=20ConfirmDia?= =?UTF-8?q?log=20=E7=BB=84=E4=BB=B6=E6=9B=BF=E4=BB=A3=E5=8E=9F=E7=94=9F=20?= =?UTF-8?q?confirm()=20=E5=AF=B9=E8=AF=9D=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - EditAccountModal 和 CreateAccountModal 使用 ConfirmDialog 组件 - 保存 pending payload 供确认后重试 - 添加 mixedChannelWarningTitle 翻译 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --- .../components/account/CreateAccountModal.vue | 71 ++++++++++++----- .../components/account/EditAccountModal.vue | 76 +++++++++++++------ frontend/src/i18n/locales/en.ts | 1 + frontend/src/i18n/locales/zh.ts | 1 + 4 files changed, 106 insertions(+), 43 deletions(-) diff --git a/frontend/src/components/account/CreateAccountModal.vue b/frontend/src/components/account/CreateAccountModal.vue index 05f328acd..5702ccd61 100644 --- a/frontend/src/components/account/CreateAccountModal.vue +++ b/frontend/src/components/account/CreateAccountModal.vue @@ -1615,6 +1615,18 @@
+ + + diff --git a/frontend/src/i18n/locales/en.ts b/frontend/src/i18n/locales/en.ts index b36d31e41..1f5471e6b 100644 --- a/frontend/src/i18n/locales/en.ts +++ b/frontend/src/i18n/locales/en.ts @@ -1306,6 +1306,7 @@ export default { accountUpdated: 'Account updated successfully', failedToCreate: 'Failed to create account', failedToUpdate: 'Failed to update account', + mixedChannelWarningTitle: 'Mixed Channel Warning', mixedChannelWarning: 'Warning: Group "{groupName}" contains both {currentPlatform} and {otherPlatform} accounts. Mixing different channels may cause thinking block signature validation issues, which will fallback to non-thinking mode. Are you sure you want to continue?', pleaseEnterAccountName: 'Please enter account name', pleaseEnterApiKey: 'Please enter API Key', diff --git a/frontend/src/i18n/locales/zh.ts b/frontend/src/i18n/locales/zh.ts index ad8380a87..b931b5557 100644 --- a/frontend/src/i18n/locales/zh.ts +++ b/frontend/src/i18n/locales/zh.ts @@ -1439,6 +1439,7 @@ export default { accountUpdated: '账号更新成功', failedToCreate: '创建账号失败', failedToUpdate: '更新账号失败', + mixedChannelWarningTitle: '混合渠道警告', mixedChannelWarning: '警告:分组 "{groupName}" 中同时包含 {currentPlatform} 和 {otherPlatform} 账号。混合使用不同渠道可能导致 thinking block 签名验证问题,会自动回退到非 thinking 模式。确定要继续吗?', pleaseEnterAccountName: '请输入账号名称', pleaseEnterApiKey: '请输入 API Key',