diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 43260916..173bda4a 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -425,6 +425,8 @@ "dsa": "DSA", "rsaSha2256": "RSA SHA2-256", "rsaSha2512": "RSA SHA2-512", + "uploadFile": "Upload File", + "pasteKey": "Paste Key", "updateKey": "Update Key", "addTagsSpaceToAdd": "add tags (space to add)", "terminalBadge": "Terminal", @@ -809,6 +811,7 @@ "folder": "folder", "password": "password", "keyPassword": "key password", + "pastePrivateKey": "Paste your private key here...", "credentialName": "My SSH Server", "description": "SSH credential description", "searchCredentials": "Search credentials by name, username, or tags...", diff --git a/public/locales/zh/translation.json b/public/locales/zh/translation.json index 41b22c95..427a8935 100644 --- a/public/locales/zh/translation.json +++ b/public/locales/zh/translation.json @@ -463,6 +463,8 @@ "dsa": "DSA", "rsaSha2256": "RSA SHA2-256", "rsaSha2512": "RSA SHA2-512", + "uploadFile": "上传文件", + "pasteKey": "粘贴密钥", "updateKey": "更新密钥", "addTagsSpaceToAdd": "添加标签(空格添加)", "terminalBadge": "终端", @@ -849,6 +851,7 @@ "description": "SSH凭据描述", "searchCredentials": "按名称、用户名或标签搜索凭据...", "keyPassword": "密钥密码", + "pastePrivateKey": "在此粘贴您的私钥...", "sshConfig": "端点 SSH 配置", "homePath": "/home", "clientId": "您的客户端 ID", diff --git a/src/ui/Desktop/Apps/Host Manager/HostManagerHostEditor.tsx b/src/ui/Desktop/Apps/Host Manager/HostManagerHostEditor.tsx index b1942590..502c7e1e 100644 --- a/src/ui/Desktop/Apps/Host Manager/HostManagerHostEditor.tsx +++ b/src/ui/Desktop/Apps/Host Manager/HostManagerHostEditor.tsx @@ -61,6 +61,7 @@ export function HostManagerHostEditor({editingHost, onFormSubmit}: SSHManagerHos const [loading, setLoading] = useState(true); const [authTab, setAuthTab] = useState<'password' | 'key' | 'credential'>('password'); + const [keyInputMethod, setKeyInputMethod] = useState<'upload' | 'paste'>('upload'); // Ref for the IP address input to manage focus const ipInputRef = useRef(null); @@ -696,40 +697,79 @@ export function HostManagerHostEditor({editingHost, onFormSubmit}: SSHManagerHos /> -
- ( - - {t('hosts.sshPrivateKey')} - -
- { - const file = e.target.files?.[0]; - field.onChange(file || null); - }} - className="absolute inset-0 w-full h-full opacity-0 cursor-pointer" + { + setKeyInputMethod(value as 'upload' | 'paste'); + // Clear the other field when switching + if (value === 'upload') { + form.setValue('key', null); + } else { + form.setValue('key', ''); + } + }} + className="w-full" + > + + {t('hosts.uploadFile')} + {t('hosts.pasteKey')} + + + ( + + {t('hosts.sshPrivateKey')} + +
+ { + const file = e.target.files?.[0]; + field.onChange(file || null); + }} + className="absolute inset-0 w-full h-full opacity-0 cursor-pointer" + /> + +
+
+
+ )} + /> +
+ + ( + + {t('hosts.sshPrivateKey')} + +