feat(frontend): add multi-platform key setup and refine account controls

Share platform-specific configuration and CC Switch imports across key pages. Make connection test models searchable and hide account-wide forecasts for Antigravity.

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Zyy
2026-11-28 14:27:04 +08:00
co-authored by Codex
parent 2b6536236f
commit 2ec300ecf4
18 changed files with 184 additions and 158 deletions
+21 -4
View File
@@ -625,11 +625,28 @@ Caddy 与应用同在容器网络时,将回源地址改为 `codex-proxy-rs:808
直接发送 HTTP 请求时,参见 [Messages 示例](../docs/api.md#messages-请求)和 [GenAI 接口与鉴权](../docs/api.md#antigravity-客户端原生生成)
使用 Codex 时,打开「使用密钥」,按操作系统复制 `config.toml`。
在密钥列表点「使用密钥」,或在密钥用量页点「配置」,按平台切换 Codex(OpenAI)、Grok Build(xAI)和 Antigravity,再选择操作系统复制配置。Codex 和 Grok Build 模板使用固定模型,可在复制后改为密钥可用的型号
Antigravity 桌面版与 CLI 共用 `~/.gemini/config/config.json`(Windows 为 `%USERPROFILE%\.gemini\config\config.json`):
1. 如 CLI 仍登录旧 Google 账号,在 `agy` 中输入 `/logout`,回到登录选择页后按 Ctrl+C 退出
2. 在 macOS/Linux 用以下命令准备文件。将弹窗中的 JSON 写入空文件;已有配置只合并或更新顶层 `gateway`,保留 `plugins`、`sidecars`、`userSettings` 等字段
```sh
mkdir -p ~/.gemini/config
touch ~/.gemini/config/config.json
chmod 600 ~/.gemini/config/config.json
```
3. `gateway.url` 填网关根地址,子路径部署保留部署前缀。使用 `genai` 时客户端会追加 `/v1beta/models`
4. 完全退出并重新打开桌面版。CLI 可用 `agy models` 查看目录,运行 `agy` 后输入 `/model` 选择模型
使用 Codex 时,按操作系统复制 `config.toml`。
已有配置先备份,合并后完全退出并重启 Codex。代理密钥由 Provider 配置提供,
不需要另写 `auth.json`,已有官方登录文件可以保留
管理端生成的 CC Switch 一键导入包含连接信息和当前 Key 的日/周额度查询,默认每 30 分钟刷新。
点「导入到」后选择 CC Switch,导入当前平台的客户端配置和日/周额度查询,默认每 30 分钟刷新。密钥列表的更多菜单和密钥创建成功弹窗也支持直接导入,可在工具选择框切换平台。
Antigravity 导入为 CC Switch 的 CLI 供应商卡片,模型使用显示名 `Gemini 4 Neon (High)`,从卡片打开终端即可使用。桌面版和独立启动的 CLI 使用上面的共享网关配置。
查询地址和凭据随导入生成,在 CC Switch 中修改 Provider 的地址或 Key 后,需重新导入以同步用量查询。
导入不包含下方模板的远程压缩、异步压缩、原生生图、WebSocket 和语音设置。需要这些设置时,使用下方配置直连 CPR,
避免 CC Switch 切换或接管后重写 Provider 配置
@@ -644,8 +661,8 @@ Linux/macOS 默认目录为 `~/.codex/`,Windows 为 `%USERPROFILE%\.codex\`;
```toml
model_provider = "OpenAI"
model = "gpt-5.6-terra"
review_model = "gpt-5.6-terra"
model = "gpt-6-luna"
review_model = "gpt-6-luna"
model_reasoning_effort = "max"
service_tier = "default"
# 语音通话控制地址
+1 -1
View File
@@ -1042,7 +1042,7 @@ KeyUsageService 从 AuthService 的服务端身份或 Core 的入口认证结果
ObservabilityStore 的范围查询;数据面额度查询不执行推理准入或开启窗口,入口认证和适用的请求中间件仍会执行。
API 只输出各入口所需的字段白名单,不复用管理员的宽响应。
客户端配置通过 ClientKeyStore 显式读取当前会话绑定 Key 的明文,不进入用量响应。
前端 `/key-usage` 独立于管理布局,不挂载管理员菜单或请求管理接口;配置弹窗、Codex 配置及 CC Switch
前端 `/key-usage` 独立于管理布局,不挂载管理员菜单或请求管理接口;各平台的配置模板、配置弹窗及 CC Switch
导入链接生成逻辑与管理端共用,明文仅在打开弹窗时获取,关闭后清除,不持久化到浏览器
## 8. 状态所有权
@@ -1,18 +1,23 @@
<script setup lang="ts">
import type { BuiltinProvider } from '@/providers/catalog'
import { Github } from '@boxicons/vue'
import { ZDialog, ZMenuItem } from '@codex-proxy/ui'
import { AppWindow } from '@lucide/vue'
import { shallowRef } from 'vue'
import { useI18n } from 'vue-i18n'
import ProviderSelect from '@/components/ProviderSelect.vue'
const props = defineProps<{ provider?: BuiltinProvider }>()
const emit = defineEmits<{
select: []
select: [provider: BuiltinProvider]
afterLeave: []
}>()
const open = defineModel<boolean>({ default: false })
const selectedProvider = shallowRef<BuiltinProvider>('openai')
const { t } = useI18n({ useScope: 'global' })
function select() {
emit('select')
emit('select', props.provider ?? selectedProvider.value)
open.value = false
}
</script>
@@ -26,6 +31,7 @@ function select() {
@closed="emit('afterLeave')"
>
<div class="grid gap-2">
<ProviderSelect v-if="!provider" v-model="selectedProvider" :aria-label="t('keys.configuration.platform')" />
<div
class="flex items-center gap-1 rounded-z-sm pr-1 transition-colors hover:bg-z-bg-text-hover has-focus-visible:bg-z-bg-text-hover motion-reduce:transition-none"
>
@@ -1,20 +1,25 @@
import type { BuiltinProvider } from '@/providers/catalog'
import { API_BASE_URL } from '@/api/constants'
const CODEX_DEFAULT_MODEL = 'gpt-5.6-terra'
export const CODEX_WEBSOCKET_ENABLED_BY_DEFAULT = false
const clientPresets = {
openai: { app: 'codex', model: 'gpt-6-luna' },
xai: { app: 'grokbuild', model: 'grok-4.7' },
antigravity: { app: 'agy', model: 'Gemini 4 Neon (High)' },
} satisfies Record<BuiltinProvider, { app: string, model: string }>
interface CodexConfigInput {
interface SetupInput {
provider: BuiltinProvider
apiKey: string
baseUrl: string
websocketEnabled?: boolean
root: string
windows: boolean
websocketEnabled: boolean
}
export function buildCodexConfig(input: CodexConfigInput): string {
const baseUrl = input.baseUrl.replace(/\/+$/, '')
const websocketEnabled = input.websocketEnabled ?? CODEX_WEBSOCKET_ENABLED_BY_DEFAULT
function buildCodexConfig(apiKey: string, baseUrl: string, websocketEnabled: boolean) {
const model = JSON.stringify(clientPresets.openai.model)
return `model_provider = "OpenAI"
model = "${CODEX_DEFAULT_MODEL}"
review_model = "${CODEX_DEFAULT_MODEL}"
model = ${model}
review_model = ${model}
model_reasoning_effort = "max"
service_tier = "default"
# 语音通话控制地址
@@ -28,7 +33,7 @@ wire_api = "responses"
supports_websockets = ${websocketEnabled}
requires_openai_auth = false
# 代理密钥
experimental_bearer_token = ${JSON.stringify(input.apiKey)}
experimental_bearer_token = ${JSON.stringify(apiKey)}
[model_providers.OpenAI.capabilities]
# V2 远程压缩
@@ -45,9 +50,47 @@ image_generation = true
goals = true`
}
interface CodexCcSwitchImportInput {
export function buildClientConfig({ provider, root, apiKey, windows, websocketEnabled }: SetupInput) {
const path = (relative: string) => windows
? `%USERPROFILE%\\${relative.replaceAll('/', '\\')}`
: `~/${relative}`
const baseUrl = `${root}/v1`
if (provider === 'openai') {
return {
title: path('.codex/config.toml'),
text: buildCodexConfig(apiKey, baseUrl, websocketEnabled),
}
}
if (provider === 'xai') {
return {
title: path('.grok/config.toml'),
text: `[models]
default = "cpr"
[model.cpr]
model = ${JSON.stringify(clientPresets.xai.model)}
base_url = ${JSON.stringify(baseUrl)}
api_key = ${JSON.stringify(apiKey)}
api_backend = "responses"`,
}
}
return {
title: path('.gemini/config/config.json'),
text: JSON.stringify({
gateway: {
enabled: true,
url: root,
wireProtocol: 'genai',
apiKey,
},
}, null, 2),
}
}
interface CcSwitchImportInput {
provider: BuiltinProvider
apiKey: string
baseUrl: string
providerName: string
}
@@ -84,16 +127,20 @@ function buildUsageScript(apiKey: string, baseUrl: string) {
})`
}
export function buildCodexCcSwitchImportDeeplink(input: CodexCcSwitchImportInput): string {
const baseUrl = input.baseUrl.replace(/\/+$/, '')
export function buildCcSwitchImportDeeplink(input: CcSwitchImportInput): string {
const root = resolveServiceRootUrl()
const baseUrl = `${root}/v1`
const endpoint = input.provider === 'antigravity'
? root
: baseUrl
// 导入端会重建 Codex 配置,只传连接信息和用量查询,不传无法保留的完整模板
const entries: [string, string][] = [
['resource', 'provider'],
['app', 'codex'],
['model', CODEX_DEFAULT_MODEL],
['app', clientPresets[input.provider].app],
['model', clientPresets[input.provider].model],
['name', input.providerName],
['homepage', baseUrl],
['endpoint', baseUrl],
['homepage', root],
['endpoint', endpoint],
['apiKey', input.apiKey],
['usageEnabled', 'true'],
[
@@ -1,120 +1,78 @@
<script setup lang="ts">
import type { BuiltinProvider } from '@/providers/catalog'
import { Apple, MicrosoftWindows, Tux } from '@boxicons/vue'
import { ZButton, ZDialog, ZIconButton, ZScrollbar, ZSegmented, ZSwitch } from '@codex-proxy/ui'
import { Apple, Copy, Monitor, Upload } from '@lucide/vue'
import { Copy, Upload } from '@lucide/vue'
import { computed, shallowRef } from 'vue'
import { useI18n } from 'vue-i18n'
import ClientImportModal from '../ClientImportModal.vue'
import { buildCodexCcSwitchImportDeeplink, buildCodexConfig, CODEX_WEBSOCKET_ENABLED_BY_DEFAULT } from './client'
const props = defineProps<{
title?: string
apiKey: {
name?: string
key?: string
} | null
apiBaseUrl: string
}>()
const emit = defineEmits<{
copy: [text: string]
afterLeave: []
}>()
const { t } = useI18n({ useScope: 'global' })
import ClientImportModal from '@/components/ClientImportModal.vue'
import ProviderSelect from '@/components/ProviderSelect.vue'
import { buildCcSwitchImportDeeplink, buildClientConfig, resolveServiceRootUrl } from './client'
const props = defineProps<{ title?: string, apiKey: { name?: string, key?: string } | null }>()
const emit = defineEmits<{ copy: [text: string], afterLeave: [] }>()
const open = defineModel<boolean>({ default: false })
const { t } = useI18n({ useScope: 'global' })
const showImport = shallowRef(false)
const activePlatform = shallowRef('unix')
const websocketEnabled = shallowRef(CODEX_WEBSOCKET_ENABLED_BY_DEFAULT)
const key = computed(() => props.apiKey?.key ?? '')
const provider = shallowRef<BuiltinProvider>('openai')
const platform = shallowRef('macos')
const ws = shallowRef(false)
const root = resolveServiceRootUrl()
const platformOptions = [
{ label: 'macOS / Linux', value: 'unix', icon: Apple },
{ label: 'Windows', value: 'windows', icon: Monitor },
{ label: 'macOS', value: 'macos', icon: Apple },
{ label: 'Linux', value: 'linux', icon: Tux },
{ label: 'Windows', value: 'windows', icon: MicrosoftWindows },
]
const keyValue = computed(() => props.apiKey?.key ?? '')
const configPath = computed(() =>
activePlatform.value === 'windows'
? '%userprofile%\\.codex\\config.toml'
: '~/.codex/config.toml',
)
const codexConfig = computed(() => buildCodexConfig({
apiKey: keyValue.value,
baseUrl: props.apiBaseUrl,
websocketEnabled: websocketEnabled.value,
const config = computed(() => buildClientConfig({
provider: provider.value,
root,
apiKey: key.value,
windows: platform.value === 'windows',
websocketEnabled: ws.value,
}))
function importToClient() {
if (!keyValue.value)
if (!key.value)
return
window.location.href = buildCodexCcSwitchImportDeeplink({
apiKey: keyValue.value,
baseUrl: props.apiBaseUrl,
window.location.href = buildCcSwitchImportDeeplink({
provider: provider.value,
apiKey: key.value,
providerName: props.apiKey?.name || 'codex-proxy-rs',
})
}
</script>
<template>
<ZDialog
v-model="open"
:title="title ?? t('keys.configuration.title')"
:description="t('keys.configuration.description')"
width="48rem"
@closed="showImport = false; emit('afterLeave')"
>
<div class="flex flex-col gap-5">
<div class="flex flex-wrap items-center justify-between gap-3">
<ZSegmented v-model="activePlatform" :aria-label="t('keys.configuration.platform')" :options="platformOptions" />
<ZSwitch
v-model="websocketEnabled"
:aria-label="t('keys.configuration.toggleWebSocket')"
active-text="WS"
inactive-text="WS"
inline-prompt
:width="56"
/>
<ZDialog v-model="open" :title="title ?? t('keys.configuration.title')" width="46rem" @closed="showImport = false; emit('afterLeave')">
<div class="grid min-w-0 gap-3">
<div class="flex flex-wrap items-center justify-between gap-2">
<ProviderSelect v-model="provider" :aria-label="t('keys.configuration.platform')" />
<ZSegmented v-model="platform" :aria-label="t('keys.configuration.os')" :options="platformOptions" display="icon" class="w-30 [&_svg]:size-4.5" size="small" />
</div>
<section class="overflow-hidden rounded-z-card bg-z-fill-quaternary shadow-z-tertiary">
<div class="flex items-center justify-between gap-3 px-4 py-2.5">
<span
class="min-w-0 truncate font-mono text-z-sm font-emphasis text-z-text-secondary"
>
{{ configPath }}
</span>
<ZIconButton
variant="solid"
size="small"
:aria-label="t('common.actions.copy')"
@click="emit('copy', codexConfig)"
>
<Copy class="size-3.5" />
</ZIconButton>
</div>
<ZScrollbar max-height="calc(100dvh - 21rem)">
<div class="mx-3 mb-3 rounded-z bg-z-bg-container px-3.5 py-3 shadow-z-tertiary">
<pre
class="m-0 whitespace-pre-wrap wrap-break-word font-mono text-z-sm leading-[1.65] font-emphasis text-z-text"
v-text="codexConfig"
/>
<section class="min-w-0 overflow-hidden rounded-z-card bg-z-fill-quaternary">
<ZScrollbar max-height="min(58dvh, 34rem)">
<div class="mx-3 mb-3 min-w-0">
<div class="flex flex-wrap items-center gap-3 py-2">
<code class="min-w-0 flex-1 break-all text-z-sm text-z-text-secondary">{{ config.title }}</code>
<ZSwitch v-if="provider === 'openai'" v-model="ws" :aria-label="t('keys.configuration.toggleWebSocket')" active-text="WS" inactive-text="WS" inline-prompt :width="56" />
<ZIconButton variant="solid" size="small" :disabled="!key" :aria-label="t('common.actions.copy')" @click="emit('copy', config.text)">
<Copy class="size-3.5" />
</ZIconButton>
</div>
<pre class="m-0 rounded-z bg-z-bg-container px-3.5 py-3 font-mono text-z-sm leading-relaxed wrap-anywhere whitespace-pre-wrap text-z-text" v-text="config.text" />
</div>
</ZScrollbar>
</section>
</div>
<template #footer>
<ZButton :disabled="!keyValue" @click="showImport = true">
<Upload class="size-4" />
{{ t('keys.configuration.importTo') }}
<ZButton :disabled="!key" @click="showImport = true">
<Upload class="size-4" /> {{ t('keys.configuration.importTo') }}
</ZButton>
<ZButton type="primary" @click="open = false">
{{ t('common.actions.close') }}
</ZButton>
</template>
</ZDialog>
<ClientImportModal v-if="open" v-model="showImport" @select="importToClient" />
<ClientImportModal v-if="open" v-model="showImport" :provider="provider" @select="importToClient" />
</template>
+4 -4
View File
@@ -1,15 +1,15 @@
{
"keys": {
"configuration": {
"description": "Save or merge the configuration below and then restart Codex",
"platform": "Platform",
"toggleWebSocket": "Switch WebSocket configuration",
"fullApiKeyNotAvailable": "Full API key not available",
"title": "Use API key",
"os": "Operating system",
"importTo": "Import",
"selectImportTool": "Choose a tool to import into",
"ccSwitchDescription": "Manage AI client configurations",
"viewOnGitHub": "View {name} on GitHub",
"fullApiKeyNotAvailable": "Full API key not available",
"title": "Use API key"
"viewOnGitHub": "View {name} on GitHub"
},
"actions": {
"editKey": "Edit key",
+5 -5
View File
@@ -1,15 +1,15 @@
{
"keys": {
"configuration": {
"description": "保存或合并下方配置后重启 Codex",
"platform": "配置平台",
"platform": "平台",
"toggleWebSocket": "切换 WebSocket 配置",
"fullApiKeyNotAvailable": "完整 API密钥不可用",
"title": "使用密钥",
"os": "操作系统",
"importTo": "导入到",
"selectImportTool": "选择要导入的工具",
"ccSwitchDescription": "管理和切换 AI 客户端配置",
"viewOnGitHub": "在 GitHub 查看 {name}",
"fullApiKeyNotAvailable": "完整 API密钥不可用",
"title": "使用密钥"
"viewOnGitHub": "在 GitHub 查看 {name}"
},
"actions": {
"editKey": "编辑密钥",
+5 -5
View File
@@ -1,15 +1,15 @@
{
"keys": {
"configuration": {
"description": "保存或合併下方配置後重啓 Codex",
"platform": "配置平臺",
"platform": "平台",
"toggleWebSocket": "切換 WebSocket 配置",
"fullApiKeyNotAvailable": "完整 API密鑰不可用",
"title": "使用密鑰",
"os": "作業系統",
"importTo": "導入到",
"selectImportTool": "選擇要導入的工具",
"ccSwitchDescription": "管理和切換 AI 客戶端配置",
"viewOnGitHub": "在 GitHub 查看 {name}",
"fullApiKeyNotAvailable": "完整 API密鑰不可用",
"title": "使用密鑰"
"viewOnGitHub": "在 GitHub 查看 {name}"
},
"actions": {
"editKey": "編輯密鑰",
+1 -1
View File
@@ -5,8 +5,8 @@ import { t } from '@/i18n'
const providers = {
openai: { label: 'OpenAI', icon: Openai },
xai: { label: 'xAI', icon: Xai },
antigravity: { label: 'Antigravity', icon: GoogleAntigravity },
xai: { label: 'xAI', icon: Xai },
} as const
export const PROVIDER_IDS = Object.keys(providers) as BuiltinProvider[]
@@ -95,6 +95,7 @@ function connectionLogClass(tone: string) {
</div>
<ZSelect
v-model="selectedModel"
filterable
:aria-label="t('accounts.connectionTest.model')"
:options="modelOptions"
:disabled="status === 'running' || loadingModels || refreshingModels"
@@ -52,7 +52,8 @@ const creditsOpen = shallowRef(false)
const profileOpen = shallowRef(false)
const forecastOpen = shallowRef(false)
const hasPlanBadge = computed(() => Boolean(props.account.planType) || props.account.authenticationKind === 'api_key')
const hasForecast = computed(() => props.account.authenticationKind !== 'api_key')
// Antigravity 的额度按模型组返回,不能用于整号周/月预测。
const hasForecast = computed(() => props.account.provider !== 'antigravity' && props.account.authenticationKind !== 'api_key')
const hasPersonalInfo = computed(() => props.account.capabilities.profile || props.account.capabilities.subscription)
const needsPeerDiscovery = computed(() => props.account.upstream?.discovered === false)
const canRefresh = computed(() => props.account.capabilities.quotaRefresh || props.account.upstream != null)
@@ -109,7 +109,7 @@ const additionalEntryCount = computed(() => Math.max(summaryEntries.value.length
</div>
<span
v-if="additionalEntryCount > 0"
class="grid h-5 min-w-5 shrink-0 place-items-center rounded-z bg-z-fill-quaternary px-1.5 font-mono text-[9px] font-heavy tabular-nums text-z-text-tertiary"
class="grid h-5 min-w-5 shrink-0 place-items-center rounded-z bg-current/10 px-1 font-mono text-[9px] font-heavy tabular-nums text-z-text-tertiary"
:title="t('accounts.quota.moreGroups', { count: additionalEntryCount })"
>
+{{ additionalEntryCount }}
@@ -1,3 +1,4 @@
import type { SelectOption } from '@codex-proxy/ui'
import type { Account, AccountModelsResponse } from '@/api'
import { CheckCircle2, Clock3, Wifi, XCircle } from '@lucide/vue'
import { useEventSource } from '@vueuse/core'
@@ -14,11 +15,6 @@ import { errorMessage } from '@/utils/operation'
type ConnectionTestStatus = 'idle' | 'running' | 'success' | 'error'
type ConnectionTestLogTone = 'normal' | 'info' | 'success' | 'danger'
interface ConnectionTestModelOption {
label: string
value: string
}
interface ConnectionTestLog {
key: string
time: string
@@ -179,7 +175,7 @@ export function useAccountConnectionTest(options: { reload: () => Promise<unknow
const loadingConnectionTestModels = computed(() => modelsRequest.loading.value && modelsRequestMode.value === 'load')
const refreshingConnectionTestModels = computed(() => modelsRequest.loading.value && modelsRequestMode.value === 'refresh')
const connectionTestSelectedModel = shallowRef('')
const connectionTestModelOptions = ref<ConnectionTestModelOption[]>([])
const connectionTestModelOptions = ref<SelectOption[]>([])
const connectionTestStreamUrl = shallowRef<string>()
const {
data: connectionTestStreamMessage,
@@ -452,7 +448,13 @@ export function useAccountConnectionTest(options: { reload: () => Promise<unknow
labels.set(id, id)
}
}
connectionTestModelOptions.value = Array.from(labels, ([value, label]) => ({ value, label }))
connectionTestModelOptions.value = Array.from(labels, ([value, label]) => ({
value,
label,
description: value === label
? undefined
: value,
}))
connectionTestSelectedModel.value = labels.has(previousSelection)
? previousSelection
: connectionTestModelOptions.value[0]?.value || ''
@@ -1,6 +1,5 @@
import { computed, onScopeDispose, shallowRef } from 'vue'
import { onScopeDispose, shallowRef } from 'vue'
import { getKeyUsageConfig } from '@/api'
import { resolveServiceRootUrl } from '@/components/api-key-config-modal/client'
import { useCopyText } from '@/composables/useCopyText'
import { useRequestState } from '@/composables/useRequestState'
@@ -9,7 +8,6 @@ export function useKeyConfig() {
const configKey = shallowRef<{ name: string, key: string } | null>(null)
const request = useRequestState()
const copyText = useCopyText()
const apiBaseUrl = computed(() => `${resolveServiceRootUrl()}/v1`)
async function openConfig() {
if (request.loading.value)
@@ -45,7 +43,6 @@ export function useKeyConfig() {
showConfig,
configKey,
configuring: request.loading,
apiBaseUrl,
openConfig,
copyConfig,
}
+2 -2
View File
@@ -17,7 +17,7 @@ const { t } = useI18n({ useScope: 'global' })
const { period, model, kind, refreshInterval, overview, overviewLoading, refreshing, records, refresh, changePageSize, changePage } = useKeyUsage()
const { items, currentPage, pageSize, total, loading: recordsLoading } = records
const { showConfig, configKey, configuring, apiBaseUrl, openConfig, copyConfig } = useKeyConfig()
const { showConfig, configKey, configuring, openConfig, copyConfig } = useKeyConfig()
</script>
<template>
@@ -49,6 +49,6 @@ const { showConfig, configKey, configuring, apiBaseUrl, openConfig, copyConfig }
<KeyUsageRecords v-model:kind="kind" :rows="items" :pagination="{ currentPage, pageSize, total }" :loading="recordsLoading" @page-change="changePage" @page-size-change="changePageSize" />
</div>
</ZScrollbar>
<ApiKeyConfigModal v-model="showConfig" :title="t('usage.header.keyConfiguration')" :api-key="configKey" :api-base-url="apiBaseUrl" @copy="copyConfig" @after-leave="configKey = null" />
<ApiKeyConfigModal v-model="showConfig" :title="t('usage.header.keyConfiguration')" :api-key="configKey" @copy="copyConfig" @after-leave="configKey = null" />
</main>
</template>
@@ -1,4 +1,5 @@
<script setup lang="ts">
import type { BuiltinProvider } from '@/providers/catalog'
import { ZButton, ZDialog, ZIconButton } from '@codex-proxy/ui'
import { Copy, Upload } from '@lucide/vue'
@@ -10,7 +11,7 @@ defineProps<{ createdKey: string }>()
const emit = defineEmits<{
copy: [text: string]
importClient: []
importClient: [provider: BuiltinProvider]
afterLeave: []
}>()
@@ -62,5 +63,5 @@ const showImport = shallowRef(false)
</ZButton>
</template>
</ZDialog>
<ClientImportModal v-if="open" v-model="showImport" @select="emit('importClient')" />
<ClientImportModal v-if="open" v-model="showImport" @select="emit('importClient', $event)" />
</template>
@@ -1,7 +1,8 @@
import type { ApiKey } from '@/api'
import type { BuiltinProvider } from '@/providers/catalog'
import { onScopeDispose, shallowRef } from 'vue'
import { revealApiKey } from '@/api'
import { buildCodexCcSwitchImportDeeplink, resolveServiceRootUrl } from '@/components/api-key-config-modal/client'
import { buildCcSwitchImportDeeplink } from '@/components/api-key-config-modal/client'
import { useCopyText } from '@/composables/useCopyText'
import { useRequestState } from '@/composables/useRequestState'
import { t } from '@/i18n'
@@ -28,15 +29,13 @@ export function useApiKeyUse() {
showCreatedKeyModal.value = true
}
const openAiBaseUrl = `${resolveServiceRootUrl()}/v1`
function importCreatedKey() {
function importCreatedKey(provider: BuiltinProvider) {
if (!createdKey.value)
return
window.location.href = buildCodexCcSwitchImportDeeplink({
window.location.href = buildCcSwitchImportDeeplink({
apiKey: createdKey.value,
baseUrl: openAiBaseUrl,
provider,
providerName: createdKeyName.value || 'codex-proxy-rs',
})
}
@@ -54,14 +53,14 @@ export function useApiKeyUse() {
showImportKeyModal.value = true
}
function importSelectedKey() {
function importSelectedKey(provider: BuiltinProvider) {
const apiKey = selectedImportKey.value
if (!apiKey)
return
return withPlaintextKey(apiKey, 'import', (key) => {
window.location.href = buildCodexCcSwitchImportDeeplink({
window.location.href = buildCcSwitchImportDeeplink({
apiKey: key,
baseUrl: openAiBaseUrl,
provider,
providerName: apiKey.name || apiKey.prefix || 'codex-proxy-rs',
})
})
@@ -125,7 +124,6 @@ export function useApiKeyUse() {
showImportKeyModal,
selectedImportKey,
revealingKeys,
openAiBaseUrl,
showCreatedKey,
clearCreatedKey,
copyToClipboard,
-2
View File
@@ -67,7 +67,6 @@ const {
showImportKeyModal,
selectedImportKey,
revealingKeys,
openAiBaseUrl,
showCreatedKey,
clearCreatedKey,
copyToClipboard,
@@ -298,7 +297,6 @@ watch([showFormModal, showBatchEdit], ([editor, batch]) => {
<ApiKeyConfigModal
v-model="showUseKeyModal"
:api-key="selectedUseKey"
:api-base-url="openAiBaseUrl"
@copy="copyToClipboard"
@after-leave="selectedUseKey = null"
/>