From b2d89a80437bf1bddc06f9f43718535f27c0ab6d Mon Sep 17 00:00:00 2001 From: RGBadmin Date: Sat, 14 Mar 2026 11:22:54 +0800 Subject: [PATCH] feat(auth-files): add note field for individual credentials - Add note field to the credential field editor (PrefixProxyEditorModal) - Store note as a string in the credential JSON file - Display note on AuthFileCard with 2-line clamp for long text - Note is saved when non-empty, removed from JSON when cleared - Add i18n translations for zh-CN, en, and ru Co-Authored-By: Claude Opus 4.6 --- .../authFiles/components/AuthFileCard.tsx | 8 ++++++++ .../AuthFilesPrefixProxyEditorModal.tsx | 8 ++++++++ .../hooks/useAuthFilesPrefixProxyEditor.ts | 15 ++++++++++++++- src/i18n/locales/en.json | 4 ++++ src/i18n/locales/ru.json | 4 ++++ src/i18n/locales/zh-CN.json | 4 ++++ src/pages/AuthFilesPage.module.scss | 15 +++++++++++++++ 7 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/features/authFiles/components/AuthFileCard.tsx b/src/features/authFiles/components/AuthFileCard.tsx index 20aaae7..5cd01fa 100644 --- a/src/features/authFiles/components/AuthFileCard.tsx +++ b/src/features/authFiles/components/AuthFileCard.tsx @@ -112,6 +112,7 @@ export function AuthFileCard(props: AuthFileCardProps) { Boolean(rawStatusMessage) && !HEALTHY_STATUS_MESSAGES.has(rawStatusMessage.toLowerCase()); const priorityValue = parsePriorityValue(file.priority ?? file['priority']); + const noteValue = typeof file.note === 'string' ? file.note.trim() : ''; return (
+ {noteValue && ( +
+ {t('auth_files.note_display')}: + {noteValue} +
+ )} + {rawStatusMessage && hasStatusWarning && (
{rawStatusMessage} diff --git a/src/features/authFiles/components/AuthFilesPrefixProxyEditorModal.tsx b/src/features/authFiles/components/AuthFilesPrefixProxyEditorModal.tsx index 1cc6b03..4e7b25a 100644 --- a/src/features/authFiles/components/AuthFilesPrefixProxyEditorModal.tsx +++ b/src/features/authFiles/components/AuthFilesPrefixProxyEditorModal.tsx @@ -114,6 +114,14 @@ export function AuthFilesPrefixProxyEditorModal(props: AuthFilesPrefixProxyEdito disabled={disableControls || editor.saving || !editor.json} onChange={(e) => onChange('disableCooling', e.target.value)} /> + onChange('note', e.target.value)} + /> {editor.isCodexFile && (
diff --git a/src/features/authFiles/hooks/useAuthFilesPrefixProxyEditor.ts b/src/features/authFiles/hooks/useAuthFilesPrefixProxyEditor.ts index e99c534..7591483 100644 --- a/src/features/authFiles/hooks/useAuthFilesPrefixProxyEditor.ts +++ b/src/features/authFiles/hooks/useAuthFilesPrefixProxyEditor.ts @@ -18,7 +18,8 @@ export type PrefixProxyEditorField = | 'priority' | 'excludedModelsText' | 'disableCooling' - | 'websocket'; + | 'websocket' + | 'note'; export type PrefixProxyEditorFieldValue = string | boolean; @@ -37,6 +38,7 @@ export type PrefixProxyEditorState = { excludedModelsText: string; disableCooling: string; websocket: boolean; + note: string; }; export type UseAuthFilesPrefixProxyEditorOptions = { @@ -93,6 +95,13 @@ const buildPrefixProxyUpdatedText = (editor: PrefixProxyEditorState | null): str next.websocket = editor.websocket; } + const noteValue = editor.note.trim(); + if (noteValue) { + next.note = noteValue; + } else if ('note' in next) { + delete next.note; + } + return JSON.stringify(next); }; @@ -146,6 +155,7 @@ export function useAuthFilesPrefixProxyEditor( excludedModelsText: '', disableCooling: '', websocket: false, + note: '', }); try { @@ -195,6 +205,7 @@ export function useAuthFilesPrefixProxyEditor( const excludedModels = normalizeExcludedModels(json.excluded_models); const disableCoolingValue = parseDisableCoolingValue(json.disable_cooling); const websocketValue = parseDisableCoolingValue(json.websocket); + const note = typeof json.note === 'string' ? json.note : ''; setPrefixProxyEditor((prev) => { if (!prev || prev.fileName !== name) return prev; @@ -211,6 +222,7 @@ export function useAuthFilesPrefixProxyEditor( disableCooling: disableCoolingValue === undefined ? '' : disableCoolingValue ? 'true' : 'false', websocket: websocketValue ?? false, + note, error: null, }; }); @@ -235,6 +247,7 @@ export function useAuthFilesPrefixProxyEditor( if (field === 'priority') return { ...prev, priority: String(value) }; if (field === 'excludedModelsText') return { ...prev, excludedModelsText: String(value) }; if (field === 'disableCooling') return { ...prev, disableCooling: String(value) }; + if (field === 'note') return { ...prev, note: String(value) }; return { ...prev, websocket: Boolean(value) }; }); }; diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index af92324..9449cef 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -569,6 +569,10 @@ "disable_cooling_label": "Disable cooling (disable_cooling)", "disable_cooling_placeholder": "e.g. true / false / 1 / 0", "disable_cooling_hint": "Supports booleans, numeric 0/non-0, and strings like true/false/1/0; unparseable values are ignored.", + "note_label": "Note", + "note_placeholder": "Enter a note, e.g.: John's account", + "note_hint": "Optional. Used to describe the purpose or owner of this credential; leave empty to omit.", + "note_display": "Note", "prefix_proxy_invalid_json": "This auth file is not a JSON object, so fields cannot be edited.", "prefix_proxy_saved_success": "Updated auth file \"{{name}}\" successfully", "quota_refresh_success": "Quota refreshed for \"{{name}}\"", diff --git a/src/i18n/locales/ru.json b/src/i18n/locales/ru.json index c9a2564..7a3ff74 100644 --- a/src/i18n/locales/ru.json +++ b/src/i18n/locales/ru.json @@ -569,6 +569,10 @@ "disable_cooling_label": "Отключение охлаждения (disable_cooling)", "disable_cooling_placeholder": "например: true / false / 1 / 0", "disable_cooling_hint": "Поддерживает boolean, числа 0/не 0 и строки true/false/1/0; непарсируемые значения игнорируются.", + "note_label": "Заметка (note)", + "note_placeholder": "Введите заметку, например: аккаунт Ивана", + "note_hint": "Необязательно. Используется для описания назначения или владельца учётных данных; оставьте пустым, чтобы не записывать.", + "note_display": "Заметка", "prefix_proxy_invalid_json": "Этот файл авторизации не является JSON-объектом, поэтому поля нельзя редактировать.", "prefix_proxy_saved_success": "Файл авторизации \"{{name}}\" успешно обновлён", "card_tools_title": "Инструменты", diff --git a/src/i18n/locales/zh-CN.json b/src/i18n/locales/zh-CN.json index 729134b..0b3c0b1 100644 --- a/src/i18n/locales/zh-CN.json +++ b/src/i18n/locales/zh-CN.json @@ -569,6 +569,10 @@ "disable_cooling_label": "禁用冷却(disable_cooling)", "disable_cooling_placeholder": "例如: true / false / 1 / 0", "disable_cooling_hint": "支持布尔值、0/非0 数字或字符串 true/false/1/0;无法解析时忽略。", + "note_label": "备注(note)", + "note_placeholder": "输入备注信息,例如:张三的账号", + "note_hint": "可选,用于标记凭证用途或归属;留空则不写入。", + "note_display": "备注", "prefix_proxy_invalid_json": "该认证文件不是 JSON 对象,无法编辑字段。", "prefix_proxy_saved_success": "已更新认证文件 \"{{name}}\"", "quota_refresh_success": "已刷新 \"{{name}}\" 的额度", diff --git a/src/pages/AuthFilesPage.module.scss b/src/pages/AuthFilesPage.module.scss index b446c31..2c48487 100644 --- a/src/pages/AuthFilesPage.module.scss +++ b/src/pages/AuthFilesPage.module.scss @@ -646,6 +646,21 @@ } } +.noteText { + font-size: 12px; + color: var(--text-secondary); + line-height: 1.4; + overflow: hidden; + display: -webkit-box; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; + word-break: break-word; + + .noteLabel { + color: var(--text-tertiary); + } +} + .sortSelect { padding: 8px 12px; border: 1px solid var(--border-color);