Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions backend/crates/providers/openai/src/credential/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -985,9 +985,7 @@ impl CodexCredentialAdminService {
ParsedCodexAuthentication::ApiKey(data) => {
let mut prepared = CodexCredentialAdmin.prepare_api_key(
account_id,
candidate
.name
.unwrap_or_else(|| "OpenAI API Key".to_owned()),
candidate.name.unwrap_or_else(|| "密钥账号".to_owned()),
data,
)?;
prepared.model_access = candidate.model_access;
Expand Down
2 changes: 2 additions & 0 deletions backend/crates/providers/openai/tests/credential/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,7 @@ async fn api_key_import_export_preserves_target_without_oauth_exchange() {
.into_accounts()
.pop()
.unwrap();
assert_eq!(restored.account.name(), "relay");
let CodexCredentialData::ApiKey(data) =
CodexCredentialCodec::decode_complete(&restored.credential).unwrap()
else {
Expand Down Expand Up @@ -1127,6 +1128,7 @@ async fn messages_api_key_import_export_preserves_protocol_and_rejects_websocket
.into_accounts()
.pop()
.unwrap();
assert_eq!(imported.account.name(), "密钥账号");
let now = Utc::now();
let exported = CodexCredentialAdmin
.format_cpr_export(vec![ExportManagedCodexCredential {
Expand Down
3 changes: 2 additions & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1708,7 +1708,8 @@ RT-only 使用同一形状,只提交 `refreshToken`。不得把真实 token
管理端新建表单留空时省略 `notes`。重新授权不接受 `settings`,凭据刷新保留账号设置

可选 `name` 与编辑名称使用相同的长度和控制字符约束,仅在单份导入数据解析出一个账号时覆盖名称。
省略、`null`、留空或多账号导入均保留导入数据或服务商提供的名称;管理端批量导入不提交 `name`
省略、`null`、留空或多账号导入均保留导入数据或服务商提供的名称;管理端批量导入不提交 `name`。
API Key 账号未指定名称时默认使用「密钥账号」

账号列表的每个 item 返回轻量 `groups: [{ id, name, enabled }]`

Expand Down
2 changes: 0 additions & 2 deletions frontend/src/i18n/locales/en/accounts.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@
},
"credentials": {
"accountName": "Account name",
"enterUpstreamName": "Enter the upstream name",
"baseUrlHelp": "Enter the API base URL, endpoint paths are appended automatically",
"apiPrefix": "API prefix",
"apiKeyPlaceholder": "Leave blank to keep the current key",
Expand All @@ -148,7 +147,6 @@
"transportLabel": "Transport",
"webSocketHelp": "WS requires upstream support for Responses WebSocket",
"messagesTransportHelp": "Messages upstreams use HTTP/SSE",
"nameRequired": "Enter an account name",
"validation": {
"urlLength": "Upstream API URL must not exceed 2,048 characters",
"urlFormat": "Enter an HTTP or HTTPS URL without credentials, query parameters, or a fragment",
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/i18n/locales/zh-Hans/accounts.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@
},
"credentials": {
"accountName": "账号名称",
"enterUpstreamName": "输入上游名称",
"baseUrlHelp": "填写 API 前缀,接口路径会自动追加",
"apiPrefix": "API 前缀",
"apiKeyPlaceholder": "留空保留当前密钥",
Expand All @@ -148,7 +147,6 @@
"transportLabel": "传输方式",
"webSocketHelp": "WS 需要上游支持 Responses WebSocket",
"messagesTransportHelp": "Messages 上游使用 HTTP/SSE",
"nameRequired": "请输入账号名称",
"validation": {
"urlLength": "上游 API 地址不能超过 2048 个字符",
"urlFormat": "请输入不含认证、查询参数或片段的 HTTP 或 HTTPS 地址",
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/i18n/locales/zh-Hant/accounts.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@
},
"credentials": {
"accountName": "賬號名稱",
"enterUpstreamName": "輸入上游名稱",
"baseUrlHelp": "填寫 API 前綴,接口路徑會自動追加",
"apiPrefix": "API 前綴",
"apiKeyPlaceholder": "留空保留當前密鑰",
Expand All @@ -148,7 +147,6 @@
"transportLabel": "傳輸方式",
"webSocketHelp": "WS 需要上游支持 Responses WebSocket",
"messagesTransportHelp": "Messages 上游使用 HTTP/SSE",
"nameRequired": "請輸入賬號名稱",
"validation": {
"urlLength": "上游 API 地址不能超過 2048 個字符",
"urlFormat": "請輸入不含認證、查詢參數或片段的 HTTP 或 HTTPS 地址",
Expand Down
19 changes: 0 additions & 19 deletions frontend/src/views/accounts/components/AccountNameField.vue

This file was deleted.

10 changes: 8 additions & 2 deletions frontend/src/views/accounts/components/AccountSettingsFields.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { ZFormItem, ZInput, ZSwitch, ZTextarea } from '@codex-proxy/ui'
import { useI18n } from 'vue-i18n'
import AccountModelAccessField from '@/components/account/model-access/index.vue'
import AccountGroupCheckboxGrid from '@/components/AccountGroupCheckboxGrid.vue'
import AccountNameField from './AccountNameField.vue'
import AccountProxyField from './AccountProxyField.vue'

withDefaults(defineProps<{
Expand Down Expand Up @@ -38,7 +37,14 @@ const selectedGroupIds = defineModel<string[]>('selectedGroupIds', { required: t

<template>
<div class="grid gap-4.5">
<AccountNameField v-if="name !== undefined" v-model="name" :disabled="disabled" :placeholder="namePlaceholder" />
<ZFormItem v-if="name !== undefined" prop="name" :label="t('accounts.credentials.accountName')">
<ZInput
v-model="name"
:aria-label="t('accounts.credentials.accountName')"
:placeholder="namePlaceholder ?? t('accounts.editor.namePlaceholder')"
:disabled="disabled"
/>
</ZFormItem>
<slot name="connection" />
<AccountModelAccessField v-model="modelAccess" form-prop="modelAccess" :account-id="modelAccountId ?? accountId" :disabled="disabled" :allow-preserve="preserveModelAccess" />
<slot name="scheduling">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { useAccountSettingsFormRules } from '../../composables/useAccountSetting
import { accountCreateProvider } from '../../utils/accountCreate'
import AccountApiKeyFields from '../AccountApiKeyFields.vue'
import AccountIdentityCell from '../AccountIdentityCell.vue'
import AccountNameField from '../AccountNameField.vue'
import AccountImportFields from './AccountImportFields.vue'
import AccountOAuthFields from './AccountOAuthFields.vue'
import AccountSetupFields from './AccountSetupFields.vue'
Expand Down Expand Up @@ -186,7 +185,6 @@ async function requestCreate() {
@regenerate="emit('generateOauth')"
/>
<ZForm v-else-if="mode === 'api_key'" ref="formElement" :model="form" :rules="apiKeyRules" scroll-to-error focus-on-error novalidate @submit="requestCreate">
<AccountNameField v-model="form.name" required :disabled="busy" :placeholder="t('accounts.credentials.enterUpstreamName')" />
<AccountApiKeyFields v-model="form.apiKey" :disabled="busy" />
</ZForm>
<AccountImportFields
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,10 @@ import type { FormRules } from '@codex-proxy/ui'
import type { ApiKeyAccountForm } from '../utils/upstreamApiKey'
import { computed } from 'vue'
import { useI18n } from 'vue-i18n'
import { accountNameValid } from '../utils/accountName'

export function useAccountApiKeyFormRules(editing = false) {
const { t } = useI18n({ useScope: 'global' })
return computed<FormRules<{ apiKey: ApiKeyAccountForm, name: string }>>(() => ({
...(!editing
? {
name: [
{
required: true,
whitespace: true,
trigger: ['blur', 'change'],
message: t('accounts.credentials.nameRequired'),
},
{
validator: (_rule: unknown, value: string) => accountNameValid(value),
trigger: ['blur', 'change'],
message: t('accounts.editor.nameInvalid'),
},
],
}
: {}),
return computed<FormRules<{ apiKey: ApiKeyAccountForm }>>(() => ({
'apiKey.protocol': {
required: true,
trigger: 'change',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export function useAccountOnboarding(options: {
data: {
provider: 'openai',
authentication_kind: 'api_key',
name: form.name.trim(),
base_url: form.apiKey.base_url.trim(),
api_key: form.apiKey.apiKey,
protocol: form.apiKey.protocol,
Expand Down