diff --git a/src/locales/en-US/apikeys.ts b/src/locales/en-US/apikeys.ts index fef189173..aefd645d9 100644 --- a/src/locales/en-US/apikeys.ts +++ b/src/locales/en-US/apikeys.ts @@ -5,6 +5,11 @@ export default { 'apikeys.title.save': 'Save API Key', 'apikeys.form.expiretime': 'Expiration', 'apikeys.form.apikey': 'API Key', + 'apikeys.form.keytype': 'Key Type', + 'apikeys.form.keytype.auto': 'Auto-generated', + 'apikeys.form.keytype.custom': 'Custom', + 'apikeys.form.customkey': 'Custom API Key', + 'apikeys.form.customkey.minlength': 'Custom API key must not be empty', 'apikeys.table.name': 'Key Name', 'apikeys.table.save.tips': 'Make sure to copy your key immediately. You will not be able to see it again.', diff --git a/src/locales/ja-JP/apikeys.ts b/src/locales/ja-JP/apikeys.ts index 5dde76230..de8ec8338 100644 --- a/src/locales/ja-JP/apikeys.ts +++ b/src/locales/ja-JP/apikeys.ts @@ -5,6 +5,11 @@ export default { 'apikeys.title.save': 'APIキーを保存', 'apikeys.form.expiretime': '有効期限', 'apikeys.form.apikey': 'APIキー', + 'apikeys.form.keytype': 'キーの種類', + 'apikeys.form.keytype.auto': '自動生成', + 'apikeys.form.keytype.custom': 'カスタム', + 'apikeys.form.customkey': 'カスタムAPIキー', + 'apikeys.form.customkey.minlength': 'カスタムAPIキーは空にできません', 'apikeys.table.name': 'キー名', 'apikeys.table.save.tips': 'キーをすぐにコピーしてください。一度閉じると再表示はできません。', diff --git a/src/locales/ru-RU/apikeys.ts b/src/locales/ru-RU/apikeys.ts index 3d0921333..9072e2c87 100644 --- a/src/locales/ru-RU/apikeys.ts +++ b/src/locales/ru-RU/apikeys.ts @@ -5,6 +5,12 @@ export default { 'apikeys.title.save': 'Сохранить API-ключ', 'apikeys.form.expiretime': 'Срок действия', 'apikeys.form.apikey': 'API-ключ', + 'apikeys.form.keytype': 'Тип ключа', + 'apikeys.form.keytype.auto': 'Автоматически сгенерировано', + 'apikeys.form.keytype.custom': 'Обычай', + 'apikeys.form.customkey': 'Пользовательский ключ API', + 'apikeys.form.customkey.minlength': + 'Пользовательские API-ключи не могут быть пустыми.', 'apikeys.table.name': 'Название ключа', 'apikeys.table.save.tips': 'Обязательно скопируйте ключ сразу. Вы не сможете увидеть его снова.', diff --git a/src/locales/zh-CN/apikeys.ts b/src/locales/zh-CN/apikeys.ts index 7d50c9a8a..e89ff7ffa 100644 --- a/src/locales/zh-CN/apikeys.ts +++ b/src/locales/zh-CN/apikeys.ts @@ -5,6 +5,11 @@ export default { 'apikeys.title.save': '保存 API 密钥', 'apikeys.form.expiretime': '过期时间', 'apikeys.form.apikey': 'API 密钥', + 'apikeys.form.keytype': '密钥类型', + 'apikeys.form.keytype.auto': '自动生成', + 'apikeys.form.keytype.custom': '自定义', + 'apikeys.form.customkey': '自定义 API 密钥', + 'apikeys.form.customkey.minlength': '自定义 API 密钥不能为空', 'apikeys.table.name': '密钥名称', 'apikeys.table.save.tips': '确保立即复制您的密钥。您将无法再次看到它!', 'apikeys.form.expiration.7days': '7天', diff --git a/src/pages/api-keys/components/add-apikey-modal/form.tsx b/src/pages/api-keys/components/add-apikey-modal/form.tsx index 697851147..c15e70039 100644 --- a/src/pages/api-keys/components/add-apikey-modal/form.tsx +++ b/src/pages/api-keys/components/add-apikey-modal/form.tsx @@ -3,7 +3,7 @@ import SealSelect from '@/components/seal-form/seal-select'; import { PageAction } from '@/config'; import { PageActionType } from '@/config/types'; import { useIntl } from '@umijs/max'; -import { Form } from 'antd'; +import { Form, Radio } from 'antd'; import React from 'react'; import { expirationOptions } from '../../config'; import { FormData, ListItem } from '../../config/types'; @@ -15,6 +15,7 @@ const APIKeyForm: React.FC<{ onValuesChange?: (changedValues: any, allValues: any) => void; }> = ({ action, currentData, onValuesChange }) => { const intl = useIntl(); + const [keyType, setKeyType] = React.useState<'auto' | 'custom'>('auto'); return ( <> @@ -39,6 +40,54 @@ const APIKeyForm: React.FC<{ required > + + {/* Key type selection - only for create action */} + {action === PageAction.CREATE && ( +