diff --git a/src/components/config/VisualConfigEditor.tsx b/src/components/config/VisualConfigEditor.tsx
index 9432aa3..7dd6714 100644
--- a/src/components/config/VisualConfigEditor.tsx
+++ b/src/components/config/VisualConfigEditor.tsx
@@ -106,6 +106,13 @@ function ApiKeysCardEditor({
const [inputValue, setInputValue] = useState('');
const [formError, setFormError] = useState('');
+ function generateSecureApiKey(): string {
+ const charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
+ const array = new Uint8Array(17);
+ crypto.getRandomValues(array);
+ return 'sk-' + Array.from(array, (b) => charset[b % charset.length]).join('');
+ }
+
const openAddModal = () => {
setEditingIndex(null);
setInputValue('');
@@ -162,6 +169,11 @@ function ApiKeysCardEditor({
);
};
+ const handleGenerate = () => {
+ setInputValue(generateSecureApiKey());
+ setFormError('');
+ };
+
return (
@@ -233,6 +245,18 @@ function ApiKeysCardEditor({
disabled={disabled}
error={formError || undefined}
hint={t('config_management.visual.api_keys.input_hint')}
+ style={{ paddingRight: 148 }}
+ rightElement={
+
+ }
/>
diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json
index 4fcc00b..dfa9ea4 100644
--- a/src/i18n/locales/en.json
+++ b/src/i18n/locales/en.json
@@ -1011,6 +1011,7 @@
"api_keys": {
"label": "API Keys List (api-keys)",
"add": "Add API Key",
+ "generate": "Generate",
"empty": "No API keys",
"hint": "Each entry represents an API key (consistent with 'API Key Management' page style)",
"edit_title": "Edit API Key",
diff --git a/src/i18n/locales/ru.json b/src/i18n/locales/ru.json
index 788e1d3..87aff1e 100644
--- a/src/i18n/locales/ru.json
+++ b/src/i18n/locales/ru.json
@@ -1016,6 +1016,7 @@
"api_keys": {
"label": "Список API-ключей (api-keys)",
"add": "Добавить API-ключ",
+ "generate": "Сгенерировать",
"empty": "API-ключи отсутствуют",
"hint": "Каждая запись — это API-ключ (в том же стиле, что и на странице управления API-ключами)",
"edit_title": "Редактирование API-ключа",
diff --git a/src/i18n/locales/zh-CN.json b/src/i18n/locales/zh-CN.json
index 6ae82af..043316d 100644
--- a/src/i18n/locales/zh-CN.json
+++ b/src/i18n/locales/zh-CN.json
@@ -1011,6 +1011,7 @@
"api_keys": {
"label": "API 密钥列表 (api-keys)",
"add": "添加 API 密钥",
+ "generate": "生成",
"empty": "暂无 API 密钥",
"hint": "每个条目代表一个 API 密钥(与 「API 密钥管理」 页面样式一致)",
"edit_title": "编辑 API 密钥",