mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-09 02:47:45 +08:00
Normalize endpoint API root handling
This commit is contained in:
@@ -1050,7 +1050,7 @@ import { log } from '@/utils/logger'
|
||||
import AlertDialog from '@/components/common/AlertDialog.vue'
|
||||
import EndpointConditionEditor from './EndpointConditionEditor.vue'
|
||||
import ProxyNodeSelect from './ProxyNodeSelect.vue'
|
||||
import { getDefaultEndpointPath, normalizeEndpointApiFormat } from './endpoint-default-paths'
|
||||
import { getDefaultEndpointBaseUrl, getDefaultEndpointPath, normalizeEndpointApiFormat } from './endpoint-default-paths'
|
||||
import { useProxyNodesStore } from '@/stores/proxy-nodes'
|
||||
import {
|
||||
createEndpoint,
|
||||
@@ -1886,6 +1886,15 @@ function getEndpointDefaultPath(endpoint: ProviderEndpoint): string {
|
||||
return getDefaultPath(endpoint.api_format, getEndpointEditState(endpoint.id)?.url ?? endpoint.base_url)
|
||||
}
|
||||
|
||||
function getNewEndpointBaseUrl(): string {
|
||||
const typedBaseUrl = newEndpoint.value.base_url.trim()
|
||||
if (typedBaseUrl) return typedBaseUrl
|
||||
return getDefaultEndpointBaseUrl({
|
||||
apiFormat: newEndpoint.value.api_format,
|
||||
baseUrl: props.provider?.website || '',
|
||||
})
|
||||
}
|
||||
|
||||
function getDisplayedPath(endpoint: ProviderEndpoint): string {
|
||||
return getEndpointEditState(endpoint.id)?.path ?? (endpoint.custom_path || '')
|
||||
}
|
||||
@@ -3117,8 +3126,8 @@ function getResponseHeaderValidationErrorForEndpoint(endpointId: string): string
|
||||
|
||||
// 新端点选择的格式的默认路径
|
||||
const newEndpointDefaultPath = computed(() => {
|
||||
// 使用填写的 base_url 或 provider 的 website 来判断是否是 Codex 端点
|
||||
const baseUrl = newEndpoint.value.base_url || props.provider?.website || ''
|
||||
// 使用填写的 base_url;留空时使用按格式规范化后的 provider website。
|
||||
const baseUrl = getNewEndpointBaseUrl()
|
||||
return getDefaultPath(newEndpoint.value.api_format, baseUrl)
|
||||
})
|
||||
|
||||
@@ -3362,8 +3371,8 @@ async function handleCycleUpstreamStream(endpoint: ProviderEndpoint) {
|
||||
async function handleAddEndpoint() {
|
||||
if (!props.provider || !newEndpoint.value.api_format) return
|
||||
|
||||
// 如果没有输入 base_url,使用提供商的 website 作为默认值
|
||||
const baseUrl = newEndpoint.value.base_url || props.provider.website
|
||||
// 如果没有输入 base_url,使用按格式规范化后的提供商 website 作为默认值。
|
||||
const baseUrl = getNewEndpointBaseUrl()
|
||||
if (!baseUrl) {
|
||||
showError('请输入 Base URL')
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user