修复主机密码编辑问题,修复Web终端双重发送

This commit is contained in:
sky22333
2026-04-21 23:20:57 +08:00
parent dda2624bc4
commit a0a8dd0e31
2 changed files with 11 additions and 17 deletions

View File

@@ -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

View File

@@ -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 }));
}
});