mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/sky22333/ansible-ui
synced 2026-09-20 08:03:57 +08:00
修复主机密码编辑问题,修复Web终端双重发送
This commit is contained in:
12
database.py
12
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
|
||||
|
||||
@@ -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 }));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user