From a0a8dd0e3103787aec5820c8078a094a81cdeb75 Mon Sep 17 00:00:00 2001 From: sky22333 Date: Tue, 21 Apr 2026 23:20:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=BB=E6=9C=BA=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E7=BC=96=E8=BE=91=E9=97=AE=E9=A2=98=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E5=A4=8DWeb=E7=BB=88=E7=AB=AF=E5=8F=8C=E9=87=8D=E5=8F=91?= =?UTF-8?q?=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- database.py | 12 ++++++++++-- web/src/pages/TerminalPage.tsx | 16 +--------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/database.py b/database.py index d852f1e..80b98ba 100644 --- a/database.py +++ b/database.py @@ -160,10 +160,18 @@ class Database: """更新主机信息""" with self.get_connection() as conn: auth_method = host_data.get('auth_method', 'password') - encrypted_password = None + current_host = conn.execute( + "SELECT password FROM hosts WHERE id = ?", + (host_id,) + ).fetchone() + current_password = current_host["password"] if current_host else None - if auth_method == 'password' and host_data.get('password'): + if auth_method == 'key': + encrypted_password = None + elif host_data.get('password'): encrypted_password = self.crypto.encrypt(host_data['password']) + else: + encrypted_password = current_password conn.execute(""" UPDATE hosts diff --git a/web/src/pages/TerminalPage.tsx b/web/src/pages/TerminalPage.tsx index ab2df79..e8df91e 100644 --- a/web/src/pages/TerminalPage.tsx +++ b/web/src/pages/TerminalPage.tsx @@ -190,23 +190,9 @@ function TerminalPage() { term.current = terminal; terminal.open(terminalRef.current); - terminal.onKey(({ key, domEvent }) => { - if (domEvent.ctrlKey && domEvent.key === 'c') { - if (socket.current?.readyState === WebSocket.OPEN) { - socket.current.send(JSON.stringify({ type: 'input', data: '\x03' })); - } - } else { - if (socket.current?.readyState === WebSocket.OPEN) { - socket.current.send(JSON.stringify({ type: 'input', data: key })); - } - } - }); - terminal.onData((data) => { if (socket.current?.readyState === WebSocket.OPEN) { - if (data.length > 1) { - socket.current.send(JSON.stringify({ type: 'input', data })); - } + socket.current.send(JSON.stringify({ type: 'input', data })); } });