diff --git a/server/app/controller/ssh.js b/server/app/controller/ssh.js index 3f53d26..8ae1125 100644 --- a/server/app/controller/ssh.js +++ b/server/app/controller/ssh.js @@ -79,8 +79,8 @@ const removeSSH = async ({ res, request }) => { const getCommand = async ({ res, request }) => { let { host } = request.query if(!host) return res.fail({ data: false, msg: '参数错误' }) - let sshRecord = await readSSHRecord() - let record = sshRecord?.find(item => item.host === host) + let hostInfo = await readHostList() + let record = hostInfo?.find(item => item.host === host) consola.info('查询登录后执行的指令:', host) if(!record) return res.fail({ data: false, msg: 'host not found' }) // host不存在 const { command } = record diff --git a/server/app/socket/terminal.js b/server/app/socket/terminal.js index aeecf03..f383683 100644 --- a/server/app/socket/terminal.js +++ b/server/app/socket/terminal.js @@ -66,7 +66,8 @@ module.exports = (httpServer) => { } consola.info('准备连接终端:', host) targetHostInfo[targetHostInfo.authType] = await AESDecryptSync(targetHostInfo[targetHostInfo.authType]) - + // :TODO: 初始化后连接失败... + // console.log('targetHostInfo:', targetHostInfo) consola.log('连接信息', { username, port, authType }) sshClient .on('ready', () => { diff --git a/web/src/views/terminal/components/terminal-tab.vue b/web/src/views/terminal/components/terminal-tab.vue index 90eb7f9..d5371ca 100644 --- a/web/src/views/terminal/components/terminal-tab.vue +++ b/web/src/views/terminal/components/terminal-tab.vue @@ -13,7 +13,7 @@ import { WebLinksAddon } from 'xterm-addon-web-links' import socketIo from 'socket.io-client' const { io } = socketIo -const { proxy: { $api, $store, $serviceURI, $notification, $router, $message, $messageBox } } = getCurrentInstance() +const { proxy: { $api, $store, $serviceURI, $notification, $router, $message } } = getCurrentInstance() const props = defineProps({ host: { @@ -225,7 +225,7 @@ const handleInputCommand = (command) => { onMounted(async () => { createLocalTerminal() - // await getCommand() + await getCommand() connectIO() }) diff --git a/web/src/views/terminal/components/terminal.vue b/web/src/views/terminal/components/terminal.vue index ec39ac6..2863145 100644 --- a/web/src/views/terminal/components/terminal.vue +++ b/web/src/views/terminal/components/terminal.vue @@ -4,6 +4,8 @@
+ + 连接