fix: 添加混合渠道警告确认框和过滤 prompt_cache_retention 参数
- 前端: EditAccountModal 和 CreateAccountModal 添加 409 mixed_channel_warning 处理 - 前端: 弹出确认框让用户确认混合渠道风险 - 后端: 过滤 OpenAI 请求中的 prompt_cache_retention 参数(上游不支持) - 添加中英文翻译 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
@@ -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 = () => {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<form
|
||||
v-if="account"
|
||||
id="edit-account-form"
|
||||
@submit.prevent="handleSubmit"
|
||||
@submit.prevent="() => handleSubmit()"
|
||||
class="space-y-5"
|
||||
>
|
||||
<div>
|
||||
@@ -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<string, unknown> = { ...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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user