feat: Anthropic oauth/setup-token账号支持自定义转发URL
This commit is contained in:
@@ -2245,6 +2245,41 @@
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Custom Base URL Relay -->
|
||||
<div class="rounded-lg border border-gray-200 p-4 dark:border-dark-600">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<label class="input-label mb-0">{{ t('admin.accounts.quotaControl.customBaseUrl.label') }}</label>
|
||||
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">
|
||||
{{ t('admin.accounts.quotaControl.customBaseUrl.hint') }}
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
@click="customBaseUrlEnabled = !customBaseUrlEnabled"
|
||||
:class="[
|
||||
'relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2',
|
||||
customBaseUrlEnabled ? 'bg-primary-600' : 'bg-gray-200 dark:bg-dark-600'
|
||||
]"
|
||||
>
|
||||
<span
|
||||
:class="[
|
||||
'pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out',
|
||||
customBaseUrlEnabled ? 'translate-x-5' : 'translate-x-0'
|
||||
]"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="customBaseUrlEnabled" class="mt-3">
|
||||
<input
|
||||
v-model="customBaseUrl"
|
||||
type="text"
|
||||
class="input"
|
||||
:placeholder="t('admin.accounts.quotaControl.customBaseUrl.urlHint')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
@@ -3095,6 +3130,8 @@ const tlsFingerprintProfiles = ref<{ id: number; name: string }[]>([])
|
||||
const sessionIdMaskingEnabled = ref(false)
|
||||
const cacheTTLOverrideEnabled = ref(false)
|
||||
const cacheTTLOverrideTarget = ref<string>('5m')
|
||||
const customBaseUrlEnabled = ref(false)
|
||||
const customBaseUrl = ref('')
|
||||
|
||||
// Gemini tier selection (used as fallback when auto-detection is unavailable/fails)
|
||||
const geminiTierGoogleOne = ref<'google_one_free' | 'google_ai_pro' | 'google_ai_ultra'>('google_one_free')
|
||||
@@ -3765,6 +3802,8 @@ const resetForm = () => {
|
||||
sessionIdMaskingEnabled.value = false
|
||||
cacheTTLOverrideEnabled.value = false
|
||||
cacheTTLOverrideTarget.value = '5m'
|
||||
customBaseUrlEnabled.value = false
|
||||
customBaseUrl.value = ''
|
||||
allowOverages.value = false
|
||||
antigravityAccountType.value = 'oauth'
|
||||
upstreamBaseUrl.value = ''
|
||||
@@ -4856,6 +4895,12 @@ const handleAnthropicExchange = async (authCode: string) => {
|
||||
extra.cache_ttl_override_target = cacheTTLOverrideTarget.value
|
||||
}
|
||||
|
||||
// Add custom base URL settings
|
||||
if (customBaseUrlEnabled.value && customBaseUrl.value.trim()) {
|
||||
extra.custom_base_url_enabled = true
|
||||
extra.custom_base_url = customBaseUrl.value.trim()
|
||||
}
|
||||
|
||||
const credentials: Record<string, unknown> = { ...tokenInfo }
|
||||
applyInterceptWarmup(credentials, interceptWarmupRequests.value, 'create')
|
||||
await createAccountAndFinish(form.platform, addMethod.value as AccountType, credentials, extra)
|
||||
@@ -4974,6 +5019,12 @@ const handleCookieAuth = async (sessionKey: string) => {
|
||||
extra.cache_ttl_override_target = cacheTTLOverrideTarget.value
|
||||
}
|
||||
|
||||
// Add custom base URL settings
|
||||
if (customBaseUrlEnabled.value && customBaseUrl.value.trim()) {
|
||||
extra.custom_base_url_enabled = true
|
||||
extra.custom_base_url = customBaseUrl.value.trim()
|
||||
}
|
||||
|
||||
const accountName = keys.length > 1 ? `${form.name} #${i + 1}` : form.name
|
||||
|
||||
const credentials: Record<string, unknown> = { ...tokenInfo }
|
||||
|
||||
@@ -1580,6 +1580,41 @@
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Custom Base URL Relay -->
|
||||
<div class="rounded-lg border border-gray-200 p-4 dark:border-dark-600">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<label class="input-label mb-0">{{ t('admin.accounts.quotaControl.customBaseUrl.label') }}</label>
|
||||
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">
|
||||
{{ t('admin.accounts.quotaControl.customBaseUrl.hint') }}
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
@click="customBaseUrlEnabled = !customBaseUrlEnabled"
|
||||
:class="[
|
||||
'relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2',
|
||||
customBaseUrlEnabled ? 'bg-primary-600' : 'bg-gray-200 dark:bg-dark-600'
|
||||
]"
|
||||
>
|
||||
<span
|
||||
:class="[
|
||||
'pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out',
|
||||
customBaseUrlEnabled ? 'translate-x-5' : 'translate-x-0'
|
||||
]"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="customBaseUrlEnabled" class="mt-3">
|
||||
<input
|
||||
v-model="customBaseUrl"
|
||||
type="text"
|
||||
class="input"
|
||||
:placeholder="t('admin.accounts.quotaControl.customBaseUrl.urlHint')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="border-t border-gray-200 pt-4 dark:border-dark-600">
|
||||
@@ -1854,6 +1889,8 @@ const tlsFingerprintProfiles = ref<{ id: number; name: string }[]>([])
|
||||
const sessionIdMaskingEnabled = ref(false)
|
||||
const cacheTTLOverrideEnabled = ref(false)
|
||||
const cacheTTLOverrideTarget = ref<string>('5m')
|
||||
const customBaseUrlEnabled = ref(false)
|
||||
const customBaseUrl = ref('')
|
||||
|
||||
// OpenAI 自动透传开关(OAuth/API Key)
|
||||
const openaiPassthroughEnabled = ref(false)
|
||||
@@ -2482,6 +2519,8 @@ function loadQuotaControlSettings(account: Account) {
|
||||
sessionIdMaskingEnabled.value = false
|
||||
cacheTTLOverrideEnabled.value = false
|
||||
cacheTTLOverrideTarget.value = '5m'
|
||||
customBaseUrlEnabled.value = false
|
||||
customBaseUrl.value = ''
|
||||
|
||||
// Only applies to Anthropic OAuth/SetupToken accounts
|
||||
if (account.platform !== 'anthropic' || (account.type !== 'oauth' && account.type !== 'setup-token')) {
|
||||
@@ -2528,6 +2567,12 @@ function loadQuotaControlSettings(account: Account) {
|
||||
cacheTTLOverrideEnabled.value = true
|
||||
cacheTTLOverrideTarget.value = account.cache_ttl_override_target || '5m'
|
||||
}
|
||||
|
||||
// Load custom base URL setting
|
||||
if (account.custom_base_url_enabled === true) {
|
||||
customBaseUrlEnabled.value = true
|
||||
customBaseUrl.value = account.custom_base_url || ''
|
||||
}
|
||||
}
|
||||
|
||||
function formatTempUnschedKeywords(value: unknown) {
|
||||
@@ -2980,6 +3025,15 @@ const handleSubmit = async () => {
|
||||
delete newExtra.cache_ttl_override_target
|
||||
}
|
||||
|
||||
// Custom base URL relay setting
|
||||
if (customBaseUrlEnabled.value && customBaseUrl.value.trim()) {
|
||||
newExtra.custom_base_url_enabled = true
|
||||
newExtra.custom_base_url = customBaseUrl.value.trim()
|
||||
} else {
|
||||
delete newExtra.custom_base_url_enabled
|
||||
delete newExtra.custom_base_url
|
||||
}
|
||||
|
||||
updatePayload.extra = newExtra
|
||||
}
|
||||
|
||||
|
||||
@@ -2318,6 +2318,11 @@ export default {
|
||||
target: 'Target TTL',
|
||||
targetHint: 'Select the TTL tier for billing'
|
||||
},
|
||||
customBaseUrl: {
|
||||
label: 'Custom Relay URL',
|
||||
hint: 'Forward requests to a custom relay service. Proxy URL will be passed as a query parameter.',
|
||||
urlHint: 'Relay service URL (e.g., https://relay.example.com)',
|
||||
},
|
||||
clientAffinity: {
|
||||
label: 'Client Affinity Scheduling',
|
||||
hint: 'When enabled, new sessions prefer accounts previously used by this client to reduce account switching'
|
||||
|
||||
@@ -2462,6 +2462,11 @@ export default {
|
||||
target: '目标 TTL',
|
||||
targetHint: '选择计费使用的 TTL 类型'
|
||||
},
|
||||
customBaseUrl: {
|
||||
label: '自定义转发地址',
|
||||
hint: '启用后将请求转发到自定义中继服务,代理地址将作为 URL 参数传递给中继服务',
|
||||
urlHint: '中继服务地址(如 https://relay.example.com)',
|
||||
},
|
||||
clientAffinity: {
|
||||
label: '客户端亲和调度',
|
||||
hint: '启用后,新会话会优先调度到该客户端之前使用过的账号,避免频繁切换账号'
|
||||
|
||||
@@ -734,6 +734,10 @@ export interface Account {
|
||||
cache_ttl_override_enabled?: boolean | null
|
||||
cache_ttl_override_target?: string | null
|
||||
|
||||
// 自定义 Base URL 中继转发(仅 Anthropic OAuth/SetupToken 账号有效)
|
||||
custom_base_url_enabled?: boolean | null
|
||||
custom_base_url?: string | null
|
||||
|
||||
// 客户端亲和调度(仅 Anthropic/Antigravity 平台有效)
|
||||
// 启用后新会话会优先调度到客户端之前使用过的账号
|
||||
client_affinity_enabled?: boolean | null
|
||||
|
||||
Reference in New Issue
Block a user