diff --git a/frontend/src/features/providers/components/EndpointFormDialog.vue b/frontend/src/features/providers/components/EndpointFormDialog.vue index add84ca..162af87 100644 --- a/frontend/src/features/providers/components/EndpointFormDialog.vue +++ b/frontend/src/features/providers/components/EndpointFormDialog.vue @@ -20,44 +20,45 @@ API 配置 -
- -
- - - +
- + +
-
- -
- - +
+ + +

+ 将为所有选中的格式使用相同的 URL 和路径配置 +

+
@@ -217,10 +220,10 @@ 取消 @@ -306,6 +309,9 @@ const form = ref({ proxy_password: '', }) +// 选中的 API 格式(多选) +const selectedFormats = ref([]) + // API 格式列表 const apiFormats = ref>([]) @@ -400,6 +406,7 @@ function resetForm() { proxy_username: '', proxy_password: '', } + selectedFormats.value = [] proxyEnabled.value = false } @@ -479,6 +486,8 @@ const handleSubmit = async (skipCredentialCheck = false) => { } loading.value = true + let successCount = 0 + try { const proxyConfig = buildProxyConfig() @@ -497,27 +506,52 @@ const handleSubmit = async (skipCredentialCheck = false) => { success('端点已更新', '保存成功') emit('endpointUpdated') + emit('update:modelValue', false) } else if (props.provider) { - // 创建端点 - await createEndpoint(props.provider.id, { - provider_id: props.provider.id, - api_format: form.value.api_format, - base_url: form.value.base_url, - custom_path: form.value.custom_path || undefined, - timeout: form.value.timeout, - max_retries: form.value.max_retries, - max_concurrent: form.value.max_concurrent, - rate_limit: form.value.rate_limit, - is_active: form.value.is_active, - proxy: proxyConfig, - }) + // 批量创建端点 + let failCount = 0 + const errors: string[] = [] - success('端点创建成功', '成功') - emit('endpointCreated') - resetForm() + for (const apiFormat of selectedFormats.value) { + try { + await createEndpoint(props.provider.id, { + provider_id: props.provider.id, + api_format: apiFormat, + base_url: form.value.base_url, + custom_path: form.value.custom_path || undefined, + timeout: form.value.timeout, + max_retries: form.value.max_retries, + max_concurrent: form.value.max_concurrent, + rate_limit: form.value.rate_limit, + is_active: form.value.is_active, + proxy: proxyConfig, + }) + successCount++ + } catch (error: any) { + failCount++ + const formatLabel = apiFormats.value.find((f: any) => f.value === apiFormat)?.label || apiFormat + errors.push(`${formatLabel}: ${error.response?.data?.detail || '创建失败'}`) + } + } + + // 显示结果 + if (successCount > 0 && failCount === 0) { + success(`成功创建 ${successCount} 个端点`, '创建成功') + } else if (successCount > 0 && failCount > 0) { + success(`成功创建 ${successCount} 个端点,${failCount} 个失败`, '部分成功') + if (errors.length > 0) { + log.error('创建端点失败:', errors) + } + } else { + showError(errors.join('\n') || '创建端点失败', '创建失败') + } + + if (successCount > 0) { + emit('endpointCreated') + resetForm() + emit('update:modelValue', false) + } } - - emit('update:modelValue', false) } catch (error: any) { const action = isEditMode.value ? '更新' : '创建' showError(error.response?.data?.detail || `${action}端点失败`, '错误')