diff --git a/frontend/src/components/keys/UseKeyModal.vue b/frontend/src/components/keys/UseKeyModal.vue index 9414523d..7db67b96 100644 --- a/frontend/src/components/keys/UseKeyModal.vue +++ b/frontend/src/components/keys/UseKeyModal.vue @@ -28,7 +28,29 @@ {{ platformDescription }}

- + +
+ +
+ +
+ + + +
(null) const selectedKey = ref(null) const copiedKeyId = ref(null) const groupSelectorKeyId = ref(null) @@ -871,8 +916,48 @@ const closeModals = () => { } } -const importToCcswitch = (apiKey: string) => { +const importToCcswitch = (row: ApiKey) => { + const platform = row.group?.platform || 'anthropic' + + // For antigravity platform, show client selection dialog + if (platform === 'antigravity') { + pendingCcsRow.value = row + showCcsClientSelect.value = true + return + } + + // For other platforms, execute directly + executeCcsImport(row, platform === 'gemini' ? 'gemini' : 'claude') +} + +const executeCcsImport = (row: ApiKey, clientType: 'claude' | 'gemini') => { const baseUrl = publicSettings.value?.api_base_url || window.location.origin + const platform = row.group?.platform || 'anthropic' + + // Determine app name and endpoint based on platform and client type + let app: string + let endpoint: string + + if (platform === 'antigravity') { + // Antigravity always uses /antigravity suffix + app = clientType === 'gemini' ? 'gemini' : 'claude' + endpoint = `${baseUrl}/antigravity` + } else { + switch (platform) { + case 'openai': + app = 'codex' + endpoint = baseUrl + break + case 'gemini': + app = 'gemini' + endpoint = baseUrl + break + default: // anthropic + app = 'claude' + endpoint = baseUrl + } + } + const usageScript = `({ request: { url: "{{baseUrl}}/v1/usage", @@ -889,11 +974,11 @@ const importToCcswitch = (apiKey: string) => { })` const params = new URLSearchParams({ resource: 'provider', - app: 'claude', + app: app, name: 'sub2api', homepage: baseUrl, - endpoint: baseUrl, - apiKey: apiKey, + endpoint: endpoint, + apiKey: row.key, configFormat: 'json', usageEnabled: 'true', usageScript: btoa(usageScript), @@ -916,6 +1001,19 @@ const importToCcswitch = (apiKey: string) => { } } +const handleCcsClientSelect = (clientType: 'claude' | 'gemini') => { + if (pendingCcsRow.value) { + executeCcsImport(pendingCcsRow.value, clientType) + } + showCcsClientSelect.value = false + pendingCcsRow.value = null +} + +const closeCcsClientSelect = () => { + showCcsClientSelect.value = false + pendingCcsRow.value = null +} + onMounted(() => { loadApiKeys() loadGroups()